tools.h

Go to the documentation of this file.
00001 #ifndef TOOLS_IS_INCLUDED 
00002 #define TOOLS_IS_INCLUDED 
00003 
00004 #include <ginac/ginac.h>
00005 #include <iostream>
00006 #include <stdio.h>
00007 #include <stdlib.h>
00008 #include <math.h>
00009 #include <string>
00010 #include <sstream>
00011 #include <algorithm>
00012 #include <map>
00013 #include <stdexcept>
00014 #include <vector>
00015 
00016 
00017 
00018 //using namespace GiNaC; 
00019 using namespace std; 
00020 
00021 extern GiNaC::symbol x; 
00022 extern GiNaC::symbol y; 
00023 extern GiNaC::symbol z; 
00024 extern int nsd; 
00025 extern GiNaC::symbol infinity; 
00026 extern GiNaC::symbol DUMMY; 
00027 
00028 /* Vector of ex */ 
00029 typedef vector<GiNaC::ex> ex_vector; 
00030 
00031 /* Dictionary with ex as keys and values */ 
00032 typedef map<GiNaC::ex,GiNaC::ex, GiNaC::ex_is_less>  ex_ex_map;
00033 typedef map<GiNaC::ex,int, GiNaC::ex_is_less>  ex_int_map;
00034 
00035 /* Iterator associated with the ex-ex dictionary */ 
00036 typedef map<GiNaC::ex,GiNaC::ex>::iterator ex_ex_it;  
00037 typedef map<GiNaC::ex,int>::iterator ex_int_it;  
00038 
00039 /* Vector of vectors of ex */ 
00040 typedef vector<GiNaC::exvector> ex_vector_vector;
00041 
00042 
00043 // inner product of vectors or lst
00044 GiNaC::ex inner(GiNaC::ex a, GiNaC::ex b, bool transposed = false); 
00045 GiNaC::ex inner(GiNaC::exvector& v1, GiNaC::exvector& v2); 
00046 GiNaC::ex inner(GiNaC::lst v1, GiNaC::lst v2); 
00047 GiNaC::lst cross(GiNaC::lst& v1, GiNaC::lst& v2); 
00048 
00049 
00050 // generates a polynom of arbitrary order on a line, a triangle, or a tetrahedron 
00051 GiNaC::ex pol(int order, int nsd, const string a);  
00052 // generates a vector polynom of arbitrary order on a line, a triangle or a tetrahedron 
00053 GiNaC::lst polv(int order, int nsd, const string a);  
00054 // generates a polynom of arbitrary order on a square or a box   
00055 GiNaC::ex polb(int order, int nsd, const string a);  
00056 // generates a vector polynom of arbitrary order on a squart or a box  
00057 //lst polbv(int order, int nsd, const string a);  
00058 
00059 
00060 // matrix vector product
00061 GiNaC::lst matvec(GiNaC::matrix& M, GiNaC::lst& x);  
00062 
00063 
00064 
00065 // extracts the coefficents from a polynomial
00066 GiNaC::exvector coeff(GiNaC::ex pol); 
00067 GiNaC::lst coeffs(GiNaC::ex pol); 
00068 GiNaC::lst coeffs(GiNaC::lst pols); 
00069 // extract the basisfunctions and corresponding coefficents from a polynomial
00070 ex_ex_map  pol2basisandcoeff(GiNaC::ex e); 
00071 
00072 
00073 // the divergence 
00074 GiNaC::ex div(GiNaC::exvector& v);  
00075 GiNaC::ex div(GiNaC::lst& v);  
00076 GiNaC::ex div(GiNaC::ex v);  
00077 GiNaC::ex grad(GiNaC::ex f); 
00078 
00079 // print functions 
00080 #ifndef SWIG 
00081 void print(GiNaC::exvector& v); 
00082 void print(GiNaC::lst& l); 
00083 void print(ex_ex_map m); 
00084 void print(ex_int_map m); 
00085 void print(std::map<std::pair<int,int>, GiNaC::ex>& A); 
00086 #endif 
00087 
00088 // dirac delta function 
00089 int dirac(int i, int j); 
00090 
00091 
00092 GiNaC::lst ex2equations(GiNaC::ex rel); 
00093 GiNaC::lst collapse(GiNaC::lst l);  
00094 
00095 GiNaC::matrix equations2matrix (const GiNaC::ex &eqns, const GiNaC::ex &symbols); 
00096 
00097 GiNaC::lst lst_equals(GiNaC::ex a, GiNaC::ex b);  
00098 GiNaC::ex lst_to_matrix2(const GiNaC::lst & l); 
00099 GiNaC::lst matrix_to_lst2(const GiNaC::ex & m ); 
00100 
00101 // FIXME bad name
00102 int find(GiNaC::ex e, GiNaC::lst list); 
00103 void check_visitor(GiNaC::ex e, GiNaC::lst& exlist);  
00104 void visitor_subst_pow(GiNaC::ex e, ex_ex_map& map, ex_int_map& intmap, string a);  
00105 
00106 string istr(string a, int b); 
00107 
00108 bool compare(GiNaC::ex e, string s); 
00109 
00110 void EQUAL_OR_DIE(GiNaC::ex e, char* s);  
00111 
00112 void matrix_from_equations(const GiNaC::ex &eqns, const GiNaC::ex &symbols, GiNaC::matrix &A, GiNaC::matrix& b); 
00113  
00114 
00115 #endif 
00116 
00117 
00118 
00119 

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