private void GenerateDivideByScalarOutermorphismsMacro(AstFrame frameInfo) { var commandsList = GMacDslSyntaxFactory.SyntaxElementsList( GMacDslSyntaxFactory.DeclareLocalVariable(DefaultStructure.Outermorphism, "newOm"), GMacDslSyntaxFactory.EmptyLine() ); for (var index = 1; index <= frameInfo.VSpaceDimension; index++) { commandsList.Add( GMacDslSyntaxFactory.AssignToLocalVariable( "newOm.ImageV" + index, "om.ImageV" + index + ".@G1@ / s" ) ); } commandsList.AddEmptyLine(); var commandsText = GMacLanguage.CodeGenerator.GenerateCode(commandsList); GenerateMacro( frameInfo, DefaultMacro.Outermorphism.DivideByScalar, ComposeMacroInputs( "om", DefaultStructure.Outermorphism, "s", GMacLanguage.ScalarTypeName ), DefaultStructure.Outermorphism, commandsText, "newOm" ); }
private void GenerateComposeLinearTransformsMacro(AstFrame frameInfo) { var commandsList = GMacDslSyntaxFactory.SyntaxElementsList( GMacDslSyntaxFactory.DeclareLocalVariable(DefaultStructure.LinearTransform, "newTr"), GMacDslSyntaxFactory.EmptyLine() ); for (var id = 0; id <= frameInfo.MaxBasisBladeId; id++) { commandsList.Add( GMacDslSyntaxFactory.AssignToLocalVariable( "newTr.ImageE" + id, DefaultMacro.LinearTransform.Apply + "(tr1, tr2.ImageE" + id + ")" ) ); } commandsList.AddEmptyLine(); var commandsText = GMacLanguage.CodeGenerator.GenerateCode(commandsList); GenerateMacro( frameInfo, DefaultMacro.LinearTransform.Compose, ComposeMacroInputs( "tr1", DefaultStructure.LinearTransform, "tr2", DefaultStructure.LinearTransform ), DefaultStructure.LinearTransform, commandsText, "newTr" ); }
private void GenerateComposeOutermorphismsMacro(AstFrame frameInfo) { var commandsList = GMacDslSyntaxFactory.SyntaxElementsList( GMacDslSyntaxFactory.DeclareLocalVariable(DefaultStructure.Outermorphism, "newOm"), GMacDslSyntaxFactory.EmptyLine() ); for (var index = 1; index <= frameInfo.VSpaceDimension; index++) { commandsList.Add( GMacDslSyntaxFactory.AssignToLocalVariable( "newOm.ImageV" + index, DefaultMacro.Outermorphism.ApplyToVector + "(om1, om2.ImageV" + index + ")" ) ); } commandsList.AddEmptyLine(); var commandsText = GMacLanguage.CodeGenerator.GenerateCode(commandsList); GenerateMacro( frameInfo, DefaultMacro.Outermorphism.Compose, ComposeMacroInputs( "om1", DefaultStructure.Outermorphism, "om2", DefaultStructure.Outermorphism ), DefaultStructure.Outermorphism, commandsText, "newOm" ); }
private void GenerateOutermorphismToLinearTransformMacro(AstFrame frameInfo) { var commandsList = GMacDslSyntaxFactory.SyntaxElementsList( GMacDslSyntaxFactory.DeclareLocalVariable(DefaultStructure.LinearTransform, "newTr"), GMacDslSyntaxFactory.EmptyLine(), GMacDslSyntaxFactory.FixedCode("let newTr.ImageE0 = Multivector(#E0# = '1')"), GMacDslSyntaxFactory.EmptyLine() ); for (var index = 1; index <= frameInfo.VSpaceDimension; index++) { var id = GMacMathUtils.BasisVectorId(index - 1); commandsList.Add( GMacDslSyntaxFactory.AssignToLocalVariable( "newTr.ImageE" + id, "om.ImageV" + index + ".@G1@" ) ); } commandsList.AddEmptyLine(); for (var grade = 2; grade <= frameInfo.VSpaceDimension; grade++) { var kvSpaceDim = frameInfo.KvSpaceDimension(grade); for (var index = 0; index < kvSpaceDim; index++) { int id = GMacMathUtils.BasisBladeId(grade, index); int id1, id2; id.SplitBySmallestBasisVectorId(out id1, out id2); commandsList.Add( GMacDslSyntaxFactory.AssignToLocalVariable( "newTr.ImageE" + id, " newTr.ImageE" + id1 + " op newTr.ImageE" + id2 ) ); } commandsList.AddEmptyLine(); } var commandsText = GMacLanguage.CodeGenerator.GenerateCode(commandsList); GenerateMacro( frameInfo, DefaultMacro.Outermorphism.ToLinearTransform, ComposeMacroInputs("om", DefaultStructure.Outermorphism), DefaultStructure.LinearTransform, commandsText, "newTr" ); }
private void GenerateTransposeOutermorphismMacro(AstFrame frameInfo) { var inputsText = ComposeMacroInputs( "om", DefaultStructure.Outermorphism ); var commandsList = GMacDslSyntaxFactory.SyntaxElementsList( GMacDslSyntaxFactory.DeclareLocalVariable(DefaultStructure.Outermorphism, "newOm"), GMacDslSyntaxFactory.EmptyLine() ); var componentsText = new ListComposer("," + Environment.NewLine); for (var index1 = 1; index1 <= frameInfo.VSpaceDimension; index1++) { componentsText.Clear(); var id1 = GMacMathUtils.BasisBladeId(1, index1 - 1); commandsList.AddFixedCode("let newOm.ImageV" + index1 + " = Multivector("); for (var index2 = 1; index2 <= frameInfo.VSpaceDimension; index2++) { var id2 = GMacMathUtils.BasisBladeId(1, index2 - 1); componentsText.Add(" #E" + id2 + "# = om.ImageV" + index2 + ".#E" + id1 + "#"); } commandsList.AddFixedCode(componentsText.ToString()); commandsList.AddFixedCode(")"); commandsList.AddEmptyLine(); } var commandsText = GMacLanguage.CodeGenerator.GenerateCode(commandsList); GenerateMacro( frameInfo, DefaultMacro.Outermorphism.Transpose, inputsText, DefaultStructure.Outermorphism, commandsText, "newOm" ); }
private void GenerateTransposeLinearTransformMacro(AstFrame frameInfo) { var inputsText = ComposeMacroInputs( "tr", DefaultStructure.LinearTransform ); var commandsList = GMacDslSyntaxFactory.SyntaxElementsList( GMacDslSyntaxFactory.DeclareLocalVariable(DefaultStructure.LinearTransform, "newTr"), GMacDslSyntaxFactory.EmptyLine() ); var componentsText = new ListComposer("," + Environment.NewLine); for (var id1 = 0; id1 <= frameInfo.MaxBasisBladeId; id1++) { componentsText.Clear(); commandsList.AddFixedCode("let newTr.ImageE" + id1 + " = Multivector("); for (var id2 = 0; id2 <= frameInfo.MaxBasisBladeId; id2++) { componentsText.Add(" #E" + id2 + "# = tr.ImageE" + id2 + ".#E" + id1 + "#"); } commandsList.AddFixedCode(componentsText.ToString()); commandsList.AddFixedCode(")"); commandsList.AddEmptyLine(); } var commandsText = GMacLanguage.CodeGenerator.GenerateCode(commandsList); GenerateMacro( frameInfo, DefaultMacro.LinearTransform.Transpose, inputsText, DefaultStructure.LinearTransform, commandsText, "newTr" ); }
private void GenerateEuclideanVersorToOutermorphismMacro(AstFrame frameInfo) { var commandsList = GMacDslSyntaxFactory.SyntaxElementsList( GMacDslSyntaxFactory.DeclareLocalVariable(DefaultStructure.Outermorphism, "newOm"), GMacDslSyntaxFactory.EmptyLine(), GMacDslSyntaxFactory.AssignToLocalVariable("vi", DefaultMacro.EuclideanVersor.Inverse + "(v)"), GMacDslSyntaxFactory.EmptyLine() ); for (var index = 1; index <= frameInfo.VSpaceDimension; index++) { //var id = GaUtils.BasisVector_Index_To_ID(index - 1); commandsList.AddRange( GMacDslSyntaxFactory.AssignToLocalVariable( "newOm.ImageV" + index, "v egp " + frameInfo.BasisVectorFromIndex(index - 1).AccessName + " egp vi" ), GMacDslSyntaxFactory.AssignToLocalVariable( "newOm.ImageV" + index, "newOm.ImageV" + index + ".@G1@" ), GMacDslSyntaxFactory.EmptyLine() ); } var commandsText = GMacLanguage.CodeGenerator.GenerateCode(commandsList); GenerateMacro( frameInfo, DefaultMacro.EuclideanVersor.ToOutermorphism, ComposeMacroInputs("v", frameInfo.FrameMultivector.Name), DefaultStructure.Outermorphism, commandsText, "newOm" ); }