SyFi  0.3
legendre.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 int main() {
00009 
00010     initSyFi(2); 
00011 
00012     archive ar; 
00013 
00014     int order = 2; 
00015 
00016 
00017     ex polynom_space = legendre(order,nsd, "a"); 
00018     cout <<"polynom_space "<<polynom_space<<endl; 
00019     ar.archive_ex(polynom_space, "polynom_space"); 
00020 
00021     ex p = polynom_space.op(0); 
00022     cout <<"polynom p = "<<p<<endl; 
00023     ar.archive_ex(p, "p"); 
00024 
00025     ex dpdx = diff(p,x);   
00026     cout <<"dpdx = "<<dpdx<<endl; 
00027     ar.archive_ex(dpdx, "dpdx"); 
00028 
00029     ex p0 = lst(-1,-1);
00030     ex p1 = lst(1,1);
00031 
00032     Rectangle rectangle(p0,p1) ;
00033     ex basis = polynom_space.op(2); 
00034     for (unsigned int i=0; i< basis.nops(); i++) {
00035         cout <<"i "<<i<<endl; 
00036         ex integrand = p*basis.op(i); 
00037         ex ai = rectangle.integrate(integrand); 
00038         cout <<"ai "<<ai<<endl; 
00039 
00040         ar.archive_ex(ai, istr("a", i).c_str()); 
00041     }
00042 
00043     ofstream vfile("legendre.gar.v"); 
00044     vfile << ar; vfile.close(); 
00045     if(!compare_archives("legendre.gar.v", "legendre.gar.r")) { 
00046             cerr << "Failure!" << endl;
00047             return -1;
00048     }
00049 
00050     return 0; 
00051 
00052 }
00053 
00054 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator