[gatest] Calculate correct sign for duals

I was aware in the beginning that the signs were probably incorrect, but
I had left them as I wasn't sure how they worked.  Thanks to enki
(bivector community), I was pointed in the right direction for getting
the calculations right: the product of a basis blade with its dual
(x !x) must product the positive pseudo-scalar.
This commit is contained in:
Bill Currie 2023-06-08 13:02:13 +09:00
parent 2858870153
commit a40fee2513

View file

@ -263,9 +263,11 @@ static MultiVector *new_mv (Algebra *algebra, BasisLayout *layout)
}
double lc = components[i];
BasisBlade *lb = [layout bladeAt:i];
unsigned mask = [lb mask] ^ dual_mask;
double s = 1;
int ind = [layout bladeIndex:mask];
unsigned lb_mask = [lb mask];
unsigned mask = lb_mask ^ dual_mask;
double ls = [lb scale];
double s = count_flips (lb_mask, mask) & 1 ? -1 : 1;
int ind = [dual.layout bladeIndex:mask];
dual.components[ind] += s * lc;
}
return dual;