#include <SyFi.h>
Go to the source code of this file.
Functions | |
int | main () |
|
Definition at line 7 of file pol.cpp. References bernstein(), EQUAL_OR_DIE(), Triangle::integrate(), nsd, pol(), and x. 00007 { 00008 int order = 2; 00009 int nsd = 2; 00010 00011 ex polynom_space = pol(order,nsd, "a"); 00012 cout <<"polynom_space "<<polynom_space<<endl; 00013 00014 ex p = polynom_space.op(0); 00015 cout <<"polynom p = "<<p<<endl; 00016 EQUAL_OR_DIE(p,"y^2*a5+x^2*a3+a2*y+y*x*a4+a0+a1*x"); 00017 00018 ex dpdx = diff(p,x); 00019 cout <<"dpdx = "<<dpdx<<endl; 00020 EQUAL_OR_DIE(dpdx, "y*a4+a1+2*x*a3"); 00021 00022 Triangle triangle(lst(0,0), lst(1,0), lst(0,1)); 00023 ex intp = triangle.integrate(p); 00024 cout <<"integral of p over reference triangle = "<<intp<<endl; 00025 EQUAL_OR_DIE(intp, "1/6*a2+1/6*a1+1/12*a5+1/2*a0+1/24*a4+1/12*a3"); 00026 00027 //Bernstein polynomial in barycentric coordinates 00028 00029 ex polynom_space2 = bernstein(order,triangle, "a"); 00030 ex p2 = polynom_space2.op(0); 00031 cout <<"polynom p2 = "<<p2<<endl; 00032 EQUAL_OR_DIE(p2, "y^2*a0+2*(1-y-x)*x*a4+2*(1-y-x)*a3*y+(1-y-x)^2*a5+2*a1*y*x+a2*x^2"); 00033 00034 ex dp2dx = diff(p2,x); 00035 cout <<"dp2dx = "<<dp2dx<<endl; 00036 EQUAL_OR_DIE(dp2dx, "2*a1*y+2*(-1+y+x)*a5+2*a2*x+2*(1-y-x)*a4-2*a3*y-2*x*a4"); 00037 00038 ex intp2 = triangle.integrate(p2); 00039 cout <<"integral of p2 over reference triangle = "<<intp<<endl; 00040 EQUAL_OR_DIE(intp2, "1/12*a3+1/12*a2+1/12*a1+1/12*a5+1/12*a0+1/12*a4"); 00041 00042 00043 00044 00045 00046 }
|