Re: [glas] multi-dimensional arrays?
From: Ian McCulloch (ianmcc_at_[hidden])
Date: 2006-12-14 12:01:13
On Thu, 14 Dec 2006, Neal Becker wrote:
> Does glas intend to address multi-dimensional arrays?
> There seems to be a big disconnect between c++ libraries that support 1d and
> 2d arrays with various linear algebra support and libraries that support
> larger dimensionality (usually without any connection to linear algebra).
> IMO, this is really unfortunate. I think we really need either one library
> that supports both multidimensional arrays and linear algebra or 2 libraries
> that interoperate well.
The problem, as I see it, is that higher dimensional objects don't allow
for the nice notation that vectors and matrices do. Most tensor libraries
I've seen use some sort of index notation, say
a[i][j][k] = b[i][j] * c[k] + d[i][m] * e[k][l][m]
But for ordinary matrices, this is quite cumbersome. Is there a nice
notation that unifies vectors/matrices with higher dimensional tensors?
Hopefully it would not be too hard to have a tensor library where the
special cases of 1- and 2-dimensional tensors satisfy the glas vector and
matrix concepts though.
Nested vectors and matrices are a different case, these should be
supported. Much of it comes naturally, unless you go out of the way to
forbid constructing a matrix<matrix<T> >. But there does need to be some
extra functionality, for example partial transpose
A(i,j)(k,l) -> B(i,k)(j,l). I don't think this affects the core library
much (although I may be wrong) - as long as one keeps in mind that the
nested operation might need to be specified eg, for a vector of vectors,
you might want to construct the vector of 2-norms of the nested vectors,
then construct the 1-norm of that vector, as one operation, say as a
lambda expression norm_1(v, norm_2(_1)). Or maybe