tensor_test is a development/test wrapper for a proposed tensor
extension of the GSL. Some of the changes it institutes are fairly
serious, although it would be possible to implement it with less
impact.
- The gsl block is redefined so that it is (also) a gsl vector.
Before a vector was a block with an owner. Now a block is a block with
an owner, and there is no separate "vector" quantity.
- The gsl matrix is redefined so that it can have any rank from 1
(vector) to 8. It contains lower, upper, and length vectors (each of
length equal to the rank of the matrix) that contain the lower and upper
bounds of the matrix indices and the over index length. The key feature
of the matrix object is the void* matrix->mptr pointer, which can be
packed with data addresses from a block and cast to whatever type
pointer you like. This permits ALL MATRICES to be addressed in the form
m[i][j]...[l][m].
- A gsl tensor is defined to be a matrix and an associated data
block whose addresses are packed into the matrix-mptr pointer. It can
be created or freed with a single command. However, blocks and matrices
can be created and freed separately as well, and (for example) several
matrices can refer to the same block or different parts of the same
block. Freeing a matrix does not free the underlying data block;
freeing a tensor does.
At the moment, the code passes at least one elementary set of tests;
the block can be loaded as a straight vector with data elements which
can then be successfully referenced by matrix address. In verbose mode,
the test code also traces fairly explicitly the memory allocations and
freeings (which is still not a guarantee that the code cannot leak or
segvec fault). Still, it SEEMS to work out to 8th rank tensors for
fairly arbitrary index limits.