Пример #1
0
    public virtual Algebraic map(LambdaAlgebraic lambda, Algebraic arg)
    {
        if (arg == null)
        {
            var r = lambda.f_exakt(this);

            if (r != null)
            {
                return(r);
            }

            var fname = lambda.GetType().Name;

            if (fname.StartsWith("Lambda", StringComparison.Ordinal))
            {
                fname = fname.Substring("Lambda".Length);
                fname = fname.ToLower();

                return(FunctionVariable.create(fname, this));
            }

            throw new JasymcaException("Wrong type of arguments.");
        }

        return(lambda.f_exakt(this, arg));
    }
Пример #2
0
    public override Algebraic Map(LambdaAlgebraic f, Algebraic args)
    {
        if (args is Vector && (( Vector )args).Length() == _items.Length)
        {
            // TODO: Check this
            var v = _items.Select((x, n) => x.Map(f, (( Vector )args)[n])).ToList();

            if (v.Any(x => !(x is Algebraic)))
            {
                throw new JasymcaException("Cannot evaluate function to algebraic.");
            }

            return(new Vector(v.Cast <Algebraic>().ToArray()));
        }
        else
        {
            // TODO: Check this
            var v = _items.Select(x => x.Map(f, args)).ToList();

            if (v.Any(x => !(x is Algebraic)))
            {
                throw new JasymcaException("Cannot evaluate function to algebraic.");
            }

            return(new Vector(v.Cast <Algebraic>().ToArray()));
        }
    }
Пример #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public Algebraic map(LambdaAlgebraic f) throws JasymcaException
    public override Algebraic map(LambdaAlgebraic f)
    {
        Algebraic[] cn = new Algebraic[a.Length];
        for (int i = 0; i < a.Length; i++)
        {
            cn[i] = f.f_exakt(a[i]);
        }
        return(new Vektor(cn));
    }
Пример #4
0
    public override Algebraic Map(LambdaAlgebraic f)
    {
        var cn = CreateRectangularArray <Algebraic>(a.Length, a[0].Length);

        for (int i = 0; i < a.Length; i++)
        {
            for (int k = 0; k < a[0].Length; k++)
            {
                cn[i][k] = f.SymEval(a[i][k]);
            }
        }
        return(new Matrix(cn));
    }
Пример #5
0
    public override Algebraic map(LambdaAlgebraic f)
    {
//JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
//ORIGINAL LINE: Algebraic[][] cn = new Algebraic[a.Length][a[0].Length];
        Algebraic[][] cn = RectangularArrays.ReturnRectangularAlgebraicArray(a.Length, a[0].Length);
        for (int i = 0; i < a.Length; i++)
        {
            for (int k = 0; k < a[0].Length; k++)
            {
                cn[i][k] = f.f_exakt(a[i][k]);
            }
        }
        return(new Matrix(cn));
    }
Пример #6
0
    public override Algebraic Map(LambdaAlgebraic lambda, Algebraic arg)
    {
        if (arg == null)
        {
            var r = lambda.PreEval(this);

            if (r != null)
            {
                return(r);
            }
        }

        return(base.Map(lambda, arg));
    }
Пример #7
0
    public override Algebraic map(LambdaAlgebraic lambda, Algebraic arg2)
    {
        if (arg2 == null)
        {
            var r = lambda.f(this);

            if (r != null)
            {
                return(r);
            }
        }

        return(base.map(lambda, arg2));
    }
Пример #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public Algebraic map(LambdaAlgebraic f) throws JasymcaException
    public override Algebraic map(LambdaAlgebraic f)
    {
        Algebraic x = v is SimpleVariable ? new Polynomial(v): FunctionVariable.create(((FunctionVariable)v).fname, f.f_exakt(((FunctionVariable)v).arg));
        Algebraic r = Zahl.ZERO;

        for (int i = a.Length - 1; i > 0; i--)
        {
            r = r.add(f.f_exakt(a[i])).mult(x);
        }
        if (a.Length > 0)
        {
            r = r.add(f.f_exakt(a[0]));
        }
        return(r);
    }
Пример #9
0
    public override Algebraic Map(LambdaAlgebraic f, Algebraic arg)
    {
        var b = CreateRectangularArray <Algebraic>(a.Length, a[0].Length);

        if (arg is Matrix && Equalsized(( Matrix )arg))
        {
            for (int i = 0; i < a.Length; i++)
            {
                for (int k = 0; k < a[0].Length; k++)
                {
                    var c = (( Matrix )arg)[i, k];

                    object r = a[i][k].Map(f, c);

                    if (r is Algebraic)
                    {
                        b[i][k] = ( Algebraic )r;
                    }
                    else
                    {
                        throw new JasymcaException("Cannot evaluate function to algebraic.");
                    }
                }
            }
        }
        else
        {
            for (int i = 0; i < a.Length; i++)
            {
                for (int k = 0; k < a[0].Length; k++)
                {
                    object r = a[i][k].Map(f, arg);
                    if (r is Algebraic)
                    {
                        b[i][k] = (Algebraic)r;
                    }
                    else
                    {
                        throw new JasymcaException("Cannot evaluate function to algebraic.");
                    }
                }
            }
        }
        return(new Matrix(b));
    }
Пример #10
0
    public override Algebraic Map(LambdaAlgebraic f)
    {
        var x = _v is SimpleVariable ? new Polynomial(_v): FunctionVariable.Create(((FunctionVariable)_v).Name, f.SymEval(((FunctionVariable)_v).Var));

        Algebraic r = Symbolic.ZERO;

        for (int i = Coeffs.Length - 1; i > 0; i--)
        {
            r = (r + f.SymEval(Coeffs[i])) * x;
        }

        if (Coeffs.Length > 0)
        {
            r = r + f.SymEval(Coeffs[0]);
        }

        return(r);
    }
Пример #11
0
    public override Algebraic map(LambdaAlgebraic f, Algebraic arg2)
    {
//JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
//ORIGINAL LINE: Algebraic[][] b = new Algebraic[a.Length][a[0].Length];
        Algebraic[][] b = RectangularArrays.ReturnRectangularAlgebraicArray(a.Length, a[0].Length);
        if (arg2 is Matrix && equalsized((Matrix)arg2))
        {
            for (int i = 0; i < a.Length; i++)
            {
                for (int k = 0; k < a[0].Length; k++)
                {
                    Algebraic c = ((Matrix)arg2).get(i, k);
                    object    r = a[i][k].map(f, c);
                    if (r is Algebraic)
                    {
                        b[i][k] = (Algebraic)r;
                    }
                    else
                    {
                        throw new JasymcaException("Cannot evaluate function to algebraic.");
                    }
                }
            }
        }
        else
        {
            for (int i = 0; i < a.Length; i++)
            {
                for (int k = 0; k < a[0].Length; k++)
                {
                    object r = a[i][k].map(f, arg2);
                    if (r is Algebraic)
                    {
                        b[i][k] = (Algebraic)r;
                    }
                    else
                    {
                        throw new JasymcaException("Cannot evaluate function to algebraic.");
                    }
                }
            }
        }
        return(new Matrix(b));
    }
Пример #12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public Algebraic map_lambda(LambdaAlgebraic f, Algebraic arg2) throws ParseException,JasymcaException
    public override Algebraic map(LambdaAlgebraic f, Algebraic arg2)
    {
        Algebraic[] b = new Algebraic[a.Length];
        if (arg2 is Vektor && ((Vektor)arg2).length() == a.Length)
        {
            for (int i = 0; i < b.Length; i++)
            {
                Algebraic c = ((Vektor)arg2).get(i);
                object    r = a[i].map(f, c);
                if (r is Algebraic)
                {
                    b[i] = (Algebraic)r;
                }
                else
                {
                    throw new JasymcaException("Cannot evaluate function to algebraic.");
                }
            }
        }
        else
        {
            for (int i = 0; i < b.Length; i++)
            {
                object r = a[i].map(f, arg2);
                if (r is Algebraic)
                {
                    b[i] = (Algebraic)r;
                }
                else
                {
                    throw new JasymcaException("Cannot evaluate function to algebraic.");
                }
            }
        }
        return(new Vektor(b));
    }
Пример #13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public Algebraic map(LambdaAlgebraic f) throws JasymcaException
    public override Algebraic map(LambdaAlgebraic f)
    {
        return(f.f_exakt(nom).div(f.f_exakt(den)));
    }
Пример #14
0
 public FunctionVariable(string fname, Algebraic fvar, LambdaAlgebraic flambda)
 {
     this.Name      = fname;
     this.Var       = fvar;
     this.AlgLambda = flambda;
 }
Пример #15
0
 public override Algebraic Map(LambdaAlgebraic f)
 {
     return(new Vector(_items.Select(f.SymEval).ToArray()));
 }
Пример #16
0
 public FunctionVariable(string fname, Algebraic arg, LambdaAlgebraic la)
 {
     this.fname = fname;
     this.arg   = arg;
     this.la    = la;
 }
Пример #17
0
 public override Algebraic Map(LambdaAlgebraic f)
 {
     return(f.SymEval(nom) / f.SymEval(den));
 }
Пример #18
0
 public override Algebraic Map(LambdaAlgebraic f)
 {
     return(poly2exp(base.Map(f)));
 }
Пример #19
0
 public override Algebraic Map(LambdaAlgebraic lambda)
 {
     return(lambda.PreEval(this));
 }
Пример #20
0
 public abstract Algebraic map(LambdaAlgebraic f);
Пример #21
0
 public override Algebraic map(LambdaAlgebraic lambda)
 {
     return(lambda.f(this));
 }