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

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

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

        private void GenerateEuclideanDualFunction(int inGrade, AstMacro macroInfo)
        {
            var macroGenerator = LibraryComposer.CreateMacroCodeGenerator(macroInfo);

            var outGrade = CurrentFrame.VSpaceDimension - inGrade;

            macroGenerator.ActionSetMacroParametersBindings =
                macroBinding =>
            {
                macroBinding.BindMultivectorPartToVariables("result", outGrade);
                macroBinding.BindMultivectorPartToVariables("mv", inGrade);
            };

            macroGenerator.ActionSetTargetVariablesNames =
                targetNaming =>
            {
                BladesLibraryGenerator.SetBasisBladeToArrayNaming(targetNaming, "result", outGrade, "c");
                BladesLibraryGenerator.SetBasisBladeToArrayNaming(targetNaming, "mv", inGrade, "coefs");
                BladesLibraryGenerator.SetTargetTempVariablesNames(targetNaming);
            };

            //Generate code from macro binding
            var computationsText = macroGenerator.Generate();

            TextComposer.Append(
                Templates["edual"],
                "double", GMacLanguage.ScalarTypeName,
                "grade", inGrade,
                "num", CurrentFrame.KvSpaceDimension(inGrade),
                "computations", computationsText
                );
        }
        protected override void SetTargetVariablesNames(GMacTargetVariablesNaming targetNaming)
        {
            targetNaming.SetScalarParameter(targetNaming.BaseMacro.OutputParameterValueAccess, "result");

            BladesLibraryGenerator.SetBasisBladeToArrayNaming(targetNaming, "mv", _inGrade, "coefs");

            BladesLibraryGenerator.SetTargetTempVariablesNames(targetNaming);
        }
        protected override void SetTargetVariablesNames(GMacTargetVariablesNaming targetNaming)
        {
            BladesLibraryGenerator.SetBasisBladeToArrayNaming(targetNaming, "result", OutputGrade, "c");

            BladesLibraryGenerator.SetBasisBladeToArrayNaming(targetNaming, "v", InputGrade1, "coefs1");
            BladesLibraryGenerator.SetBasisBladeToArrayNaming(targetNaming, "mv", InputGrade2, "coefs2");

            BladesLibraryGenerator.SetTargetTempVariablesNames(targetNaming);
        }
        private void GenerateSelfDpGradeFunction(int inGrade, AstMacro selfEgpMacroInfo)
        {
            var macroGenerator = LibraryComposer.CreateMacroCodeGenerator(selfEgpMacroInfo);

            var outGradesList =
                CurrentFrame
                .GradesOfEGp(inGrade, inGrade)
                .Where(grade => grade > 0)
                .OrderByDescending(g => g);

            macroGenerator.ActionSetMacroParametersBindings =
                macroBinding =>
            {
                foreach (var outGrade in outGradesList)
                {
                    macroBinding.BindMultivectorPartToVariables("result", outGrade);
                }

                macroBinding.BindMultivectorPartToVariables("mv", inGrade);
            };

            macroGenerator.ActionSetTargetVariablesNames =
                targetNaming =>
            {
                foreach (var outGrade in outGradesList)
                {
                    targetNaming.SetMultivectorParameters("result", outGrade, id => "c");
                }

                BladesLibraryGenerator.SetBasisBladeToArrayNaming(targetNaming, "mv", inGrade, "coefs");

                BladesLibraryGenerator.SetTargetTempVariablesNames(targetNaming);
            };

            macroGenerator.ActionBeforeGenerateSingleComputation =
                TestSelfDpGradeFunctionComputationCondition;

            macroGenerator.ActionAfterGenerateSingleComputation =
                AddSelfDpGradeFunctionComputationCondition;

            macroGenerator.MacroBinding.FixOutputComputationsOrder = true;

            //Generate code from macro binding
            var computationsText = macroGenerator.Generate();

            TextComposer.Append(
                Templates["self_dp_grade"],
                "grade", inGrade,
                "double", GMacLanguage.ScalarTypeName,
                "computations", computationsText
                );
        }
        protected override void SetTargetVariablesNames(GMacTargetVariablesNaming targetNaming)
        {
            BladesLibraryGenerator.SetBasisBladeToArrayNaming(targetNaming, "result", _outGrade, "coefs");

            for (var gradeIdx = 0; gradeIdx < _outGrade; gradeIdx++)
            {
                var vectorName = "vectors[" + gradeIdx + "].C";

                targetNaming.SetMultivectorParameters(
                    "v" + gradeIdx + ".@G1@",
                    id => vectorName + (CurrentFrame.BasisBladeIndex(id) + 1)
                    );
            }

            BladesLibraryGenerator.SetTargetTempVariablesNames(targetNaming);
        }
Esempio n. 6
0
        protected override void SetTargetVariablesNames(GMacTargetVariablesNaming targetNaming)
        {
            var outputParam = targetNaming.BaseMacro.OutputParameterValueAccess;

            if (outputParam.GMacType.IsValidMultivectorType)
            {
                BladesLibraryGenerator.SetBasisBladeToArrayNaming(targetNaming, outputParam, _outGrade, "c");
            }
            else
            {
                targetNaming.SetScalarParameter(outputParam, "c[0]");
            }

            BladesLibraryGenerator.SetBasisBladeToArrayNaming(targetNaming, "mv", _inGrade, "coefs");

            BladesLibraryGenerator.SetTargetTempVariablesNames(targetNaming);
        }
        private string GenerateOutermorphismDeterminantCode(string opName)
        {
            var macroGenerator = CreateMacroCodeGenerator(opName);

            macroGenerator.ActionSetMacroParametersBindings =
                macroBinding =>
            {
                macroBinding.BindToVariables("result");

                for (var i = 0; i < CurrentFrame.VSpaceDimension; i++)
                {
                    var id = CurrentFrame.BasisVectorId(i);

                    for (var j = 0; j < CurrentFrame.VSpaceDimension; j++)
                    {
                        var valueAccessName = "om.ImageV" + (j + 1) + ".#E" + id + "#";

                        macroBinding.BindToVariables(valueAccessName);
                    }
                }
            };

            macroGenerator.ActionSetTargetVariablesNames =
                targetNaming =>
            {
                targetNaming.SetScalarParameter("result", "det");

                for (var i = 0; i < CurrentFrame.VSpaceDimension; i++)
                {
                    var id = CurrentFrame.BasisVectorId(i);

                    for (var j = 0; j < CurrentFrame.VSpaceDimension; j++)
                    {
                        var varName = "Coefs".CoefPart(i, j);

                        var valueAccessName = "om.ImageV" + (j + 1) + ".#E" + id + "#";

                        targetNaming.SetScalarParameter(valueAccessName, varName);
                    }
                }

                BladesLibraryGenerator.SetTargetTempVariablesNames(targetNaming);
            };

            return(macroGenerator.Generate());
        }
Esempio n. 8
0
        protected override void SetTargetVariablesNames(GMacTargetVariablesNaming targetNaming)
        {
            BladesLibraryGenerator.SetBasisBladeToArrayNaming(targetNaming, "B", InputGrade, "coefs");

            for (var idx = 1; idx <= InputGrade; idx++)
            {
                var valueAccessName = "result.f" + idx + ".@G1@";

                var outputName = "vectors[" + (idx - 1) + "].C";

                targetNaming.SetMultivectorParameters(
                    valueAccessName,
                    vectorId => outputName + (CurrentFrame.BasisBladeIndex(vectorId) + 1)
                    );
            }

            BladesLibraryGenerator.SetTargetTempVariablesNames(targetNaming);
        }
Esempio n. 9
0
        protected override void SetTargetVariablesNames(GMacTargetVariablesNaming targetNaming)
        {
            BladesLibraryGenerator.SetBasisBladeToArrayNaming(targetNaming, "result", InputGrade, "coefs");
            BladesLibraryGenerator.SetBasisBladeToArrayNaming(targetNaming, "mv", InputGrade, "bladeCoefs");

            for (var i = 0; i < CurrentFrame.VSpaceDimension; i++)
            {
                var id = CurrentFrame.BasisVectorId(i);

                for (var j = 0; j < CurrentFrame.VSpaceDimension; j++)
                {
                    var varName = "omCoefs".CoefPart(i, j);

                    var valueAccessName = "om.ImageV" + (j + 1) + ".#E" + id + "#";

                    targetNaming.SetScalarParameter(valueAccessName, varName);
                }
            }

            BladesLibraryGenerator.SetTargetTempVariablesNames(targetNaming);
        }