00001
00002
00003
00004 #ifndef GINAC_TOOLS_IS_INCLUDED
00005 #define GINAC_TOOLS_IS_INCLUDED
00006
00007 #include <string>
00008 #include <iostream>
00009 #include <map>
00010
00011 #include <ginac/ginac.h>
00012
00013 #include "utilities.h"
00014
00015 namespace SyFi
00016 {
00017
00018 bool compare(const GiNaC::ex & e, const std::string & s);
00019
00020 void EQUAL_OR_DIE(const GiNaC::ex & e, const std::string & s);
00021
00022
00023
00024
00025 bool compare_archives(const std::string & first, const std::string & second, std::ostream & os=std::cout);
00026
00027
00028
00029 GiNaC::ex inner(GiNaC::ex a, GiNaC::ex b, bool transposed = false);
00030 GiNaC::ex inner(GiNaC::exvector& v1, GiNaC::exvector& v2);
00031 GiNaC::ex inner(GiNaC::lst v1, GiNaC::lst v2);
00032 GiNaC::lst cross(GiNaC::lst& v1, GiNaC::lst& v2);
00033
00034 GiNaC::lst matvec(GiNaC::matrix& M, GiNaC::lst& x);
00035 GiNaC::ex matvec(GiNaC::ex A, GiNaC::ex x);
00036
00037 GiNaC::lst ex2equations(GiNaC::ex rel);
00038 GiNaC::lst collapse(GiNaC::lst l);
00039
00040 GiNaC::matrix equations2matrix (const GiNaC::ex &eqns, const GiNaC::ex &symbols);
00041 void matrix_from_equations(const GiNaC::ex &eqns, const GiNaC::ex &symbols, GiNaC::matrix &A, GiNaC::matrix& b);
00042
00043 GiNaC::ex lst_to_matrix2(const GiNaC::lst & l);
00044 GiNaC::lst matrix_to_lst2(const GiNaC::ex & m );
00045
00046 GiNaC::lst lst_equals(GiNaC::ex a, GiNaC::ex b);
00047
00048
00049 int find(GiNaC::ex e, GiNaC::lst list);
00050
00051
00052 void check_visitor(GiNaC::ex e, GiNaC::lst& exlist);
00053 void visitor_subst_pow(GiNaC::ex e, GiNaC::exmap& map, ex_int_map& intmap, std::string a);
00054
00055
00056 GiNaC::ex pol(unsigned int order, unsigned int nsd, const std::string a);
00057
00058 GiNaC::lst polv(unsigned int no_fields, unsigned int order, unsigned int nsd, const std::string a);
00059
00060 GiNaC::ex polb(unsigned int order, unsigned int nsd, const std::string a);
00061
00062
00063
00064
00065 GiNaC::ex homogenous_pol(unsigned int order, unsigned int nsd, const std::string a);
00066
00067 GiNaC::lst homogenous_polv(unsigned int no_fields, unsigned int order, unsigned int nsd, const std::string a);
00068
00069
00070 GiNaC::ex legendre(unsigned int order, unsigned int nsd, const std::string a);
00071
00072 GiNaC::lst legendrev(unsigned int no_fields, unsigned int order, unsigned int nsd, const std::string a);
00073
00074
00075 GiNaC::exvector coeff(GiNaC::ex pol);
00076 GiNaC::lst coeffs(GiNaC::ex pol);
00077 GiNaC::lst coeffs(GiNaC::lst pols);
00078
00079
00080 GiNaC::exmap pol2basisandcoeff(GiNaC::ex e);
00081 GiNaC::exmap pol2basisandcoeff(GiNaC::ex e, GiNaC::ex s);
00082
00083
00084 void collect_symbols(const GiNaC::ex & e, exset & v);
00085
00086 GiNaC::exvector collect_symbols(const GiNaC::ex & e);
00087
00088
00089
00090 GiNaC::exhashmap<int> count_symbols(const GiNaC::ex & e);
00091
00092
00093
00094 GiNaC::ex extract_symbols(const GiNaC::ex & e);
00095
00096
00097
00098
00099
00100
00101 class ExStats
00102 {
00103 public:
00104 ExStats(): muls(0), adds(0), pows(0), functions(0), flops(0) {}
00105
00106 inline const ExStats & operator+=(const ExStats & rhs)
00107 {
00108 muls += rhs.muls;
00109 adds += rhs.adds;
00110 pows += rhs.pows;
00111 functions += rhs.functions;
00112 flops += rhs.flops;
00113 return *this;
00114 }
00115
00116 int muls;
00117 int adds;
00118
00119 int pows;
00120 int functions;
00121
00122
00123 int flops;
00124 };
00125
00126
00127 ExStats count_ops(const GiNaC::ex & e);
00128
00129
00130
00131 GiNaC::ex replace_powers(const GiNaC::ex & e, const std::list<GiNaC::symbol> & symbols, std::list<symexpair> & sel, const std::string & tmpsymbolprefix="p_");
00132
00133 };
00134 #endif