Esempio n. 1
0
        /// <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,
                           GaMultivector.CreateScalar(
                               mvType.ParentFrame.GaSpaceDimension,
                               scalarValue
                               )
                           ));
            }

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

                return(GMacValueMultivector.Create(
                           mvType,
                           GaMultivector.CreateCopy(mvValue.MultivectorCoefficients)
                           ));
            }

            throw new InvalidOperationException("Invalid cast operation");
        }
Esempio n. 2
0
 public ILanguageValue DuplicateValue(bool deepCopy)
 {
     return(new GMacValueMultivector(ValueMultivectorType, GaMultivector.CreateCopy(MultivectorCoefficients)));
 }