/// <summary> /// Return true if the anti-commutator product of the given euclidean basis blades ids is always zero /// </summary> /// <param name="id1"></param> /// <param name="id2"></param> /// <returns></returns> public static bool IsZeroEuclideanAcp(int id1, int id2) { return(FrameUtils.IsNegativeEGp(id1, id2) == !FrameUtils.IsNegativeEGp(id2, id1)); }
/// <summary> /// Compute and fill all GA lookup tables /// </summary> private static void ComputeGaLookupTables() { const int c = 1; const int d = 1; var gaSpaceDim = (c << FrameUtils.MaxVSpaceDimension); var maxId = gaSpaceDim - 1; var gradeCount = new int[FrameUtils.MaxVSpaceDimension + 1]; //Initialize all tables IdToGradeTable = new int[gaSpaceDim]; IdToIndexTable = new int[gaSpaceDim]; IsNegativeReverseTable = new BitArray(gaSpaceDim); IsNegativeGradeInvTable = new BitArray(gaSpaceDim); IsNegativeClifConjTable = new BitArray(gaSpaceDim); IsNegativeEGpTable = new BitArray(d << (2 * FrameUtils.MaxVSpaceDimension)); GradeIndexToIdTable = new List <int[]>(FrameUtils.MaxVSpaceDimension); //var stopWatch = new Stopwatch(); //long ticks = 0; for (var id = 0; id <= maxId; id++) { var grade = id.CountOnes(); IdToGradeTable[id] = grade; //Calculate grade inversion sign if (grade.GradeHasNegativeGradeInv()) { IsNegativeGradeInvTable.Set(id, true); } //Calculate reversion sign if (grade.GradeHasNegativeReverse()) { IsNegativeReverseTable.Set(id, true); } //Calculate Clifford conjugate sign if (grade.GradeHasNegativeClifConj()) { IsNegativeClifConjTable.Set(id, true); } //Calculate index of basis blade ID IdToIndexTable[id] = gradeCount[grade]; gradeCount[grade] += 1; //stopWatch.Start(); //Calculate the sign of the geometric product of basis blades var id1 = id; for (var id2 = 0; id2 <= maxId; id2++) { if (FrameUtils.ComputeIsNegativeEGp(id1, id2)) { IsNegativeEGpTable.Set(FrameUtils.JoinIDs(id1, id2), true); } } //stopWatch.Stop(); //ticks += stopWatch.ElapsedTicks; } //MessageBox.Show(ticks.ToString("###,###,###,###,###")); //Calculate inverse index table: (grade, index) to ID table gradeCount = new int[gaSpaceDim]; for (var id = 0; id <= maxId; id++) { var grade = IdToGradeTable[id]; var index = gradeCount[grade]; gradeCount[grade] += 1; if (gradeCount[grade] == 1) { GradeIndexToIdTable.Add(new int[Choose(FrameUtils.MaxVSpaceDimension, grade)]); } GradeIndexToIdTable[grade][index] = id; } }