Exemple #1
0
        private string GenerateDeclarations(int grade)
        {
            var kvDim = CurrentFrame.KvSpaceDimension(grade);

            var template = Templates["static_basisblade_declare"];

            var declaresText = new ListComposer(Environment.NewLine);

            var coefsText = new ListComposer(", ");

            for (var index = 0; index < kvDim; index++)
            {
                coefsText.Clear();

                for (var i = 0; i < kvDim; i++)
                {
                    coefsText.Add((i == index) ? "1.0D" : "0.0D");
                }

                declaresText.Add(
                    template,
                    "frame", CurrentFrameName,
                    "id", CurrentFrame.BasisBladeId(grade, index),
                    "grade", grade,
                    "coefs", coefsText
                    );
            }

            declaresText.Add("");

            return(declaresText.ToString());
        }
Exemple #2
0
        private void GenerateMainInvolutionFunction(string macroName, Func <int, bool> useNegative)
        {
            var caseTemplate1 = Templates["main_negative_case"];
            var caseTemplate2 = Templates["main_negative_case2"];

            var casesText = new ListComposer(Environment.NewLine);

            foreach (var grade in CurrentFrame.Grades())
            {
                if (useNegative(grade))
                {
                    casesText.Add(caseTemplate1,
                                  "frame", CurrentFrameName,
                                  "grade", grade,
                                  "num", CurrentFrame.KvSpaceDimension(grade)
                                  );
                }
                else
                {
                    casesText.Add(caseTemplate2,
                                  "grade", grade
                                  );
                }
            }

            TextComposer.AppendAtNewLine(
                Templates["main_involution"],
                "frame", CurrentFrameName,
                "name", macroName,
                "cases", casesText
                );
        }
Exemple #3
0
        private string GenerateSubtractMethodCode(MvClassData resultClassData)
        {
            //The two classes are zero multivector classes
            if (resultClassData.ClassId == 0)
            {
                return("return Zero;");
            }

            var idCommon = ClassData.ClassId & CalcClassData.ClassId;

            var idDiff1 = ClassData.ClassId & ~CalcClassData.ClassId;

            var idDiff2 = ~ClassData.ClassId & CalcClassData.ClassId;

            var composer = new ListComposer("," + Environment.NewLine)
            {
                FinalPrefix      = "return new " + resultClassData.ClassName + "()" + Environment.NewLine + "{" + Environment.NewLine,
                FinalSuffix      = Environment.NewLine + "};",
                ActiveItemPrefix = "    "
            };

            var basisBlades = ClassData.Frame.BasisBladesOfGrades(idDiff1.PatternToPositions());

            foreach (var basisBlade in basisBlades)
            {
                composer.Add(
                    $"{basisBlade.GradeIndexName} = {basisBlade.GradeIndexName}"
                    );
            }

            basisBlades = ClassData.Frame.BasisBladesOfGrades(idDiff2.PatternToPositions());

            foreach (var basisBlade in basisBlades)
            {
                composer.Add(
                    $"{basisBlade.GradeIndexName} = {"-mv." + basisBlade.GradeIndexName}"
                    );
            }

            basisBlades = ClassData.Frame.BasisBladesOfGrades(idCommon.PatternToPositions());

            foreach (var basisBlade in basisBlades)
            {
                var term = basisBlade.GradeIndexName + " - mv." + basisBlade.GradeIndexName;

                composer.Add(
                    $"{basisBlade.GradeIndexName} = {term}"
                    );
            }

            return(composer.ToString());
        }
Exemple #4
0
        private string GenerateIsEqualMethodCode()
        {
            //The two classes are zero multivector classes
            if (ClassData.ClassId == 0 && CalcClassData.ClassId == 0)
            {
                return("return true;");
            }

            var idCommon = ClassData.ClassId & CalcClassData.ClassId;

            var idDiff1 = ClassData.ClassId & ~CalcClassData.ClassId;

            var idDiff2 = ~ClassData.ClassId & CalcClassData.ClassId;

            var composer = new ListComposer(" || " + Environment.NewLine)
            {
                FinalPrefix      = "return !(" + Environment.NewLine,
                FinalSuffix      = Environment.NewLine + ");",
                ActiveItemPrefix = "    "
            };

            var basisBlades = ClassData.Frame.BasisBladesOfGrades(idDiff1.PatternToPositions());

            foreach (var basisBlade in basisBlades)
            {
                composer.Add(
                    String.Format("{0} <= -Epsilon || {0} >= Epsilon", basisBlade.GradeIndexName)
                    );
            }

            basisBlades = ClassData.Frame.BasisBladesOfGrades(idDiff2.PatternToPositions());

            foreach (var basisBlade in basisBlades)
            {
                composer.Add(
                    String.Format("{0} <= -Epsilon || {0} >= Epsilon", "mv." + basisBlade.GradeIndexName)
                    );
            }

            basisBlades = ClassData.Frame.BasisBladesOfGrades(idCommon.PatternToPositions());

            foreach (var basisBlade in basisBlades)
            {
                var term = "(" + basisBlade.GradeIndexName + " - mv." + basisBlade.GradeIndexName + ")";

                composer.Add(
                    String.Format("{0} <= -Epsilon || {0} >= Epsilon", term)
                    );
            }

            return(composer.ToString());
        }
Exemple #5
0
        private string GenerateDeclareCoefsText()
        {
            var s = new ListComposer(Environment.NewLine);

            DeclareCoefsTemplate["double"] = GMacLanguage.ScalarTypeName;

            foreach (var basisBlade in ClassData.ClassBasisBlades)
            {
                s.Add(DeclareCoefsTemplate, "coef", basisBlade.GradeIndexName);
            }

            return(s.Add().ToString());
        }
Exemple #6
0
        public override void Generate()
        {
            GenerateBladeFileStartCode();

            var kvdimsText      = new ListComposer(", ");
            var basisnamesText  = new ListComposer("," + Environment.NewLine);
            var basisbladesText = new ListComposer(Environment.NewLine);

            foreach (var grade in CurrentFrame.Grades())
            {
                kvdimsText.Add(CurrentFrame.KvSpaceDimension(grade));

                basisnamesText.Add(GenerateBasisBladesNames(grade));

                basisbladesText.Add(GenerateDeclarations(grade));
            }

            TextComposer.Append(
                Templates["static"],
                "frame", CurrentFrameName,
                "grade", CurrentFrame.VSpaceDimension,
                "double", GMacLanguage.ScalarTypeName,
                "kvdims", kvdimsText,
                "basisnames", basisnamesText,
                "basisblades", basisbladesText
                );

            GenerateBladeFileFinishCode();

            FileComposer.FinalizeText();
        }
        private void GenerateMethods(int inGrade1, int inGrade2)
        {
            var gpCaseText = new ListComposer(Environment.NewLine);
            var gradesList = CurrentFrame.GradesOfEGp(inGrade1, inGrade2).OrderByDescending(grade => grade);

            foreach (var outGrade in gradesList)
            {
                var funcName = BladesLibraryGenerator.GetBinaryFunctionName(DefaultMacro.EuclideanBinary.GeometricProduct, inGrade1, inGrade2, outGrade);

                gpCaseText.Add(Templates["dp_case"],
                               "name", funcName,
                               "num", CurrentFrame.KvSpaceDimension(outGrade),
                               "frame", CurrentFrameName,
                               "grade", outGrade
                               );
            }

            TextComposer.AppendAtNewLine(
                Templates["dp"],
                "frame", CurrentFrameName,
                "name", BladesLibraryGenerator.GetBinaryFunctionName(OperatorName, inGrade1, inGrade2),
                "double", GMacLanguage.ScalarTypeName,
                "dp_case", gpCaseText
                );
        }
Exemple #8
0
        private void GenerateMethods(int inputGrade)
        {
            var gpCaseText = new ListComposer("," + Environment.NewLine);

            var gradesList = CurrentFrame.GradesOfEGp(inputGrade, inputGrade);

            foreach (var outputGrade in gradesList)
            {
                var funcName =
                    BladesLibraryGenerator
                    .GetBinaryFunctionName(OperatorName, inputGrade, inputGrade, outputGrade);

                GenerateMethod(
                    funcName,
                    inputGrade,
                    outputGrade
                    );

                gpCaseText.Add(Templates["selfgp_case"],
                               "frame", CurrentFrameName,
                               "grade", outputGrade,
                               "name", funcName
                               );
            }

            TextComposer.AppendAtNewLine(
                Templates["selfgp"],
                "frame", CurrentFrameName,
                "name", BladesLibraryGenerator.GetBinaryFunctionName(OperatorName, inputGrade, inputGrade),
                "double", GMacLanguage.ScalarTypeName,
                "selfgp_case", gpCaseText
                );
        }
        public override void Generate()
        {
            GenerateBladeFileStartCode();

            var casesText = new ListComposer(Environment.NewLine);

            for (var grade = 2; grade <= CurrentFrame.VSpaceDimension; grade++)
            {
                _outGrade = grade;

                GenerateVectorsOpFunction();

                casesText.Add(
                    Templates["op_vectors_main_case"].GenerateUsing(grade)
                    );
            }

            TextComposer.Append(
                Templates["op_vectors_main"],
                "frame", CurrentFrameName,
                "op_vectors_main_case", casesText
                );

            GenerateBladeFileFinishCode();

            FileComposer.FinalizeText();
        }
Exemple #10
0
        private void GenerateMainIsZeroFunction()
        {
            var t1 = Templates["main_iszero"];
            var t2 = Templates["main_iszero_case"];
            var t3 = Templates["main_trimcoefs_case"];

            var iszeroCasesText    = new ListComposer(Environment.NewLine);
            var trimcoefsCasesText = new ListComposer(Environment.NewLine);

            foreach (var grade in CurrentFrame.Grades())
            {
                iszeroCasesText.Add(t2,
                                    "grade", grade,
                                    "num", CurrentFrame.KvSpaceDimension(grade)
                                    );

                trimcoefsCasesText.Add(t3,
                                       "frame", CurrentFrameName,
                                       "grade", grade,
                                       "num", CurrentFrame.KvSpaceDimension(grade)
                                       );
            }

            TextComposer.AppendAtNewLine(t1,
                                         "frame", CurrentFrameName,
                                         "main_iszero_case", iszeroCasesText,
                                         "main_trimcoefs_case", trimcoefsCasesText
                                         );
        }
        private void GenerateMiscFunctions(int kvSpaceDim)
        {
            //This code can be replaced using ListTextBuilderCollection and ParametricTextBuilderCollection
            //objects. See GenerateMainMiscFunctions() in this file for an example
            var addCasesTemplate   = Templates["add_case"];
            var subtCasesTemplate  = Templates["subt_case"];
            var timesCasesTemplate = Templates["times_case"];

            var addCasesText   = new ListComposer("," + Environment.NewLine);
            var subtCasesText  = new ListComposer("," + Environment.NewLine);
            var timesCasesText = new ListComposer("," + Environment.NewLine);

            for (var index = 0; index < kvSpaceDim; index++)
            {
                addCasesText.Add(addCasesTemplate, "index", index);
                subtCasesText.Add(subtCasesTemplate, "index", index);
                timesCasesText.Add(timesCasesTemplate, "index", index);
            }


            var miscFuncsTemplate = Templates["misc"];

            TextComposer.Append(miscFuncsTemplate,
                                "double", GMacLanguage.ScalarTypeName,
                                "num", kvSpaceDim,
                                "addcases", addCasesText,
                                "subtcases", subtCasesText,
                                "timescases", timesCasesText
                                );
        }
        private void GenerateMaxCoefIdFunction(int grade)
        {
            var casesText = new ListComposer(Environment.NewLine);

            var maxIndex = CurrentFrame.KvSpaceDimension(grade) - 1;

            for (var index = 1; index < maxIndex; index++)
            {
                casesText.Add(
                    Templates["maxcoefid_case"],
                    "index", index,
                    "id", CurrentFrame.BasisBladeId(grade, index)
                    );
            }

            TextComposer.Append(
                Templates["maxcoefid"],
                "grade", grade,
                "double", GMacLanguage.ScalarTypeName,
                "initid", CurrentFrame.BasisBladeId(grade, 0),
                "maxindex", maxIndex,
                "maxid", CurrentFrame.BasisBladeId(grade, maxIndex),
                "maxcoefid_case", casesText
                );
        }
        public string GetCasesText()
        {
            var t2 = Templates["bilinearproduct_main_case"];

            var casesText = new ListComposer(Environment.NewLine);

            foreach (var grade1 in CurrentFrame.Grades())
            {
                foreach (var grade2 in CurrentFrame.Grades())
                {
                    if (IsLegalGrade(grade1, grade2) == false)
                    {
                        continue;
                    }

                    var grade = GetFinalGrade(grade1, grade2);

                    var id = grade1 + grade2 * CurrentFrame.GradesCount;

                    var name = BladesLibraryGenerator.GetBinaryFunctionName(OperatorName, grade1, grade2, grade);

                    casesText.Add(t2,
                                  "name", name,
                                  "id", id,
                                  "g1", grade1,
                                  "g2", grade2,
                                  "grade", grade,
                                  "frame", CurrentFrameName
                                  );
                }
            }

            return(casesText.ToString());
        }
        private string GenerateOutermorphismComposeCode()
        {
            var codeText = new ListComposer(Environment.NewLine);

            var sumText = new ListComposer(" + ");

            for (var i = 0; i < CurrentFrame.VSpaceDimension; i++)
            {
                for (var j = 0; j < CurrentFrame.VSpaceDimension; j++)
                {
                    sumText.Clear();

                    for (var k = 0; k < CurrentFrame.VSpaceDimension; k++)
                    {
                        sumText.Add(
                            "om1.Coefs".CoefPart(i, k) + " * " + "om2.Coefs".CoefPart(k, j)
                            );
                    }

                    codeText.Add(
                        "coefs".CoefPart(i, j) + " = " + sumText + ";"
                        );
                }
            }

            return(codeText.ToString());
        }
        private void GenerateMainMethod()
        {
            var casesText = new ListComposer(Environment.NewLine);

            foreach (var inGrade1 in CurrentFrame.Grades())
            {
                foreach (var inGrade2 in CurrentFrame.Grades())
                {
                    var id = inGrade1 + inGrade2 * CurrentFrame.GradesCount;

                    casesText.Add(Templates["dp_main_case"],
                                  "name", BladesLibraryGenerator.GetBinaryFunctionName(OperatorName, inGrade1, inGrade2),
                                  "id", id,
                                  "g1", inGrade1,
                                  "g2", inGrade2,
                                  "frame", CurrentFrameName
                                  );
                }
            }

            TextComposer.AppendAtNewLine(
                Templates["dp_main"],
                "name", OperatorName,
                "frame", CurrentFrameName,
                "cases", casesText
                );
        }
        private List <AstMacro> AddFactorGMacMacros()
        {
            var gmacMacroInfoList = new List <AstMacro>(CurrentFrame.VSpaceDimension - 1);

            for (var grade = 2; grade <= CurrentFrame.VSpaceDimension; grade++)
            {
                var stepsText = new ListComposer(Environment.NewLine);

                for (var num = 1; num < grade; num++)
                {
                    stepsText.Add(Templates["factor_macro_step"], "num", num);
                }

                var codeText =
                    Templates["factor_macro"]
                    .GenerateText("frame", CurrentFrameName, "num", grade, "steps", stepsText);

                TempSymbolsCompiler.RefResContext.Clear(CurrentFrame);

                var gmacMacro = TempSymbolsCompiler.CompileMacro(codeText);

                gmacMacroInfoList.Add(gmacMacro);
            }

            return(gmacMacroInfoList);
        }
        //private GMacInfoMacro AddEuclideanGeometricProductDualGMacMacro()
        //{
        //    var codeText =
        //        Templates["egp_dual_macro"].GenerateUsing(CurrentFrameName);

        //    var gmacMacro =
        //        _tempSymbolsCompiler.CompileMacro(
        //            codeText,
        //            _currentFrame.AssociatedFrame.ChildScope
        //            );

        //    return new GMacInfoMacro(gmacMacro);
        //}

        //private GMacInfoMacro AddSelfEuclideanGeometricProductGMacMacro()
        //{
        //    var codeText =
        //        Templates["self_egp_macro"].GenerateUsing(CurrentFrameName);

        //    var gmacMacro =
        //        _tempSymbolsCompiler.CompileMacro(
        //            codeText,
        //            _currentFrame.AssociatedFrame.ChildScope
        //            );

        //    return new GMacInfoMacro(gmacMacro);
        //}

        internal AstMacro AddVectorsOuterProductGMacMacro()
        {
            var vopInputsText = new ListComposer(", ")
            {
                ActiveItemPrefix = "v", ActiveItemSuffix = " : Multivector"
            };
            var vopExprText = new ListComposer(" ^ ")
            {
                ActiveItemPrefix = "v"
            };

            for (var num = 0; num < CurrentFrame.VSpaceDimension; num++)
            {
                vopInputsText.Add(num);
                vopExprText.Add(num);
            }

            var codeText =
                Templates["vectors_op_macro"]
                .GenerateText(
                    "frame", CurrentFrameName,
                    "vop_inputs", vopInputsText,
                    "vop_expr", vopExprText
                    );

            TempSymbolsCompiler.RefResContext.Clear(CurrentFrame);

            var gmacMacro = TempSymbolsCompiler.CompileMacro(codeText);

            return(gmacMacro);
        }
        private void GenerateMethods(int inGrade1, int inGrade2)
        {
            var gpCaseText = new ListComposer("," + Environment.NewLine);

            var gradesList =
                DualFlag
                ? Frame.GradesOfEGp(inGrade1, inGrade2)
                .Select(grade => Frame.VSpaceDimension - grade)

                : Frame.GradesOfEGp(inGrade1, inGrade2);

            foreach (var outGrade in gradesList)
            {
                var funcName = BladesLibraryGenerator.GetBinaryFunctionName(OperatorName, inGrade1, inGrade2, outGrade);

                BladesLibraryGenerator.GenerateBilinearProductMethodFile(
                    OperatorName,
                    funcName,
                    inGrade1,
                    inGrade2,
                    outGrade
                    );

                gpCaseText.Add(Templates["gp_case"],
                               "frame", FrameTargetName,
                               "grade", outGrade,
                               "name", funcName
                               );
            }

            var name = BladesLibraryGenerator.GetBinaryFunctionName(OperatorName, inGrade1, inGrade2);

            _mainFileGenerator.GenerateIntermediateMethod(gpCaseText.ToString(), name);
        }
Exemple #19
0
        public override void Generate()
        {
            GenerateBladeFileStartCode();

            var computationsText = GenerateComputationsCode();

            var newVectorsText = new ListComposer("," + Environment.NewLine);

            for (var i = 0; i < InputGrade; i++)
            {
                newVectorsText.Add("new " + CurrentFrameName + "Vector()");
            }

            TextComposer.AppendAtNewLine(
                Templates["factor"],
                "frame", CurrentFrameName,
                "id", InputId,
                "double", GMacLanguage.ScalarTypeName,
                "newvectors", newVectorsText,
                "computations", computationsText
                );

            GenerateBladeFileFinishCode();

            FileComposer.FinalizeText();
        }
Exemple #20
0
        private string GenerateAbstractCoefsText()
        {
            var s = new ListComposer(Environment.NewLine);

            AbstractCoefsTemplate["double"] = GMacLanguage.ScalarTypeName;

            foreach (var basisBlade in ClassData.Frame.BasisBlades())
            {
                var id = basisBlade.BasisBladeId;

                var value = ClassData.ClassBinding.ContainsVariable(id) ? basisBlade.GradeIndexName : "0.0D";

                s.Add(AbstractCoefsTemplate, "coef", ("Coef" + id), "value", value);
            }

            return(s.Add().ToString());
        }
Exemple #21
0
        /// <summary>
        /// Return a simple string to describe the given value
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public string AsString(AstValueMultivector value)
        {
            if (value.IsNullOrInvalid())
            {
                return("<Invalid Value>");
            }

            if (value.IsZero)
            {
                return("0");
            }

            var composer = new ListComposer(" + ");

            var terms = value.Terms.OrderBy(t => t.TermBasisBladeGrade).ThenBy(t => t.TermBasisBladeIndex);

            foreach (var term in terms)
            {
                if (term.TermBasisBladeId == 0)
                {
                    composer.Add(term.CoefValue);
                }

                else if (term.CoefValue.IsOne)
                {
                    composer.Add(term.BasisBlade.Name);
                }

                else if (term.CoefValue.IsMinusOne)
                {
                    composer.Add("-" + term.BasisBlade.Name);
                }

                else
                {
                    composer.Add(term.CoefValue + " " + term.BasisBlade.Name);
                }
            }

            return(composer.ToString());
        }
Exemple #22
0
        public override string ToString()
        {
            var composer = new ListComposer(" + ");

            foreach (var pair in _internalDictionary.OrderBy(p => p.Key))
            {
                composer.Add(
                    pair.Value + " " + pair.Key.BasisBladeName()
                    );
            }

            return(composer.ToString());
        }
Exemple #23
0
        private void GenerateStructures(AstFrame frameInfo)
        {
            var membersText = new ListComposer("," + Environment.NewLine);

            for (var id = 0; id <= frameInfo.MaxBasisBladeId; id++)
            {
                membersText.Add(
                    Templates["structure_member"],
                    "name", "ImageE" + id,
                    "type", frameInfo.FrameMultivector.Name
                    );
            }

            ActiveFileTextComposer.Append(
                Templates["structure"],
                "frame", frameInfo.Name,
                "name", DefaultStructure.LinearTransform,
                "members", membersText
                );

            membersText.Clear();

            for (var index = 1; index <= frameInfo.VSpaceDimension; index++)
            {
                membersText.Add(
                    Templates["structure_member"],
                    "name", "ImageV" + index,
                    "type", frameInfo.FrameMultivector.Name
                    );
            }

            ActiveFileTextComposer.Append(
                Templates["structure"],
                "frame", frameInfo.Name,
                "name", DefaultStructure.Outermorphism,
                "members", membersText
                );
        }
Exemple #24
0
        public static GaSymFrameNonOrthogonal CreateConformal(int vSpaceDim)
        {
            VerifyVSpaceDim(vSpaceDim, 3);

            var eSpaceDim    = vSpaceDim - 2;
            var listComposer = new ListComposer(",")
            {
                FinalPrefix = "{",
                FinalSuffix = "}"
            };

            for (var i = 0; i < eSpaceDim; i++)
            {
                listComposer.Add(
                    (1 << i)
                    .PatternToSequence(vSpaceDim, "0", "1")
                    .Concatenate(",", "{", "}")
                    );
            }

            listComposer.Add(
                "{" +
                0.PatternToSequence(eSpaceDim, "0", "1").Concatenate(",") +
                ",0,-1}"
                );

            listComposer.Add(
                "{" +
                0.PatternToSequence(eSpaceDim, "0", "1").Concatenate(",") +
                ",-1,0}"
                );

            var ipm = MathematicaMatrix.Create(SymbolicUtils.Cas, listComposer.ToString());

            return(CreateNonOrthogonalFromIpm(ipm));
        }
        private string GenerateOutermorphismApplyCasesCode()
        {
            var codeText = new ListComposer(Environment.NewLine);

            for (var inGrade = 1; inGrade <= CurrentFrame.VSpaceDimension; inGrade++)
            {
                codeText.Add(
                    Templates["om_apply_code_case"],
                    "grade", inGrade,
                    "frame", CurrentFrameName
                    );
            }

            return(codeText.ToString());
        }
Exemple #26
0
        private static string ComposeMacroInputs(params string[] inputsInfo)
        {
            if (inputsInfo.Length == 0)
            {
                return("");
            }

            var inputsText = new ListComposer(", ");

            for (var i = 0; i < inputsInfo.Length; i += 2)
            {
                inputsText.Add(inputsInfo[i].Trim() + " : " + inputsInfo[i + 1].Trim());
            }

            return(inputsText.ToString());
        }
Exemple #27
0
        private string GenerateBasisBladesNames(int grade)
        {
            var namesText = new ListComposer(", ")
            {
                ActiveItemSuffix = "\"", ActiveItemPrefix = "\""
            };

            for (var index = 0; index < CurrentFrame.KvSpaceDimension(grade); index++)
            {
                namesText.Add(
                    CurrentFrame.BasisBlade(grade, index).IndexedName
                    );
            }

            return(Templates["static_basisblade_name"].GenerateText("names", namesText));
        }
        private string GenerateOutermorphismTranposeCode()
        {
            var codeText = new ListComposer(Environment.NewLine);

            for (var i = 0; i < CurrentFrame.VSpaceDimension; i++)
            {
                for (var j = 0; j < CurrentFrame.VSpaceDimension; j++)
                {
                    codeText.Add(
                        "coefs".CoefPart(i, j) + " = " + "Coefs".CoefPart(j, i) + ";"
                        );
                }
            }

            return(codeText.ToString());
        }
Exemple #29
0
        private string GenerateAbstractMethodCases(string opName)
        {
            var composer = new ListComposer(Environment.NewLine);

            AbstractMethodCaseTemplate["op_name"] = opName;

            foreach (var classData in MvLibraryGenerator.MultivectorClassesData.Values)
            {
                composer.Add(
                    AbstractMethodCaseTemplate,
                    "id", classData.ClassId,
                    "class_name", classData.ClassName
                    );
            }

            return(composer.ToString());
        }
Exemple #30
0
        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"
                );
        }