public PolynomialBase(PolynomialBase <T> polynomialBase)
        {
            Length       = polynomialBase.Length;
            Coefficients = new T[Length];

            for (var i = 0; i < Length; i++)
            {
                Coefficients[i] = polynomialBase.Coefficients[i];
            }
        }
        protected static PolynomialBase <T> ElementWiseOperation(
            PolynomialBase <T> polynomial,
            T scalar,
            Func <T, T, T> operation)
        {
            var rawResult = new T[polynomial.Length];

            for (int i = 0; i < polynomial.Length; i++)
            {
                rawResult[i] = operation(polynomial.Coefficients[i], scalar);
            }

            PolynomialBase <T> result = new PolynomialBase <T>(rawResult);

            return(result);
        }
        protected static PolynomialBase <T> ElementWiseOperation(
            PolynomialBase <T> polynomialLeft,
            PolynomialBase <T> polynomialRight,
            Func <T, T, T> operation)
        {
            if (polynomialLeft.Length != polynomialRight.Length)
            {
                throw new DimensionMismatchException("The length of this polynomial does not equal the length of other polynomial");
            }

            var rawResult = new T[polynomialLeft.Length];

            for (int i = 0; i < polynomialLeft.Length; i++)
            {
                rawResult[i] = operation(polynomialLeft.Coefficients[i], polynomialRight.Coefficients[i]);
            }

            PolynomialBase <T> result = new PolynomialBase <T>(rawResult);

            return(result);
        }
Beispiel #4
0
 public PolynomialInt(PolynomialBase <int> polynomialBase) : base(polynomialBase)
 {
 }
 public PolynomialDouble(PolynomialBase <double> polynomialBase) : base(polynomialBase)
 {
 }