protected void ValidateEqual(string msg, GaNumMultivector mv1, GaNumMultivector mv2) { ReportComposer.AppendLineAtNewLine(); ReportComposer.AppendAtNewLine(msg); var diff = mv2 - mv1; if (diff.IsNearZero(NumericEpsilon)) { ReportComposer.AppendLine("... << Validated >>"); if (ShowValidatedResults) { ReportComposer .IncreaseIndentation(); ReportComposer .AppendLineAtNewLine("Result: ") .IncreaseIndentation() .AppendLine(mv1.ToString()) .DecreaseIndentation() .AppendLine(); ReportComposer .DecreaseIndentation(); } return; } ReportComposer.AppendLine("... << Invalid >>"); ReportComposer .IncreaseIndentation(); ReportComposer .AppendLineAtNewLine("First Value: ") .IncreaseIndentation() .AppendLine(mv1.ToString()) .DecreaseIndentation() .AppendLine(); ReportComposer .AppendLineAtNewLine("Second Value: ") .IncreaseIndentation() .AppendLine(mv2.ToString()) .DecreaseIndentation() .AppendLine(); ReportComposer .AppendLineAtNewLine("Difference: ") .IncreaseIndentation() .AppendLine(diff.ToString()) .DecreaseIndentation() .AppendLine(); ReportComposer .DecreaseIndentation(); }
private void ValidateComputingMainProductsSymbolic(int grade1, int grade2) { ReportComposer.AppendLineAtNewLine(); ReportComposer.AppendHeader("Grades: <" + grade1 + ", " + grade2 + ">", 2); //Initialize blades with random integer coefficients var mv1 = RandomGenerator.GetSymBlade(SymbolicFrame.GaSpaceDimension, grade1); var mv2 = RandomGenerator.GetSymBlade(SymbolicFrame.GaSpaceDimension, grade2); //Compute their geometric product var mvGp = SymbolicFrame.Gp[mv1, mv2]; //Compute their Outer Product and test its relation to the geometric product var mvOp1 = SymbolicFrame.Op[mv1, mv2]; var mvOp2 = mvGp.GetKVectorPart(grade1 + grade2); ValidateEqual("Outer Product: ", mvOp1, mvOp2); //Compute their Scalar Product and test its relation to the geometric product var mvSp1 = SymbolicFrame.Sp[mv1, mv2]; var mvSp2 = mvGp.GetKVectorPart(0); ValidateEqual("Scalar Product: ", mvSp1, mvSp2); //Compute their Left Contraction Product and test its relation to the geometric product var mvLcp1 = SymbolicFrame.Lcp[mv1, mv2]; var mvLcp2 = mvGp.GetKVectorPart(grade2 - grade1); ValidateEqual("Left Contraction Product: ", mvLcp1, mvLcp2); //Compute their Right Contraction Product and test its relation to the geometric product var mvRcp1 = SymbolicFrame.Rcp[mv1, mv2]; var mvRcp2 = mvGp.GetKVectorPart(grade1 - grade2); ValidateEqual("Right Contraction Product: ", mvRcp1, mvRcp2); //Compute their Fat-Dot Product and test its relation to the geometric product var mvFdp1 = SymbolicFrame.Fdp[mv1, mv2]; var mvFdpGrade = grade1 == grade2 ? 0 : Math.Abs(grade1 - grade2); var mvFdp2 = mvGp.GetKVectorPart(mvFdpGrade); ValidateEqual("Fat-Dot Product: ", mvFdp1, mvFdp2); //Compute their Anti-Commutator Product and test its relation to the geometric product var mvAcp1 = SymbolicFrame.Acp[mv1, mv2]; var mvAcp2 = (SymbolicFrame.Gp[mv1, mv2] + SymbolicFrame.Gp[mv2, mv1]) / 2; ValidateEqual("Anti-Commutator Product: ", mvAcp1, mvAcp2); //Compute their Commutator Product and test its relation to the geometric product var mvCp1 = SymbolicFrame.Cp[mv1, mv2]; var mvCp2 = (SymbolicFrame.Gp[mv1, mv2] - SymbolicFrame.Gp[mv2, mv1]) / 2; ValidateEqual("Commutator Product: ", mvCp1, mvCp2); ReportComposer.AppendLineAtNewLine(); }
private void ValidateNumericFrame() { ReportComposer.AppendHeader("Numeric Bilinear Products Validations"); //Initialize multivectors with random coefficients var mv1 = RandomGenerator.GetNumMultivectorFull(SymbolicFrame.GaSpaceDimension); var mv2 = RandomGenerator.GetNumMultivectorFull(SymbolicFrame.GaSpaceDimension); var mvComputedGp = NumericFrame.ComputedGp[mv1, mv2]; var mvComputedOp = NumericFrame.ComputedOp[mv1, mv2]; var mvComputedSp = NumericFrame.ComputedSp[mv1, mv2]; var mvComputedLcp = NumericFrame.ComputedLcp[mv1, mv2]; var mvComputedRcp = NumericFrame.ComputedRcp[mv1, mv2]; var mvComputedFdp = NumericFrame.ComputedFdp[mv1, mv2]; var mvComputedHip = NumericFrame.ComputedHip[mv1, mv2]; var mvComputedAcp = NumericFrame.ComputedAcp[mv1, mv2]; var mvComputedCp = NumericFrame.ComputedCp[mv1, mv2]; //Compute their products using several methods for (var i = 0; i < _methods.Length; i++) { var method = _methods[i]; var methodName = _methodNames[i]; if (NumericFrame.IsNonOrthogonal) { NumericFrame.BaseOrthogonalFrame.SetProductsImplementation(method); } NumericFrame.SetProductsImplementation(method); ReportComposer.AppendLineAtNewLine(); ReportComposer.AppendHeader(methodName, 2); ValidateEqual("Geometric Product: ", mvComputedGp, NumericFrame.Gp[mv1, mv2]); ValidateEqual("Outer Product: ", mvComputedOp, NumericFrame.Op[mv1, mv2]); ValidateEqual("Scalar Product: ", mvComputedSp, NumericFrame.Sp[mv1, mv2]); ValidateEqual("Left Contraction Product: ", mvComputedLcp, NumericFrame.Lcp[mv1, mv2]); ValidateEqual("Right Contraction Product: ", mvComputedRcp, NumericFrame.Rcp[mv1, mv2]); ValidateEqual("Fat-Dot Product: ", mvComputedFdp, NumericFrame.Fdp[mv1, mv2]); ValidateEqual("Hestenes Inner Product: ", mvComputedHip, NumericFrame.Hip[mv1, mv2]); ValidateEqual("Anti-Commutator Product: ", mvComputedAcp, NumericFrame.Acp[mv1, mv2]); ValidateEqual("Commutator Product: ", mvComputedCp, NumericFrame.Cp[mv1, mv2]); ReportComposer.AppendLineAtNewLine(); } ReportComposer.AppendLineAtNewLine(); }