public void DifferentTypes() { var poly3 = KtPolynomial.Create(2, 1); Term term1 = poly3; var poly1 = KtPolynomial.Create(3, 5, 2, 5); var poly2 = KtPolynomial.Create(3, 12, -2); Term term2 = new DiscontinuousTerm(poly1, poly2, Limit.Create(-12, 20)); var actualResult = term1 - term2; Assert.AreEqual(actualResult.Length, 3); Term expectedResult1 = new DiscontinuousTerm(poly3, KtPolynomial.Create(1), ForwardLimit.Create(-12)); Assert.AreEqual(actualResult[0], expectedResult1); Term expectedResult2 = new DiscontinuousTerm((poly3 * poly2) - poly1, poly2, Limit.Create(-12, 20)); Assert.AreEqual(actualResult[1], expectedResult2); Term expectedResult3 = new DiscontinuousTerm(poly3, KtPolynomial.Create(1), BackwardLimit.Create(20)); Assert.AreEqual(actualResult[2], expectedResult3); actualResult = term2 - term1; //reversed Assert.AreEqual(actualResult.Length, 3); expectedResult1 = new DiscontinuousTerm(-poly3, KtPolynomial.Create(1), ForwardLimit.Create(-12)); Assert.AreEqual(actualResult[0], expectedResult1); expectedResult2 = new DiscontinuousTerm(poly1 - (poly3 * poly2), poly2, Limit.Create(-12, 20)); Assert.AreEqual(actualResult[1], expectedResult2); expectedResult3 = new DiscontinuousTerm(-poly3, KtPolynomial.Create(1), BackwardLimit.Create(20)); Assert.AreEqual(actualResult[2], expectedResult3); }
public void BothDiscontinuousSpliceable() { var poly3 = KtPolynomial.Create(2, 1); var poly4 = KtPolynomial.Create(3, 1); Term term1 = new DiscontinuousTerm(poly3, poly4, ForwardLimit.Create(9)); Term term2 = new DiscontinuousTerm(poly3, poly4, BackwardLimit.Create(9)); var actualResult = term1 + term2; Assert.AreEqual(actualResult.Length, 1); Assert.AreEqual(actualResult[0], new ContinuousTerm(poly3, poly4)); }
public void Adding() { var poly1 = KtPolynomial.Create(4, 0, -2, 0, 4, 1); var poly2 = KtPolynomial.Create(3, -4.3, 1); var poly3 = KtPolynomial.Create(4, 3, 7); var denom = KtPolynomial.Create(1); var term1 = new DiscontinuousTerm(poly1, denom, Limit.Create(-20, -10)); var term2 = new DiscontinuousTerm(poly2, denom, Limit.Create(-15, -5)); Term term3 = poly3; var expression = new Expression(term1, term3, term2); var expected = new Expression( new DiscontinuousTerm(2 * poly3, denom, ForwardLimit.Create(-20)), new DiscontinuousTerm(2 * (poly3 + poly1), denom, Limit.Create(-20, -15)), new DiscontinuousTerm(2 * (poly3 + poly1 + poly2), denom, Limit.Create(-15, -10)), new DiscontinuousTerm(2 * (poly3 + poly2), denom, Limit.Create(-10, -5)), new DiscontinuousTerm(2 * poly3, denom, BackwardLimit.Create(-5))); Assert.AreEqual(expression + expression, expected); }
public void ContinuousAndNot() { var poly3 = KtPolynomial.Create(2, 1); Term term1 = poly3; var poly1 = KtPolynomial.Create(3, 5, 2, 5); var poly2 = KtPolynomial.Create(3, 12, -2); Term term2 = new DiscontinuousTerm(poly1, poly2, Limit.Create(-12, 20)); var actualResult = term1 + term2; Assert.AreEqual(actualResult.Length, 3); Term expectedResult1 = new DiscontinuousTerm(poly3, KtPolynomial.Create(1), ForwardLimit.Create(-12)); Assert.AreEqual(actualResult[0], expectedResult1); Term expectedResult2 = new DiscontinuousTerm((poly3 * poly2) + poly1, poly2, Limit.Create(-12, 20)); Assert.AreEqual(actualResult[1], expectedResult2); Term expectedResult3 = new DiscontinuousTerm(poly3, KtPolynomial.Create(1), BackwardLimit.Create(20)); Assert.AreEqual(actualResult[2], expectedResult3); Assert.IsTrue(actualResult.SequenceEqual(term2 + term1)); }