#include <SyFi.h>
Go to the source code of this file.
Functions | |
int | main () |
|
Definition at line 4 of file fe_ex3.cpp. References bezier_ordinates(), coeffs(), dirac(), pol(), x, and y. 00004 { 00005 Triangle t(lst(0,0), lst(1,0), lst(0,1)); 00006 int order = 2; 00007 ex polynom; 00008 lst variables; 00009 00010 // the polynomial spaces on the form: 00011 // a0 + a1*x + a2*y + a3*x^2 + a4*x*y ... 00012 polynom = pol(order, 2, "b"); 00013 // the variables a0,a1,a2 .. 00014 variables = coeffs(polynom); 00015 00016 ex Nj; 00017 // The bezier ordinates in which the basis function should be either 0 or 1 00018 lst points = bezier_ordinates(t,order); 00019 00020 // Loop over all basis functions N_j and all points xi. 00021 // Each basis function N_j is determined by a set of linear equations: 00022 // N_j(x_i) = dirac(i,j) 00023 // This system of equations is then solved by lsolve 00024 for (int j=1; j <= points.nops(); j++) { 00025 lst equations; 00026 int i=0; 00027 for (int i=1; i<= points.nops() ; i++ ) { 00028 // The point x_i 00029 ex point = points.op(i-1); 00030 // The equation N_j(x_i) = dirac(i,j) 00031 ex eq = polynom == dirac(i,j); 00032 // The equation is appended to the list of equations 00033 equations.append(eq.subs(lst(x == point.op(0) , y == point.op(1)))); 00034 } 00035 00036 00037 // We solve the linear system 00038 ex subs = lsolve(equations, variables); 00039 // Substitute to get the N_j 00040 Nj = polynom.subs(subs); 00041 cout <<"Nj "<<Nj<<endl; 00042 } 00043 00044 }
|