void TestExprDiff::apply03() { Variable x("x"),y("y"); Function f(x,y,x*y,"f"); Function g(x,y,f(2*x,3*y)); Function dg(g,Function::DIFF); TEST_ASSERT(sameExpr(dg.expr(),"((2*df((2*x),(3*y))[0]),(3*df((2*x),(3*y))[1]))")); double _box[][2]={{1,1},{2,2}}; double _dg_box[][2]={{12,12},{6,6}}; IntervalVector dg_box(dg.eval_vector(IntervalVector(2,_box))); TEST_ASSERT(dg_box==IntervalVector(2,_dg_box)); }
void TestExprDiff::apply03() { Variable x("x"),y("y"); Function f(x,y,x*y,"f"); Function g(x,y,f(2*x,3*y)); Function dg(g,Function::DIFF); // TODO: there are actually many different equivalent expressions of // the differential. // What should we exactly test? Probably requires expression equivalence // operator but this is known to be a difficult task... // CPPUNIT_ASSERT(sameExpr(dg.expr(),"((2*df((2*x),(3*y))[0]),(3*df((2*x),(3*y))[1]))")); //CPPUNIT_ASSERT(sameExpr(dg.expr(),"((df((2*x),(3*y))[0]*2),(df((2*x),(3*y))[1]*3))")); CPPUNIT_ASSERT(sameExpr(dg.expr(),"((6*y),(6*x))")); double _box[][2]={{1,1},{2,2}}; double _dg_box[][2]={{12,12},{6,6}}; IntervalVector dg_box(dg.eval_vector(IntervalVector(2,_box))); //CPPUNIT_ASSERT(dg_box==IntervalVector(2,_dg_box)); check(dg_box,IntervalVector(2,_dg_box)); CPPUNIT_ASSERT(dg_box.is_superset(IntervalVector(2,_dg_box))); }