コード例 #1
0
 public ILanguageValue Evaluate(GMacValueMultivector value1, GMacValueMultivector value2)
 {
     return(GMacValueMultivector.Create(
                value1.ValueMultivectorType,
                value1.MultivectorCoefficients.EuclideanHip(value2.MultivectorCoefficients)
                ));
 }
コード例 #2
0
ファイル: CpEval.cs プロジェクト: cloudRoutine/GMac
 public ILanguageValue Evaluate(GMacValueMultivector value1, GMacValueMultivector value2)
 {
     return(GMacValueMultivector.Create(
                value1.ValueMultivectorType,
                value1.SymbolicFrame.Cp[value1.SymbolicMultivector, value2.SymbolicMultivector]
                ));
 }
コード例 #3
0
ファイル: OpEval.cs プロジェクト: cloudRoutine/GMac
 public ILanguageValue Evaluate(GMacValueMultivector value1, GMacValueMultivector value2)
 {
     return(GMacValueMultivector.Create(
                value1.ValueMultivectorType,
                value1.SymbolicMultivector.Op(value2.SymbolicMultivector)
                ));
 }
コード例 #4
0
ファイル: LlGenerator.cs プロジェクト: cloudRoutine/GMac
        /// <summary>
        /// Evaluate a cast to multivector value operation
        /// </summary>
        /// <param name="expr"></param>
        /// <returns></returns>
        private ILanguageValue EvaluateBasicUnaryCastToMultivector(BasicUnary expr)
        {
            var value1 = expr.Operand.AcceptVisitor(this);

            var mvType = (GMacFrameMultivector)expr.Operator;

            if (value1.ExpressionType.IsNumber())
            {
                var scalarValue = ((ValuePrimitive <MathematicaScalar>)value1).Value;

                return(GMacValueMultivector.Create(
                           mvType,
                           GaSymMultivector.CreateScalar(
                               mvType.ParentFrame.GaSpaceDimension,
                               scalarValue
                               )
                           ));
            }

            if (value1.ExpressionType.IsFrameMultivector() &&
                value1.ExpressionType.GetFrame().VSpaceDimension == mvType.ParentFrame.VSpaceDimension)
            {
                var mvValue = (GMacValueMultivector)value1;

                return(GMacValueMultivector.Create(
                           mvType,
                           GaSymMultivector.CreateCopy(mvValue.SymbolicMultivector)
                           ));
            }

            throw new InvalidOperationException("Invalid cast operation");
        }
コード例 #5
0
 public ILanguageValue Evaluate(GMacValueMultivector value1, ValuePrimitive <MathematicaScalar> value2)
 {
     return(GMacValueMultivector.Create(
                value1.ValueMultivectorType,
                value1.MultivectorCoefficients * value2.Value
                ));
 }
コード例 #6
0
ファイル: CliffordConjugateEval.cs プロジェクト: phreed/GMac
 public ILanguageValue Evaluate(GMacValueMultivector value1)
 {
     return(GMacValueMultivector.Create(
                value1.ValueMultivectorType,
                value1.MultivectorCoefficients.CliffConj()
                ));
 }
コード例 #7
0
 public ILanguageValue Evaluate(ValuePrimitive <MathematicaScalar> value1, GMacValueMultivector value2)
 {
     return(GMacValueMultivector.Create(
                value2.ValueMultivectorType,
                value2.SymbolicMultivector * value1.Value
                ));
 }
コード例 #8
0
        /// <summary>
        /// Convert this binding pattern into a multivector value
        /// </summary>
        /// <param name="basisBladeToVarName"></param>
        /// <returns></returns>
        public AstValueMultivector ToValue(Func <AstFrameBasisBlade, string> basisBladeToVarName)
        {
            var frameInfo = new AstFrame(BaseFrameMultivector.AssociatedFrameMultivector.ParentFrame);

            var mv = GaSymMultivector.CreateZero(
                BaseFrameMultivector.AssociatedFrameMultivector.ParentFrame.GaSpaceDimension
                );

            foreach (var pair in _patternDictionary)
            {
                mv.AddFactor(
                    pair.Key,
                    pair.Value.IsConstant
                        ? pair.Value.ConstantSymbolicScalar
                        : MathematicaScalar.Create(SymbolicUtils.Cas, basisBladeToVarName(frameInfo.BasisBlade(pair.Key)))
                    );
            }

            return
                (new AstValueMultivector(
                     GMacValueMultivector.Create(
                         BaseFrameMultivector.AssociatedFrameMultivector,
                         mv
                         )
                     ));
        }
コード例 #9
0
 public ILanguageValue Evaluate(GMacValueMultivector value1)
 {
     return(GMacValueMultivector.Create(
                value1.ValueMultivectorType,
                value1.SymbolicMultivector.GradeInv()
                ));
 }
コード例 #10
0
 public ILanguageValue Evaluate(GMacValueMultivector value1, GMacValueMultivector value2)
 {
     return(GMacValueMultivector.Create(
                value1.ValueMultivectorType,
                value1.MultivectorCoefficients.OuterProduct(value2.MultivectorCoefficients)
                ));
 }
コード例 #11
0
ファイル: FdpEval.cs プロジェクト: phreed/GMac
 public ILanguageValue Evaluate(GMacValueMultivector value1, GMacValueMultivector value2)
 {
     return(GMacValueMultivector.Create(
                value1.ValueMultivectorType,
                value1.SymbolicFrame.Fdp(
                    value1.MultivectorCoefficients, value2.MultivectorCoefficients
                    )
                ));
 }
コード例 #12
0
ファイル: LlGenerator.cs プロジェクト: cloudRoutine/GMac
        /// <summary>
        /// Evaluate a multivector transform operation
        /// </summary>
        /// <param name="expr"></param>
        /// <returns></returns>
        private GMacValueMultivector EvaluateBasicUnaryMultivectorTransform(BasicUnary expr)
        {
            var value1 = (GMacValueMultivector)expr.Operand.AcceptVisitor(this);

            var transform = (GMacMultivectorTransform)expr.Operator;

            return(GMacValueMultivector.Create(
                       transform.TargetFrame.MultivectorType,
                       transform.AssociatedSymbolicTransform[value1.SymbolicMultivector]
                       ));
        }
コード例 #13
0
 /// <summary>
 /// Convert this basis blade into a multivector value with unity coefficient of its single term
 /// </summary>
 /// <returns></returns>
 public AstValueMultivector ToMultivectorValue()
 {
     return(new AstValueMultivector(
                GMacValueMultivector.Create(
                    AssociatedFrame.MultivectorType,
                    GaSymMultivector.CreateBasisBlade(
                        AssociatedFrame.GaSpaceDimension,
                        BasisBladeId
                        )
                    )
                ));
 }
コード例 #14
0
ファイル: GMacMultivectorBinding.cs プロジェクト: phreed/GMac
        /// <summary>
        /// Convert this binding pattern into a multivector value
        /// </summary>
        /// <param name="varNameTemplate"></param>
        /// <returns></returns>
        public AstValueMultivector ToValue(StringSequenceTemplate varNameTemplate)
        {
            var mv = GaMultivector.CreateZero(BaseFrameMultivector.AssociatedFrameMultivector.ParentFrame.GaSpaceDimension);

            foreach (var pair in _patternDictionary)
            {
                mv[pair.Key] = pair.Value.ToMathematicaScalar(varNameTemplate);
            }

            return(new AstValueMultivector(
                       GMacValueMultivector.Create(
                           BaseFrameMultivector.AssociatedFrameMultivector,
                           mv
                           )
                       ));
        }