Esempio n. 1
0
        public ILanguageExpressionBasic Generate_BinaryProduct(GMacOpInfo opInfo, ILanguageExpression expr1, ILanguageExpression expr2)
        {
            SetOperands(expr1, expr2);

            VerifyOperation_MultivectorProduct();

            return(Generate_OrthogonalBinaryProduct(opInfo));
        }
Esempio n. 2
0
        public ILanguageExpression Generate_BinaryScalarProduct(GMacOpInfo opInfo, ILanguageExpression expr1, ILanguageExpression expr2)
        {
            SetOperands(expr1, expr2);

            VerifyOperation_ScalarProduct();

            return(Generate_OrthogonalScalarProduct(opInfo));
        }
Esempio n. 3
0
        public ILanguageExpressionBasic Generate_UnaryNorm(GMacOpInfo opInfo, ILanguageExpression expr)
        {
            SetOperands(expr);

            VerifyOperation_UnaryNorm();

            return(BasicUnary.CreatePrimitive(_resultType, opInfo.OpName, _atomicOperand1));
        }
Esempio n. 4
0
        public ILanguageExpressionBasic Generate_BinaryEuclideanScalarProduct(GMacOpInfo opInfo, ILanguageExpression expr1, ILanguageExpression expr2)
        {
            SetOperands(expr1, expr2);

            VerifyOperation_ScalarProduct();

            //The Euclidean products are metric-independent and the result is the same for orthogonal and non-orthogonal frames of the same dimension
            return
                (BasicBinary
                 .CreatePrimitive(_resultType, opInfo.OpName, _atomicOperand1, _atomicOperand2));
        }
        private ILanguageExpression translate_BuiltinMacro_norm(GMacOpInfo opInfo, ParseTreeNode node)
        {
            if (node.ChildNodes.Count != 1)
            {
                return
                    (CompilationLog.RaiseGeneratorError <ILanguageExpression>(
                         "Expecting a single expression as input to the builtin macro", node));
            }

            var expr = translate_Expression_Function_Inputs_1(node.ChildNodes[0]);

            return(BasicExpressionGenerator.Generate_UnaryNorm(opInfo, expr));
        }
Esempio n. 6
0
        public ILanguageExpressionBasic Generate_OrthogonalBinaryProduct(GMacOpInfo opInfo)
        {
            var operandsMvType = _atomicOperand1.ExpressionType as GMacFrameMultivector;

            if (!(
                    opInfo.IsMetricIndependent == false &&
                    GMacCompilerOptions.ForceOrthogonalMetricProducts &&
                    ReferenceEquals(operandsMvType, null) == false &&
                    operandsMvType.ParentFrame.IsDerivedFrame &&
                    operandsMvType.ParentFrame.AssociatedSymbolicFrame.IsNonOrthogonal
                    ))
            {
                return(BasicBinary.CreatePrimitive(_resultType, opInfo.OpName, _atomicOperand1, _atomicOperand2));
            }

            var omv1 =
                Context.ActiveParentCommandBlock.NonOrthogonalToOrthogonalMultivector(
                    operandsMvType.ParentFrame,
                    _atomicOperand1
                    );

            var omv2 =
                Context.ActiveParentCommandBlock.NonOrthogonalToOrthogonalMultivector(
                    operandsMvType.ParentFrame,
                    _atomicOperand2
                    );

            var mv =
                Context.ActiveParentCommandBlock.ExpressionToAtomicExpression(
                    BasicBinary.CreatePrimitive(
                        operandsMvType.ParentFrame.BaseFrame.MultivectorType,
                        opInfo.OpName,
                        omv1,
                        omv2
                        )
                    );

            return
                (Context.ActiveParentCommandBlock.OrthogonalToNonOrthogonalMultivectorTransform(
                     operandsMvType.ParentFrame,
                     mv
                     ));
        }
Esempio n. 7
0
        public ILanguageExpression Generate_OrthogonalScalarProduct(GMacOpInfo opInfo)
        {
            var operandsMvType = _atomicOperand1.ExpressionType as GMacFrameMultivector;

            if (!(
                    opInfo.IsMetricIndependent == false &&
                    GMacCompilerOptions.ForceOrthogonalMetricProducts &&
                    ReferenceEquals(operandsMvType, null) == false &&
                    operandsMvType.ParentFrame.IsDerivedFrame &&
                    operandsMvType.ParentFrame.AssociatedSymbolicFrame.IsNonOrthogonal
                    ))
            {
                return(BasicBinary.CreatePrimitive(_resultType, opInfo.OpName, _atomicOperand1, _atomicOperand2));
            }

            var omv1 =
                Context.ActiveParentCommandBlock.NonOrthogonalToOrthogonalMultivector(
                    operandsMvType.ParentFrame,
                    _atomicOperand1
                    );

            var omv2 =
                Context.ActiveParentCommandBlock.NonOrthogonalToOrthogonalMultivector(
                    operandsMvType.ParentFrame,
                    _atomicOperand2
                    );

            //There is no need to apply the base-to-derived outermorphsm because the scalar product always gives a scalar
            // and the outer morphism of any scalar is itself
            return
                (Context.ActiveParentCommandBlock.ExpressionToAtomicExpression(
                     BasicBinary.CreatePrimitive(
                         ScalarType,
                         opInfo.OpName,
                         omv1,
                         omv2
                         )
                     ));
        }
Esempio n. 8
0
 private void GenerateBinaryScalarMacro(AstFrame frameInfo, string macroName, GMacOpInfo opInfo)
 {
     GenerateBinaryScalarMacro(frameInfo, macroName, "mv1 " + opInfo.OpSymbol + " mv2");
 }
Esempio n. 9
0
 private void GenerateUnaryMacro(AstFrame frameInfo, string macroName, GMacOpInfo opInfo)
 {
     GenerateUnaryMacro(frameInfo, macroName, opInfo.OpName + "(mv)");
 }