#include "iostream.h" #include #include using namespace std; #include using namespace GiNaC; int main() { // const int n = 108; //Archive is corrupted after saving and loading const int n = 107; //Works fine archive ar; symbol x("x"),y("y"),z("z"); ex foo = sin(x+2*y)+3*z+41; char nme[10]; for (int i = 0; i < n; i++) { sprintf(nme,"foo%d",i); ar.archive_ex(foo,nme); } //Save this archive to a file ofstream fout("test.gar"); fout << ar; fout.close(); //Reload it from file into a new archive archive ar2; ifstream fin("test.gar"); fin >> ar2; fin.close(); try{ ex ex1 = ar.unarchive_ex(lst(x,y),"foo0"); //Works fine for both cases cout << "Original archive gives " << ex1 << endl; // Fails for too large an archive with message // "expression with name 'foo0' not found in archive" ex ex2 = ar2.unarchive_ex(lst(x,y),"foo0"); cout << "Reloaded archive gives " << ex2 << endl; } catch (exception &e) { cout << e.what() << endl; } }