Example #1
0
        protected override void Translate()
        {
            var expressionText = GenUtils.Translate_StringLiteral(RootParseNode);

            if (
                expressionText.First() == '$' &&
                expressionText.Last() == '$' &&
                expressionText.Count(c => c == '$') == 2
                )
            {
                //If the expression is on the form '$ anything $' convert it into a normal multivector expression
                //based on (anything) alone; not a symbolic expression
                expressionText = expressionText.Substring(1, expressionText.Length - 2).Trim();

                _generatedExpression = translate_LanguageExpression(expressionText);

                return;
            }

            MathematicaScalar scalar;

            OperandsByName operands;

            translate_Dependency_List(expressionText, out scalar, out operands);

            _generatedExpression = BasicExpressionGenerator.Generate_SymbolicExpression(scalar, operands);
        }
Example #2
0
        ///Set the signature of the current frame to a signature vector (diagonal IPM)
        private GaFrame translate_Frame_Signature_Orthogonal(ParseTreeNode node)
        {
            var bvSigVector = MathematicaVector.Create(Cas, GenUtils.Translate_StringLiteral(node.ChildNodes[0]));

            if (bvSigVector.Size != _vSpaceDim)
            {
                CompilationLog.RaiseGeneratorError <int>("Expecting a vector with " + _vSpaceDim + " items", node.ChildNodes[0]);
            }

            return(GaFrame.CreateOrthogonal(bvSigVector));
        }
Example #3
0
        ///Set the signature of the current frame to a signature vector of +1's and -1's (diagonal IPM)
        private GaFrame translate_Frame_Signature_Orthonormal(ParseTreeNode node)
        {
            var bvSigString = GenUtils.Translate_StringLiteral(node.ChildNodes[0]).Trim();

            if (bvSigString.Count(c => c == '+' || c == '-') != _vSpaceDim || bvSigString.Length != _vSpaceDim)
            {
                CompilationLog.RaiseGeneratorError <int>("Expecting a vector of " + _vSpaceDim + @" (+\-) items", node.ChildNodes[0]);
            }

            return(GaFrame.CreateOrthonormal(bvSigString));
        }
Example #4
0
        ///Set the signature of the current frame to be defined by IPM
        private GaFrame translate_Frame_Signature_IPM(ParseTreeNode node)
        {
            //Read the IPM symbolic matrix
            var ipmMatrix = MathematicaMatrix.Create(Cas, GenUtils.Translate_StringLiteral(node.ChildNodes[0]));

            if (ipmMatrix.IsSymmetric() == false || ipmMatrix.Rows != _vSpaceDim)
            {
                CompilationLog.RaiseGeneratorError <int>("Expecting a square symmetric matrix with " + _vSpaceDim + " rows", node.ChildNodes[0]);
            }

            return(GaFrame.CreateFromIpm(ipmMatrix));
        }
Example #5
0
        ///Set the signature of the current frame to a base frame with a change of basis matrix
        private GaFrame translate_Frame_Signature_CBM(ParseTreeNode node)
        {
            var baseFrame =
                (GMacFrame)GMacValueAccessGenerator.Translate_Direct(Context, node.ChildNodes[0], RoleNames.Frame);

            if (baseFrame.VSpaceDimension != _vSpaceDim)
            {
                CompilationLog.RaiseGeneratorError <int>("Base frame must be of dimension " + _vSpaceDim, node.ChildNodes[0]);
            }

            var cbmMatrix = MathematicaMatrix.Create(Cas, GenUtils.Translate_StringLiteral(node.ChildNodes[1]));

            if (cbmMatrix.IsInvertable() == false || cbmMatrix.Rows != _vSpaceDim)
            {
                CompilationLog.RaiseGeneratorError <int>("Expecting a square invertable matrix with " + _vSpaceDim + " rows", node.ChildNodes[1]);
            }

            _baseFrame = baseFrame;

            var derivedFrameSystem = GaFrame.CreateDerivedCbmFrameSystem(baseFrame.AssociatedSymbolicFrame, cbmMatrix);

            return(derivedFrameSystem.DerivedFrame);
        }