public override object Evaluate() { IList <double> xValues = LeftExpression.EvaluateAsRealVector(); IList <double> yValues = RightExpression.EvaluateAsRealVector(); return(new CMatrix(CPolynomial.InterpolatingPolynomial(xValues, yValues).ToArray())); }
public void InterpolatingPolynomialTest() { //arrange double TOL = 1E-6; double[] xValues = new double[] { 1, 2.5, 6, 7.9, 18 }; double[] yValues = new double[] { 8.6, 0, -2, 9, 33 }; //action CPolynomial poly = CPolynomial.InterpolatingPolynomial(xValues, yValues); //assert for (int j = 0; j < xValues.Length; j++) { Complex val = poly.Evaluate(xValues[j]); NumericUtil.FuzzyEquals(yValues[j], val, TOL).Should().BeTrue(); } }