Ejemplo n.º 1
0
        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"
                );
        }
Ejemplo n.º 2
0
        private void GenerateApplyLinearTransformMacro(AstFrame frameInfo)
        {
            var inputsText = ComposeMacroInputs(
                "tr", DefaultStructure.LinearTransform,
                "mv", frameInfo.FrameMultivector.Name
                );

            var commandsList =
                GMacDslSyntaxFactory.SyntaxElementsList(
                    GMacDslSyntaxFactory.AssignToLocalVariable("imageMv", "mv.#E0# * tr.ImageE0")
                    );

            for (var id = 1; id <= frameInfo.MaxBasisBladeId; id++)
            {
                commandsList.Add(
                    GMacDslSyntaxFactory.AssignToLocalVariable("imageMv", "imageMv + mv.#E" + id + "# * tr.ImageE" + id)
                    );
            }

            commandsList.AddEmptyLine();

            var commandsText = GMacLanguage.CodeGenerator.GenerateCode(commandsList);

            GenerateMacro(
                frameInfo,
                DefaultMacro.LinearTransform.Apply,
                inputsText,
                commandsText,
                "imageMv"
                );
        }
Ejemplo n.º 3
0
        private void GenerateApplyOutermorphismToVectorMacro(AstFrame frameInfo)
        {
            var inputsText = ComposeMacroInputs(
                "om", DefaultStructure.Outermorphism,
                "mv", frameInfo.FrameMultivector.Name
                );

            var commandsList = GMacDslSyntaxFactory.SyntaxElementsList(
                GMacDslSyntaxFactory.AssignToLocalVariable("imageMv", "mv.#E1# * om.ImageV1.@G1@")
                );

            for (var index = 2; index <= frameInfo.VSpaceDimension; index++)
            {
                var id = GMacMathUtils.BasisVectorId(index - 1);

                commandsList.Add(
                    GMacDslSyntaxFactory.AssignToLocalVariable(
                        "imageMv",
                        "imageMv + mv.#E" + id + "# * om.ImageV" + index + ".@G1@"
                        )
                    );
            }

            commandsList.AddEmptyLine();

            var commandsText = GMacLanguage.CodeGenerator.GenerateCode(commandsList);

            GenerateMacro(
                frameInfo,
                DefaultMacro.Outermorphism.ApplyToVector,
                inputsText,
                commandsText,
                "imageMv"
                );
        }
Ejemplo n.º 4
0
        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"
                );
        }
Ejemplo n.º 5
0
        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"
                );
        }
Ejemplo n.º 6
0
        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"
                );
        }
Ejemplo n.º 7
0
        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"
                );
        }