#include #include #include #include #include #include #include #include using namespace std; #include using namespace GiNaC; // Shamelessly ripped from GiNaC FAQ :) const symbol symbol_factory(const int & i_ ) { static map directory; map::iterator i = directory.find(i_); if (i!=directory.end()) return i->second; ostringstream so ; so << "s" << i_; string s = so.str(); return directory.insert(map::value_type(i_, symbol(s))).first->second; } // I'm not sure if you really need indexed things... ex Z (const int & n) { if ( n == 0 ) return ex(1); ex result(0); for (int j = 1; j <= n; j++ ) result += (symbol_factory(j)*Z(n-j)).expand(); return result; } int main(int argc, char** argv) { int arg = 3; if(argc >= 2) arg = atoi(argv[1]); cout << "Z(" << arg << ") = " << Z(arg) << endl; return 0; }