internal GaSymMetricNonOrthogonal(GaSymFrame baseFrame, GaSymFrame derivedFrame, GaSymOutermorphism derivedToBaseCba, GaSymOutermorphism baseToDerivedCba) { BaseFrame = baseFrame; DerivedFrame = derivedFrame; DerivedToBaseCba = derivedToBaseCba; BaseToDerivedCba = baseToDerivedCba; }
///Select the signature definition method of the current frame private GaSymFrame translate_Frame_Signature(ParseTreeNode node) { var subnode = node.ChildNodes[0]; switch (subnode.ToString()) { case GMacParseNodeNames.FrameSignatureEuclidean: return(GaSymFrame.CreateEuclidean(_vSpaceDim)); case GMacParseNodeNames.FrameSignatureIpm: return(translate_Frame_Signature_IPM(subnode)); case GMacParseNodeNames.FrameSignatureCbm: return(translate_Frame_Signature_CBM(subnode)); case GMacParseNodeNames.FrameSignatureOrthonormal: return(translate_Frame_Signature_Orthonormal(subnode)); case GMacParseNodeNames.FrameSignatureOrthogonal: return(translate_Frame_Signature_Orthogonal(subnode)); case GMacParseNodeNames.FrameSignatureReciprocal: return(translate_Frame_Signature_Reciprocal(subnode)); default: return(CompilationLog.RaiseGeneratorError <GaSymFrame>("Illegal frame signature definition", subnode)); } }
public static GaSymMapUnilinearCoefSums RotorProductToCoefSumsMap(this GaSymFrame frame, GaSymMultivector rotorVersor) { return(frame .RotorProduct(rotorVersor, frame.BasisVectorIDs()) .ToOutermorphismDictionary() .ToCoefSumsMap(frame.VSpaceDimension, frame.VSpaceDimension)); }
public static GaSymMapUnilinearArray EvenVersorProductToArrayMap(this GaSymFrame frame, GaSymMultivector evenVersor) { return(frame .EvenVersorProduct(evenVersor, frame.BasisVectorIDs()) .ToOutermorphismDictionary() .ToArrayMap(frame.VSpaceDimension, frame.VSpaceDimension)); }
public static GaSymMapUnilinearTree OddVersorProductToTreeMap(this GaSymFrame frame, GaSymMultivector oddVersor) { return(frame .OddVersorProduct(oddVersor, frame.BasisVectorIDs()) .ToOutermorphismDictionary() .ToTreeMap(frame.VSpaceDimension, frame.VSpaceDimension)); }
public void Setup() { _frame = GaSymFrame.CreateConformal(5); _lcpLookupTable = _frame.Lcp.ToHashMap(); for (var i = 0; i < 10; i++) { _multivectors.Add(_randGen.GetSymMultivector(_frame.GaSpaceDimension)); } }
public GaSymMultivector GetSymNonNullVector(GaSymFrame frame) { GaSymMultivector mv; do { mv = GetSymVector(frame.GaSpaceDimension); }while (!frame.Norm2(mv).IsZero()); return(mv); }
public string Execute() { var validation = new GaBilinearProductsValidator(); validation.SymbolicFrame = GaSymFrame.CreateConformal(5); validation.NumericFrame = GaNumFrame.CreateConformal(5); validation.ShowValidatedResults = false; return(validation.Validate()); }
///Set the signature of the current frame to a signature vector (diagonal IPM) private GaSymFrame translate_Frame_Signature_Orthogonal(ParseTreeNode node) { var bvSigVector = MathematicaVector.Create(Cas, GenUtils.Translate_StringLiteral(node.ChildNodes[0])); if (bvSigVector.Size != _vSpaceDim) { CompilationLog.RaiseGeneratorError <int>("Expecting a vector with " + _vSpaceDim + " items", node.ChildNodes[0]); } return(GaSymFrame.CreateOrthogonal(bvSigVector)); }
///Set the signature of the current frame to a signature vector of +1's and -1's (diagonal IPM) private GaSymFrame translate_Frame_Signature_Orthonormal(ParseTreeNode node) { var bvSigString = GenUtils.Translate_StringLiteral(node.ChildNodes[0]).Trim(); if (bvSigString.Count(c => c == '+' || c == '-') != _vSpaceDim || bvSigString.Length != _vSpaceDim) { CompilationLog.RaiseGeneratorError <int>("Expecting a vector of " + _vSpaceDim + @" (+\-) items", node.ChildNodes[0]); } return(GaSymFrame.CreateOrthonormal(bvSigString)); }
/// <summary> /// Create a child frame /// </summary> /// <param name="frameName"></param> /// <param name="basisVectorsNames"></param> /// <param name="attachedSymbolicFrame"></param> /// <returns></returns> internal GMacFrame DefineFrame(string frameName, string[] basisVectorsNames, GaSymFrame attachedSymbolicFrame) { var newFrame = new GMacFrame(frameName, ChildSymbolScope, attachedSymbolicFrame); GMacRootAst.FramesCount++; newFrame.DefineFrameMultivector(); newFrame.DefineBasisVectors(basisVectorsNames); return(newFrame); }
///Set the signature of the current frame to be defined by IPM private GaSymFrame translate_Frame_Signature_IPM(ParseTreeNode node) { //Read the IPM symbolic matrix var ipmMatrix = MathematicaMatrix.Create(Cas, GenUtils.Translate_StringLiteral(node.ChildNodes[0])); if (ipmMatrix.IsSymmetric() == false || ipmMatrix.RowCount != _vSpaceDim) { CompilationLog.RaiseGeneratorError <int>("Expecting a square symmetric matrix with " + _vSpaceDim + " rows", node.ChildNodes[0]); } return(GaSymFrame.CreateFromIpm(ipmMatrix)); }
public GaSymMultivector GetSymVersor(GaSymFrame frame, int vectorsCount) { var mv = GetSymNonNullVector(frame); vectorsCount--; while (vectorsCount > 0) { mv = frame.Gp[mv, GetSymNonNullVector(frame)]; vectorsCount--; } return(mv); }
///Set the signature of the current frame to a reciprocal frame private GaSymFrame translate_Frame_Signature_Reciprocal(ParseTreeNode node) { var baseFrame = (GMacFrame)GMacValueAccessGenerator.Translate_Direct(Context, node.ChildNodes[0], RoleNames.Frame); if (baseFrame.VSpaceDimension != _vSpaceDim) { CompilationLog.RaiseGeneratorError <int>("Base frame must be of dimension " + _vSpaceDim, node.ChildNodes[0]); } _baseFrame = baseFrame; var derivedFrameSystem = GaSymFrame.CreateReciprocalCbmFrameSystem(baseFrame.SymbolicFrame); return(derivedFrameSystem.DerivedFrame); }
private GMacFrame DefineFrame(string frameName, string[] basisVectorsNames, GaSymFrame attachedSymbolicFrame, bool defineDefaultObjects) { if (Context.GMacRootAst.FramesCount + 1 > GMacCompilerFeatures.MaxFramesNumber) { CompilationLog.RaiseGeneratorError <int>($"Can't define more than {GMacCompilerFeatures.MaxFramesNumber} frames", RootParseNode); } var frame = Context.ParentNamespace.DefineFrame(frameName, basisVectorsNames, attachedSymbolicFrame); if (defineDefaultObjects) { DefineFrameDefaultObjects(frame); } return(frame); }
internal GMacFrame(string frameName, LanguageScope parentScope, GaSymFrame attachedFrame) : base(frameName, parentScope, RoleNames.Frame) { SymbolicFrame = attachedFrame; FrameBasisVectors = ChildSymbolScope.Symbols(RoleNames.FrameBasisVector).Cast <GMacFrameBasisVector>(); ChildConstants = ChildSymbolScope.Symbols(RoleNames.Constant).Cast <GMacConstant>(); ChildMacros = ChildSymbolScope.Symbols(RoleNames.Macro).Cast <GMacMacro>(); FrameSubspaces = ChildSymbolScope.Symbols(RoleNames.FrameSubspace).Cast <GMacFrameSubspace>(); Structures = ChildSymbolScope.Symbols(RoleNames.Structure).Cast <GMacStructure>(); Transforms = ChildSymbolScope.Symbols(RoleNames.Transform).Cast <GMacMultivectorTransform>(); }
///Set the signature of the current frame to a base frame with a change of basis matrix private GaSymFrame translate_Frame_Signature_CBM(ParseTreeNode node) { var baseFrame = (GMacFrame)GMacValueAccessGenerator.Translate_Direct(Context, node.ChildNodes[0], RoleNames.Frame); if (baseFrame.VSpaceDimension != _vSpaceDim) { CompilationLog.RaiseGeneratorError <int>("Base frame must be of dimension " + _vSpaceDim, node.ChildNodes[0]); } var cbmMatrix = MathematicaMatrix.Create(Cas, GenUtils.Translate_StringLiteral(node.ChildNodes[1])); if (cbmMatrix.IsInvertable() == false || cbmMatrix.RowCount != _vSpaceDim) { CompilationLog.RaiseGeneratorError <int>("Expecting a square invertable matrix with " + _vSpaceDim + " rows", node.ChildNodes[1]); } _baseFrame = baseFrame; var derivedFrameSystem = GaSymFrame.CreateDerivedCbmFrameSystem(baseFrame.SymbolicFrame, cbmMatrix); return(derivedFrameSystem.DerivedFrame); }
public string Execute() { var randGen = new GMacRandomGenerator(10); var textComposer = new LinearComposer(); var numFrame = GaNumFrame.CreateConformal(5); var symFrame = GaSymFrame.CreateConformal(5); var numMv1 = randGen.GetNumMultivectorFull(numFrame.GaSpaceDimension); var numMv2 = randGen.GetNumMultivectorFull(numFrame.GaSpaceDimension); var symMv1 = numMv1.ToSymbolic(); var symMv2 = numMv2.ToSymbolic(); var symMvGp = symFrame.Gp[symMv1, symMv2]; //textComposer.AppendLineAtNewLine("Symbolic Multivector 1: ").AppendLine(symMv1); //textComposer.AppendLineAtNewLine("Numeric Multivector 1: ").AppendLine(numMv1); //textComposer.AppendLineAtNewLine("Symbolic Multivector 2: ").AppendLine(symMv2); //textComposer.AppendLineAtNewLine("Numeric Multivector 2: ").AppendLine(numMv2); //textComposer.AppendLineAtNewLine("Symbolic Gp: ").AppendLine(symMvGp); //textComposer.AppendLineAtNewLine("Numeric GP: ").AppendLine(numMvGp); numFrame.SetProductsImplementation(GaBilinearProductImplementation.Computed); GaNumMultivector.ResetAddFactorsCallCount(); var numMvGp = numFrame.Gp[numMv1, numMv2]; var callsCount = GaNumMultivector.AddFactorsCallCount; var diff = symMvGp.ToNumeric() - numMvGp; diff.Simplify(); GaNumMultivector.ResetAddFactorsCallCount(); textComposer .AppendLineAtNewLine("Difference, Computed Tree: ") .AppendLine(callsCount) .AppendLine(diff); numFrame.SetProductsImplementation(GaBilinearProductImplementation.LookupArray); GaNumMultivector.ResetAddFactorsCallCount(); numMvGp = numFrame.Gp[numMv1, numMv2]; callsCount = GaNumMultivector.AddFactorsCallCount; //var factorsCount = ((GaNumMapBilinearArray) numFrame.Gp).FactorsCount; diff = symMvGp.ToNumeric() - numMvGp; diff.Simplify(); GaNumMultivector.ResetAddFactorsCallCount(); textComposer .AppendLineAtNewLine("Difference, Lookup Array: ") .AppendLine(callsCount) //.AppendLine(factorsCount) .AppendLine(diff); numFrame.SetProductsImplementation(GaBilinearProductImplementation.LookupHash); GaNumMultivector.ResetAddFactorsCallCount(); numMvGp = numFrame.Gp[numMv1, numMv2]; callsCount = GaNumMultivector.AddFactorsCallCount; //factorsCount = ((GaNumMapBilinearHash)numFrame.Gp).FactorsCount; diff = symMvGp.ToNumeric() - numMvGp; diff.Simplify(); GaNumMultivector.ResetAddFactorsCallCount(); textComposer .AppendLineAtNewLine("Difference, Lookup Hash: ") .AppendLine(callsCount) //.AppendLine(factorsCount) .AppendLine(diff); numFrame.SetProductsImplementation(GaBilinearProductImplementation.LookupTree); GaNumMultivector.ResetAddFactorsCallCount(); numMvGp = numFrame.Gp[numMv1, numMv2]; callsCount = GaNumMultivector.AddFactorsCallCount; //factorsCount = ((GaNumMapBilinearTree)numFrame.Gp).FactorsCount; diff = symMvGp.ToNumeric() - numMvGp; diff.Simplify(); GaNumMultivector.ResetAddFactorsCallCount(); textComposer .AppendLineAtNewLine("Difference, Lookup Tree: ") .AppendLine(callsCount) //.AppendLine(factorsCount) .AppendLine(diff); numFrame.SetProductsImplementation(GaBilinearProductImplementation.LookupCoefSums); GaNumMultivector.ResetAddFactorsCallCount(); numMvGp = numFrame.Gp[numMv1, numMv2]; callsCount = GaNumMultivector.AddFactorsCallCount; //factorsCount = ((GaNumMapBilinearCoefSums)numFrame.Gp).FactorsCount; diff = symMvGp.ToNumeric() - numMvGp; diff.Simplify(); GaNumMultivector.ResetAddFactorsCallCount(); textComposer .AppendLineAtNewLine("Difference, Lookup CoefSums: ") .AppendLine(callsCount) //.AppendLine(factorsCount) .AppendLine(diff); return(textComposer.ToString()); }
public GMacSymbolicTest4() { Frame = GaSymFrame.CreateEuclidean(3); }
public GMacSymbolicTest6() { Frame = GaSymFrame.CreateConformal(5); }
private void ProjectiveTables() { MdSparsityTable = new MarkdownTable(); var firstColumn = MdSparsityTable.AddColumn("op", MarkdownTableColumnAlignment.Left); firstColumn.Add("Geometric Product - Multivectors"); firstColumn.Add("Geometric Product - Terms"); firstColumn.Add("Scalar Product - Multivectors"); firstColumn.Add("Scalar Product - Terms"); firstColumn.Add("Left Contraction Product - Multivectors"); firstColumn.Add("Left Contraction Product - Terms"); MdSizeTable = new MarkdownTable(); firstColumn = MdSizeTable.AddColumn("op", MarkdownTableColumnAlignment.Left); firstColumn.Add("Geometric Product - Hash"); firstColumn.Add("Geometric Product - Tree"); firstColumn.Add("Geometric Product - Array"); firstColumn.Add("Geometric Product - Combinations"); firstColumn.Add("Scalar Product - Hash"); firstColumn.Add("Scalar Product - Tree"); firstColumn.Add("Scalar Product - Array"); firstColumn.Add("Scalar Product - Combinations"); firstColumn.Add("Left Contraction Product - Hash"); firstColumn.Add("Left Contraction Product - Tree"); firstColumn.Add("Left Contraction Product - Array"); firstColumn.Add("Left Contraction Product - Combinations"); for (var n = MinVSpaceDimension; n <= MaxVSpaceDimension; n++) { Console.Out.WriteLine("Projective Frame " + n); Frame = GaSymFrame.CreateProjective(n); var sparsityColumn = MdSparsityTable.AddColumn( "n" + n, MarkdownTableColumnAlignment.Right, n.ToString() ); var sizeColumn = MdSizeTable.AddColumn( "n" + n, MarkdownTableColumnAlignment.Right, n.ToString() ); var t = GpHashTableSize(); sparsityColumn.Add(t.Item2.ToString(LongFmt)); sparsityColumn.Add(t.Item3.ToString(LongFmt)); sizeColumn.Add(t.Item1.ToString(LongFmt)); sizeColumn.Add(GpTreeTableSize().ToString(LongFmt)); sizeColumn.Add(GpArrayTableSize().ToString(LongFmt)); sizeColumn.Add(GpCoefSumsTableSize().ToString(LongFmt)); t = SpSparseTableSize(); sparsityColumn.Add(t.Item2.ToString(LongFmt)); sparsityColumn.Add(t.Item3.ToString(LongFmt)); sizeColumn.Add(t.Item1.ToString(LongFmt)); sizeColumn.Add(SpTreeTableSize().ToString(LongFmt)); sizeColumn.Add(SpArrayTableSize().ToString(LongFmt)); sizeColumn.Add(SpCoefSumsTableSize().ToString(LongFmt)); t = LcpHashTableSize(); sparsityColumn.Add(t.Item2.ToString(LongFmt)); sparsityColumn.Add(t.Item3.ToString(LongFmt)); sizeColumn.Add(t.Item1.ToString(LongFmt)); sizeColumn.Add(LcpTreeTableSize().ToString(LongFmt)); sizeColumn.Add(LcpArrayTableSize().ToString(LongFmt)); sizeColumn.Add(LcpCoefSumsTableSize().ToString(LongFmt)); } }
public string Execute() { LogComposer.Clear(); for (var vSpaceDim = 3; vSpaceDim <= 5; vSpaceDim++) { Frame = GaSymFrame.CreateConformal(vSpaceDim); //var randGen = new GMacRandomGenerator(10); var mvList = new List <GaSymMultivector>(); mvList.Add(GaSymMultivector.CreateSymbolic(Frame.GaSpaceDimension, "A")); mvList.Add(GaSymMultivector.CreateSymbolic(Frame.GaSpaceDimension, "B")); //var treeMvList = mvList.Select(mv => mv.ToTreeMultivector()).ToList(); var i = 0; var j = 1; var computedOp = Frame.ComputedOp[mvList[i], mvList[j]]; var computedGp = Frame.ComputedGp[mvList[i], mvList[j]]; var computedSp = Frame.ComputedSp[mvList[i], mvList[j]]; var computedLcp = Frame.ComputedLcp[mvList[i], mvList[j]]; var computedRcp = Frame.ComputedRcp[mvList[i], mvList[j]]; var computedFdp = Frame.ComputedFdp[mvList[i], mvList[j]]; var computedHip = Frame.ComputedHip[mvList[i], mvList[j]]; var computedAcp = Frame.ComputedAcp[mvList[i], mvList[j]]; var computedCp = Frame.ComputedCp[mvList[i], mvList[j]]; Frame.SetProductsImplementation(GaBilinearProductImplementation.LookupHash); var hashOp = Frame.Op[mvList[i], mvList[j]]; var hashGp = Frame.Gp[mvList[i], mvList[j]]; var hashSp = Frame.Sp[mvList[i], mvList[j]]; var hashLcp = Frame.Lcp[mvList[i], mvList[j]]; var hashRcp = Frame.Rcp[mvList[i], mvList[j]]; var hashFdp = Frame.Fdp[mvList[i], mvList[j]]; var hashHip = Frame.Hip[mvList[i], mvList[j]]; var hashAcp = Frame.Acp[mvList[i], mvList[j]]; var hashCp = Frame.Cp[mvList[i], mvList[j]]; Frame.SetProductsImplementation(GaBilinearProductImplementation.LookupArray); var arrayOp = Frame.Op[mvList[i], mvList[j]]; var arrayGp = Frame.Gp[mvList[i], mvList[j]]; var arraySp = Frame.Sp[mvList[i], mvList[j]]; var arrayLcp = Frame.Lcp[mvList[i], mvList[j]]; var arrayRcp = Frame.Rcp[mvList[i], mvList[j]]; var arrayFdp = Frame.Fdp[mvList[i], mvList[j]]; var arrayHip = Frame.Hip[mvList[i], mvList[j]]; var arrayAcp = Frame.Acp[mvList[i], mvList[j]]; var arrayCp = Frame.Cp[mvList[i], mvList[j]]; Frame.SetProductsImplementation(GaBilinearProductImplementation.LookupTree); var treeOp = Frame.Op[mvList[i], mvList[j]]; var treeGp = Frame.Gp[mvList[i], mvList[j]]; var treeSp = Frame.Sp[mvList[i], mvList[j]]; var treeLcp = Frame.Lcp[mvList[i], mvList[j]]; var treeRcp = Frame.Rcp[mvList[i], mvList[j]]; var treeFdp = Frame.Fdp[mvList[i], mvList[j]]; var treeHip = Frame.Hip[mvList[i], mvList[j]]; var treeAcp = Frame.Acp[mvList[i], mvList[j]]; var treeCp = Frame.Cp[mvList[i], mvList[j]]; Frame.SetProductsImplementation(GaBilinearProductImplementation.LookupCoefSums); var combinationsOp = Frame.Op[mvList[i], mvList[j]]; var combinationsGp = Frame.Gp[mvList[i], mvList[j]]; var combinationsSp = Frame.Sp[mvList[i], mvList[j]]; var combinationsLcp = Frame.Lcp[mvList[i], mvList[j]]; var combinationsRcp = Frame.Rcp[mvList[i], mvList[j]]; var combinationsFdp = Frame.Fdp[mvList[i], mvList[j]]; var combinationsHip = Frame.Hip[mvList[i], mvList[j]]; var combinationsAcp = Frame.Acp[mvList[i], mvList[j]]; var combinationsCp = Frame.Cp[mvList[i], mvList[j]]; LogComposer .AppendLineAtNewLine("VSpaceDimension: " + vSpaceDim) .AppendLine(); VerifyProductResults("Outer Product - Hash Table", hashOp, computedOp); VerifyProductResults("Geometric Product - Hash Table", hashGp, computedGp); VerifyProductResults("Scalar Product - Hash Table", hashSp, computedSp); VerifyProductResults("Left Contraction Product - Hash Table", hashLcp, computedLcp); VerifyProductResults("Right Contraction Product - Hash Table", hashRcp, computedRcp); VerifyProductResults("Fat-Dot Product - Hash Table", hashFdp, computedFdp); VerifyProductResults("Hestenes Inner Product - Hash Table", hashHip, computedHip); VerifyProductResults("Anti-Commutator Product - Hash Table", hashAcp, computedAcp); VerifyProductResults("Commutator Product - Hash Table", hashCp, computedCp); VerifyProductResults("Outer Product - Array Table Table", arrayOp, computedOp); VerifyProductResults("Geometric Product - Array Table Table", arrayGp, computedGp); VerifyProductResults("Scalar Product - Array Table Table", arraySp, computedSp); VerifyProductResults("Left Contraction Product - Array Table Table", arrayLcp, computedLcp); VerifyProductResults("Right Contraction Product - Array Table Table", arrayRcp, computedRcp); VerifyProductResults("Fat-Dot Product - Array Table Table", arrayFdp, computedFdp); VerifyProductResults("Hestenes Inner Product - Array Table Table", arrayHip, computedHip); VerifyProductResults("Anti-Commutator Product - Array Table Table", arrayAcp, computedAcp); VerifyProductResults("Commutator Product - Array Table Table", arrayCp, computedCp); VerifyProductResults("Outer Product - Tree Table", treeOp, computedOp); VerifyProductResults("Geometric Product - Tree Table", treeGp, computedGp); VerifyProductResults("Scalar Product - Tree Table", treeSp, computedSp); VerifyProductResults("Left Contraction Product - Tree Table", treeLcp, computedLcp); VerifyProductResults("Right Contraction Product - Tree Table", treeRcp, computedRcp); VerifyProductResults("Fat-Dot Product - Tree Table", treeFdp, computedFdp); VerifyProductResults("Hestenes Inner Product - Tree Table", treeHip, computedHip); VerifyProductResults("Anti-Commutator Product - Tree Table", treeAcp, computedAcp); VerifyProductResults("Commutator Product - Tree Table", treeCp, computedCp); VerifyProductResults("Outer Product - Combinations Table", combinationsOp, computedOp); VerifyProductResults("Geometric Product - Combinations Table", combinationsGp, computedGp); VerifyProductResults("Scalar Product - Combinations Table", combinationsSp, computedSp); VerifyProductResults("Left Contraction Product - Combinations Table", combinationsLcp, computedLcp); VerifyProductResults("Right Contraction Product - Combinations Table", combinationsRcp, computedRcp); VerifyProductResults("Fat-Dot Product - Combinations Table", combinationsFdp, computedFdp); VerifyProductResults("Hestenes Inner Product - Combinations Table", combinationsHip, computedHip); VerifyProductResults("Anti-Commutator Product - Combinations Table", combinationsAcp, computedAcp); VerifyProductResults("Commutator Product - Combinations Table", combinationsCp, computedCp); LogComposer.AppendLine().AppendLine(); } return(LogComposer.ToString()); }