Exemplo n.º 1
0
        /// <summary>
        /// Reads a Complex number from the link and returns an object of the class set as the
        /// <see cref="IMathLink.ComplexType">ComplexType</see>.
        /// </summary>
        ///
        public object GetComplex(IMathLink ml)
        {
            double re = 0.0;
            double im = 0.0;

            if (ComplexType == null)
            {
                throw new MathLinkException(MathLinkException.MLE_NO_COMPLEX);
            }

            ExpressionType type = ml.GetNextExpressionType();

            switch (type)
            {
            case ExpressionType.Integer:
            case ExpressionType.Real: {
                re = ml.GetDouble();
                break;
            }

            case ExpressionType.Complex: {
                ml.CheckFunctionWithArgCount("Complex", 2);
                re = ml.GetDouble();
                im = ml.GetDouble();
                break;
            }

            default:
                throw new MathLinkException(MathLinkException.MLE_BAD_COMPLEX);
            }
            return(constructComplex(re, im));
        }
Exemplo n.º 2
0
 public override double GetDouble()
 {
     return(impl.GetDouble());
 }