Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Search for

# 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 no_fields, 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 // generates a homogenous polynom of arbitrary order on a line, a triangle, or a tetrahedron
    00061 GiNaC::ex homogenous_pol(int order, int nsd, const string a);
    00062 // generates a homogenous vector polynom of arbitrary order
    00063 GiNaC::lst homogenous_polv(int no_fields, int order, int nsd, const string a);
    00064
    00065 // generates a Legendre polynom of arbitrary order
    00066 GiNaC::ex legendre(int order, int nsd, const string a);
    00067 // generates a Legendre vector polynom of arbitrary order
    00068 GiNaC::lst legendrev(int no_fields, int order, int nsd, const string a);
    00069
    00070
    00071
    00072
    00073 // matrix vector product
    00074 GiNaC::lst matvec(GiNaC::matrix& M, GiNaC::lst& x);
    00075 GiNaC::ex  matvec(GiNaC::ex A, GiNaC::ex x);
    00076
    00077
    00078
    00079 // extracts the coefficents from a polynomial
    00080 GiNaC::exvector coeff(GiNaC::ex pol);
    00081 GiNaC::lst coeffs(GiNaC::ex pol);
    00082 GiNaC::lst coeffs(GiNaC::lst pols);
    00083 // extract the basisfunctions and corresponding coefficents from a polynomial
    00084 ex_ex_map  pol2basisandcoeff(GiNaC::ex e);
    00085
    00086
    00087 // the divergence
    00088 GiNaC::ex div(GiNaC::exvector& v);
    00089 GiNaC::ex div(GiNaC::lst& v);
    00090 GiNaC::ex div(GiNaC::ex v);
    00091 GiNaC::ex grad(GiNaC::ex f);
    00092
    00093 // print functions
    00094 #ifndef SWIG
    00095 void print(GiNaC::exvector& v);
    00096 void print(GiNaC::lst& l);
    00097 void print(ex_ex_map m);
    00098 void print(ex_int_map m);
    00099 void print(std::map<std::pair<int,int>, GiNaC::ex>& A);
    00100 #endif
    00101
    00102 // dirac delta function
    00103 int dirac(int i, int j);
    00104
    00105
    00106 GiNaC::lst ex2equations(GiNaC::ex rel);
    00107 GiNaC::lst collapse(GiNaC::lst l);
    00108
    00109 GiNaC::matrix equations2matrix (const GiNaC::ex &eqns, const GiNaC::ex &symbols);
    00110
    00111 GiNaC::lst lst_equals(GiNaC::ex a, GiNaC::ex b);
    00112 GiNaC::ex lst_to_matrix2(const GiNaC::lst & l);
    00113 GiNaC::lst matrix_to_lst2(const GiNaC::ex & m );
    00114
    00115 // FIXME bad name
    00116 int find(GiNaC::ex e, GiNaC::lst list);
    00117 void check_visitor(GiNaC::ex e, GiNaC::lst& exlist);
    00118 void visitor_subst_pow(GiNaC::ex e, ex_ex_map& map, ex_int_map& intmap, string a);
    00119
    00120 string istr(string a, int b);
    00121
    00122 bool compare(GiNaC::ex e, string s);
    00123
    00124 void EQUAL_OR_DIE(GiNaC::ex e, char* s);
    00125
    00126 void matrix_from_equations(const GiNaC::ex &eqns, const GiNaC::ex &symbols, GiNaC::matrix &A, GiNaC::matrix& b);
    00127
    00128
    00129 #endif
    00130
    00131
    00132
    00133