[Matrix-SIG] Using contiguous arrays with normal C syntax

Paul F. Dubois dubois1@llnl.gov
Mon, 1 Nov 1999 08:00:04 -0800


>     data = (double **) array->data;

Tom,

Your problem is that array->data is a double*, not a double**. C allows you
to create a two-dimensional array as an array of pointers, each pointing to
an array of data, but that isn't how Numerical does it, for efficiency
reasons.

You don't want to be multiplying by strides in your "solution". Having made
the data contiguous, treat it as if it were a one-dimensional array so the
i, j 'th component is

array->data[j + i * array->dimensions[0]]

(I'm doing this off the top of my head so I may not have remembered the name
of the dimension array correctly.)