Exemplo n.º 1
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"
                );
        }