fe_ex3.cpp File Reference

#include <SyFi.h>

Go to the source code of this file.

Functions

int main ()


Function Documentation

int main  ) 
 

Definition at line 5 of file fe_ex3.cpp.

References bezier_ordinates(), dirac(), pol(), x, and y.

00005            {
00006     Triangle t(lst(0,0), lst(1,0), lst(0,1));  
00007     int order = 2; 
00008     ex polynom; 
00009     lst variables; 
00010 
00011     ex polynom_space = pol(order, 2, "a"); 
00012     // the polynomial spaces on the form: 
00013     // first item:     a0 + a1*x + a2*y + a3*x^2 + a4*x*y ...     the polynom
00014     // second item:    a0, a1, a2, ...                            the coefficents 
00015     // third  item     1, x, y, x^2                               the basis  
00016     // Could also do:
00017     // GiNaC::ex polynom_space = bernstein(order, t, "a"); 
00018 
00019     polynom = polynom_space.op(0); 
00020     variables = ex_to<lst>(polynom_space.op(1));
00021     // the variables a0,a1,a2 ..
00022   
00023     ex Nj; 
00024     // The bezier ordinates (in which the basis function should be either 0 or 1)
00025     lst points = bezier_ordinates(t,order); 
00026 
00027     // Loop over all basis functions Nj and all points. 
00028     // Each basis function Nj is determined by a set of linear equations: 
00029     //   Nj(xi) = dirac(i,j) 
00030     // This system of equations is then solved by lsolve
00031     for (int j=1; j <= points.nops(); j++) {
00032       lst equations; 
00033       int i=0; 
00034       for (int i=1; i<= points.nops() ; i++ ) { 
00035         // The point xi 
00036         ex point = points.op(i-1); 
00037         // The equation Nj(x) = dirac(i,j)  
00038         ex eq = polynom == dirac(i,j); 
00039         // Substitute x = xi and y = yi and appended the equation 
00040         // to the list of equations
00041         equations.append(eq.subs(lst(x == point.op(0) , y == point.op(1))));  
00042       }
00043 
00044 
00045       // We solve the linear system 
00046 //      cout <<"equations "<<equations<<endl; 
00047 //      cout <<"variables "<<variables<<endl; 
00048       ex subs = lsolve(equations, variables); 
00049       // Substitute to get the N_j 
00050       Nj = polynom.subs(subs);   
00051       cout <<"Nj "<<Nj<<endl; 
00052     }
00053 
00054 }


Generated on Mon Jan 9 18:08:08 2006 for SyFi by  doxygen 1.4.4