diff --git a/rogueviz/ads/math.cpp b/rogueviz/ads/math.cpp index 82ca3d99..bddebc4e 100644 --- a/rogueviz/ads/math.cpp +++ b/rogueviz/ads/math.cpp @@ -15,8 +15,8 @@ struct ads_point : shiftpoint { /** similarly, ads_matrix represents a transformation of the universal cover space */ struct ads_matrix : shiftmatrix { ads_matrix(transmatrix _h = Id, ld _s = 0) { T = _h; shift = _s; } - ads_point operator* (ads_point) const; - ads_matrix operator* (ads_matrix) const; + ads_point operator* (const ads_point&) const; + ads_matrix operator* (const ads_matrix&) const; ads_point operator* (const hyperpoint& h) const { return ads_point(T*h, shift); } ads_matrix operator* (const transmatrix& h) const { return ads_matrix(T*h, shift); } ads_matrix(shiftmatrix _s) : shiftmatrix(_s) {} @@ -61,47 +61,16 @@ transmatrix chg_shift(ld x) { return cspin(2, 3, x) * cspin(0, 1, x); } -ads_point ads_matrix::operator*(ads_point h) const { - auto& T = *this; - optimize_shift(h); - ld sh = get_shift_cycles(h.shift); - h.shift -= sh; - auto res0 = T; - optimize_shift(res0); - auto res1 = res0 * chg_shift(h.shift); - optimize_shift(res1); - res1.shift += get_shift_cycles(res0.shift - res1.shift); - auto res2 = res1 * h.h; - optimize_shift(res2); - res2.shift += get_shift_cycles(res1.shift - res2.shift); - res2.shift += sh; - return res2; +ads_point ads_matrix::operator*(const ads_point& h) const { + return ads_point(twist::nmul(self, h)); } -ads_matrix ads_matrix::operator*(ads_matrix h) const { - auto& T = *this; - optimize_shift(h); - ld sh = get_shift_cycles(h.shift); - h.shift -= sh; - - auto res0 = T; - optimize_shift(res0); - auto res1 = res0 * chg_shift(h.shift); - optimize_shift(res1); - res1.shift += get_shift_cycles(res0.shift - res1.shift); - auto res2 = res1 * h.T; - optimize_shift(res2); - res2.shift += get_shift_cycles(res1.shift - res2.shift); - res2.shift += sh; - return res2; +ads_matrix ads_matrix::operator*(const ads_matrix& h) const { + return ads_matrix(twist::nmul(self, h)); } ads_matrix ads_inverse(const ads_matrix& T) { - ads_matrix res(inverse(unshift(T)), 0); - ads_matrix m = res * T; - optimize_shift(m); - res.shift -= m.shift; - return res; + return ads_matrix(twist::ninverse(T)); } struct cross_result {