From a40fee25131eae84b8f0c80db248ad14b70195b7 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 8 Jun 2023 13:02:13 +0900 Subject: [PATCH] [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. --- ruamoko/gatest/multivector.r | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ruamoko/gatest/multivector.r b/ruamoko/gatest/multivector.r index 81a6b29d6..976879ca4 100644 --- a/ruamoko/gatest/multivector.r +++ b/ruamoko/gatest/multivector.r @@ -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;