bugfixes in tensor

This commit is contained in:
jiri committed 2026-10-29 21:51:03 +01:00
1 parent 4fac0f0dda
commit 22e3d2fb63
1 file changed
+5 -2
+5 -2
View File
@@ -107,8 +107,11 @@ public:
Signedpointer(T *p, int s) : ptr(p),sgn(s) {}; Signedpointer(T *p, int s) : ptr(p),sgn(s) {};
//dereferencing *ptr should be ignored for sgn==0 //dereferencing *ptr should be ignored for sgn==0
const T operator=(const T rhs) {if(ptr_ok(ptr)) *ptr = signeddata(sgn,rhs); return rhs;} const T operator=(const T rhs) {if(ptr_ok(ptr)) *ptr = signeddata(sgn,rhs); return rhs;}
void operator*=(const T rhs) {if(ptr_ok(ptr)) *ptr *= rhs;} //the element L is related to the stored value S by L=signeddata(sgn,S): S, -S, conj(S) (sgn 2) or -conj(S) (sgn -2)
void operator/=(const T rhs) {if(ptr_ok(ptr)) *ptr /= rhs;} //for sgn +-1: L*a = +-S*a, so S*=a; for sgn +-2: L*a = +-conj(S)*a = +-conj(S*conj(a)), so S*=conj(a)
//(signeddata(sgn,rhs) cannot be used here, for negative sgn it would also negate the factor)
void operator*=(const T rhs) {if(ptr_ok(ptr)) *ptr *= (sgn==2||sgn== -2)? LA_traits<T>::conjugate(rhs) : rhs;}
void operator/=(const T rhs) {if(ptr_ok(ptr)) *ptr /= (sgn==2||sgn== -2)? LA_traits<T>::conjugate(rhs) : rhs;}
void operator+=(T rhs) {if(ptr_ok(ptr)) *ptr += signeddata(sgn,rhs);} void operator+=(T rhs) {if(ptr_ok(ptr)) *ptr += signeddata(sgn,rhs);}
void operator-=(T rhs) {if(ptr_ok(ptr)) *ptr -= signeddata(sgn,rhs);} void operator-=(T rhs) {if(ptr_ok(ptr)) *ptr -= signeddata(sgn,rhs);}
}; };