utilities.cpp
Go to the documentation of this file.00001
00002
00003
00004 #include "utilities.h"
00005 #include "syfi_version.h"
00006
00007 #include <sstream>
00008 #include <math.h>
00009
00010 using namespace std;
00011
00012 namespace SyFi
00013 {
00014
00015
00016 const int version_major = SYFILIB_MAJOR_VERSION;
00017 const int version_minor = SYFILIB_MINOR_VERSION;
00018 const int version_micro = SYFILIB_MICRO_VERSION;
00019
00020 int dirac(unsigned int i, unsigned int j)
00021 {
00022 if (i==j) return 1;
00023 else return 0;
00024 }
00025
00026 string int2string(int i)
00027 {
00028 ostringstream os;
00029 os << i;
00030 return os.str();
00031 }
00032
00033 string istr(const string & a, int b)
00034 {
00035 ostringstream s;
00036 s << a << b;
00037 return s.str();
00038 }
00039
00040 string istr(const string & a, int b, int c)
00041 {
00042 ostringstream s;
00043 s << a << b << "_" <<c;
00044 return s.str();
00045 }
00046
00047 string lst2string(GiNaC::lst& l)
00048 {
00049
00050 ostringstream s;
00051 GiNaC::lst::const_iterator i = l.begin();
00052 s <<"("<<*i;
00053 ++i;
00054
00055 for (; i != l.end() ; ++i)
00056 {
00057 s<< ","<< *i;
00058 }
00059 s <<");"<<endl;
00060 return s.str();
00061 }
00062
00063 string exvector2string(GiNaC::exvector& v)
00064 {
00065 ostringstream s;
00066 s <<"[";
00067 for (unsigned int i=0; i< v.size()-1; i++)
00068 {
00069 s <<v[i]<<",";
00070 }
00071 s<<v[v.size()-1]<< "]";
00072 return s.str();
00073 }
00074
00075 void print(GiNaC::lst& l)
00076 {
00077
00078
00079
00080 GiNaC::lst::const_iterator i = l.begin();
00081 cout <<"GiNaC::lst("<<*i;
00082 ++i;
00083
00084 for (; i != l.end() ; ++i)
00085 {
00086 cout << ","<< *i;
00087 }
00088 cout <<");"<<endl;
00089 }
00090
00091 void print(GiNaC::exvector& v)
00092 {
00093 cout <<"v=[";
00094 for (unsigned int i=0; i< v.size()-1; i++)
00095 {
00096 cout <<v[i]<<"," <<endl;
00097 }
00098 cout <<v[v.size()-1]<< "]"<<endl;
00099 }
00100
00101 void print(std::map<std::pair<unsigned int,unsigned int>, GiNaC::ex>& A)
00102 {
00103 map<std::pair<unsigned int,unsigned int>,GiNaC::ex>::iterator iter;
00104 for (iter = A.begin(); iter != A.end() ; iter++)
00105 {
00106 cout <<"A["<<(*iter).first.first<<","<<(*iter).first.second<<"]="<<(*iter).second<<endl;
00107 }
00108 }
00109
00110 void print(ex_int_map map)
00111 {
00112 GiNaC::ex b;
00113 int c=0;
00114 ex_int_map::iterator iter;
00115 iter = map.begin();
00116 cout <<"{";
00117 for (iter = map.begin(); iter != map.end(); iter++)
00118 {
00119 b = (*iter).first; c = map[b];
00120 cout <<", "<<b<<":"<<c;
00121 }
00122 cout <<"}"<<endl;
00123 }
00124
00125 void print(GiNaC::exmap map)
00126 {
00127 GiNaC::ex b;
00128 GiNaC::ex c;
00129 GiNaC::exmap::iterator iter;
00130 cout <<"{" <<b<<":"<<c;
00131 for (iter = map.begin(); iter != map.end(); iter++)
00132 {
00133 b = (*iter).first; c = map[b];
00134 cout <<", "<<b<<":"<<c;
00135 }
00136 cout <<"}"<<endl;
00137 }
00138
00139 }