SyFi  0.3
pol.cpp
Go to the documentation of this file.
00001 #include <SyFi.h>
00002 #include <fstream>
00003 
00004 using namespace GiNaC; 
00005 using namespace SyFi; 
00006 using namespace std; 
00007 
00008 
00009 
00010 int main() {
00011 
00012     initSyFi(2);
00013 
00014     archive ar; 
00015 
00016     int order = 2; 
00017     int nsd   = 2; 
00018 
00019     ex polynom_space = pol(order,nsd, "a"); 
00020     cout <<"polynom_space "<<polynom_space<<endl; 
00021     ar.archive_ex(polynom_space, "polynom_space"); 
00022 
00023     ex p = polynom_space.op(0); 
00024     cout <<"polynom p = "<<p<<endl; 
00025     ar.archive_ex(p, "p"); 
00026 
00027     ex dpdx = diff(p,x);   
00028     cout <<"dpdx = "<<dpdx<<endl; 
00029     ar.archive_ex(dpdx, "dpdx"); 
00030 
00031     Triangle triangle(lst(0,0), lst(1,0), lst(0,1)); 
00032     ex intp = triangle.integrate(p); 
00033     cout <<"integral of p over reference triangle = "<<intp<<endl;  
00034 
00035     //Bernstein polynomial in barycentric coordinates 
00036 
00037     ex polynom_space2 = bernstein(order,triangle, "a"); 
00038     ex p2 = polynom_space2.op(0); 
00039     cout <<"polynom p2 = "<<p2<<endl; 
00040     ar.archive_ex(polynom_space2, "polynom_space2"); 
00041 
00042     ex dp2dx = diff(p2,x);   
00043     cout <<"dp2dx = "<<dp2dx<<endl; 
00044     ar.archive_ex(dp2dx, "dp2dx"); 
00045 
00046     ex intp2 = triangle.integrate(p2); 
00047     cout <<"integral of p2 over reference triangle = "<<intp<<endl;  
00048     ar.archive_ex(intp2, "intp2"); 
00049 
00050     ofstream vfile("pol.gar.v"); 
00051     vfile << ar; vfile.close(); 
00052     if(!compare_archives("pol.gar.v", "pol.gar.r")) { 
00053             cerr << "Failure!" << endl;
00054             return -1;
00055     }
00056 
00057     return 0; 
00058 
00059 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator