public static Blade InnerProduct(Basis e1, Basis e2) { int hashPair = Basis.GetHashPair(e1, e2); if (innerProductCache.ContainsKey(hashPair)) { return(innerProductCache[hashPair]); } Blade result; if (e1.IsNullMetric || e2.IsNullMetric) { MultiVector m1 = e1.ToMinkowskiMetric(); MultiVector m2 = e2.ToMinkowskiMetric(); result = (Blade)MultiVector.InnerProduct(m1, m2).ToNullMetric(); } else { if ((e1.bitMask & ~e2.bitMask) == 0) { result = (Blade)(e1 * e2); } else { result = Blade.Zero; } } innerProductCache.Add(hashPair, result); return(result); }
public static MultiVector GeometricProduct(Basis e1, Basis e2) { int hashPair = Basis.GetHashPair(e1, e2); if (geometricProductCache.ContainsKey(hashPair)) { return(geometricProductCache[hashPair]); } MultiVector result; if (e1.IsNullMetric || e2.IsNullMetric) { MultiVector m1 = e1.ToMinkowskiMetric(); MultiVector m2 = e2.ToMinkowskiMetric(); result = (m1 * m2).ToNullMetric(); } else { int rBitMask = e1.bitMask ^ e2.bitMask; double rValue = Basis.Order(e1, e2); int common = e1.bitMask & e2.bitMask; int i = 0; while (common != 0) { if ((common & 0x1) != 0) { rValue *= Basis.minkowskiSignature[i]; } common >>= 1; i++; } result = new Blade(new Basis(rBitMask, false), rValue); } geometricProductCache.Add(hashPair, result); return(result); }
public static Blade OuterProduct(Basis e1, Basis e2) { int hashPair = Basis.GetHashPair(e1, e2); if (outerProductCache.ContainsKey(hashPair)) return outerProductCache[hashPair]; Blade result; if (e1.IsNullMetric || e2.IsNullMetric) { MultiVector m1 = e1.ToMinkowskiMetric(); MultiVector m2 = e2.ToMinkowskiMetric(); result = (Blade)(m1 ^ m2).ToNullMetric(); } else { if ((e1.bitMask & e2.bitMask) == 0) result = (Blade)(e1 * e2); else result = Blade.Zero; } outerProductCache.Add(hashPair, result); return result; }
public static MultiVector GeometricProduct(Basis e1, Basis e2) { int hashPair = Basis.GetHashPair(e1, e2); if (geometricProductCache.ContainsKey(hashPair)) return geometricProductCache[hashPair]; MultiVector result; if (e1.IsNullMetric || e2.IsNullMetric) { MultiVector m1 = e1.ToMinkowskiMetric(); MultiVector m2 = e2.ToMinkowskiMetric(); result = (m1 * m2).ToNullMetric(); } else { int rBitMask = e1.bitMask ^ e2.bitMask; double rValue = Basis.Order(e1, e2); int common = e1.bitMask & e2.bitMask; int i = 0; while (common != 0) { if ((common & 0x1) != 0) rValue *= Basis.minkowskiSignature[i]; common >>= 1; i++; } result = new Blade(new Basis(rBitMask, false), rValue); } geometricProductCache.Add(hashPair, result); return result; }