Large archive problem
Will Woods
will at brain.ncl.ac.uk
Fri Mar 30 17:20:18 CEST 2001
Hi,
I am working with large matrices (~100x100) and had trouble with restoring
archives of them. I wrote the attached test program which just adds the
same expression to an archive n times (with a unique name each time).
For any n, the expression can always be retrieved from the original
archive. But reloading it from file into a new archive object only
succeeds for n<108 (in this case - other size expressions have different
limits).
Great package though. Our problem solution went from several hours under
Macsyma to just 36 seconds with GiNaC!
Will
System:
GiNaC 0.8.0
CLN 1.1.0
Linux Mandrake 7.2
AMD 700Mhz 128Mb
-------------- next part --------------
#include "iostream.h"
#include <cstdio>
#include <fstream>
using namespace std;
#include <ginac/ginac.h>
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; }
}
More information about the GiNaC-devel
mailing list