public override object Evaluate() { CPolynomial poly1 = LeftExpression.EvaluateAsCPolynomial(); CPolynomial poly2 = RightExpression.EvaluateAsCPolynomial(); return(new CMatrix(CPolynomial.Divide(poly1, poly2).ToArray())); }
public void DivTest() { //arrange double TOL = 1E-12; CPolynomial f = new CPolynomial(new Complex[] { new Complex(3467.2, 456), new Complex(2.225, -0.0123), new Complex(46.2, 4.24), new Complex(2, 2), new Complex(12.8, 16.3), new Complex(0, 0), new Complex(22, 347) }); CPolynomial g = new CPolynomial(new Complex[] { new Complex(3, 8.5), new Complex(11, -0.5), new Complex(0, 1), new Complex(1, 2), new Complex(346, 4.365) }); CPolynomial zero = new CPolynomial(1); CPolynomial r; CPolynomial q = CPolynomial.Divide(f, g, out r); CPolynomial rtest = new CPolynomial(1); //action CPolynomial qtest = CPolynomial.Divide(f - r, g, out rtest); //assert for (int j = 0; j < rtest.Length; j++) { Complex.Abs(rtest[j]).Should().BeLessOrEqualTo(TOL); } qtest.Should().Be(q); }