Hello,
i am trying to create a regular grid with the griddata function of
Plplot. I followed the example file x21.cc and the griddata documentation.
But there is a problem in my code and I don't find the reason. There is
no error message, just the message that the program is exiting with
return value -1. Nothing more.
My code:
====================================================================
plstream *pls;
pls = new plstream();
pls->init();
PLFLT *x, *y, *z;
int n = cd.count();
x = cd.get_x();
y = cd.get_y();
z = cd.get_value();
int nn = 20;
PLFLT *xg = new PLFLT[nn];
PLFLT *yg = new PLFLT[nn];
PLFLT **zg;
pls->Alloc2dGrid(&zg, nn, nn);
double step = 2*28/((double)n-1);
for(int i = 0; i < n; i++){
double val = -28 + step*(double)i;
xg[i] = val;
yg[i] = val;
}
pls->griddata(x, y, z, n, xg, nn, yg, nn, zg, GRID_DTLI, 0);
====================================================================
Is there a problem in this code?
I tried to check zg with this lines:
====================================================================
for(int i = 0; i < nn; i++){
for(int j = 0; j < nn; j++){
cout << "\t";
cout << zg[i][j];
}
cout << "\n";
}
====================================================================
Using the Debian testing/sid Plplot 5.6.1 I get an error message:
*** glibc detected *** /home/paul/dev/opsc/opsc/Debug/opsc: corrupted
double-linked list: 0x080a2fa0 ***
======= Backtrace: =========
[...]
And a big 20x20 matrix output of zeros. This is what it should be, I
suppose. But why the glibc error then?
I hope someone can help me here. Thanks very much and best regards,
Paul.
|