|Posted by Pablo Ripollés||PermalinkReply|
Janice Caron Wrote:
> If you wanted to go even more general, you could go beyond std.matrix and head into the murky waters of std.tensor.
> Tensors are a generalisation of the progression: scalar, vector, matrix, ....
be careful with that! a matrix is an algebraic structure very different from vectors and tensors. you could say that a tensor is a generalization of a vector (a vector is a rank-1 tensor) or that a tensor is a generalization of a scalar (a scalar is a rank-0 tensor), however a matrix is a different thing. think of a matrix as a two dimensional array with several algebraic rules and operations. matrices are away to represent and operate a bunch of numbers. matrices serve to represent scalars, vectors and rank-2 tensors. mathematically speaking, matrices are higher level than arrays but lower than tensors. Tensors are "geometric" entities that are independent of the coordinate system. Tensors are much more conceptualized than plain algebraic matrices, they are a very particular tool to represent the former. if you were to expand a high rank tensor product, representing the corresponding slices with matrices and their algebra should help you do that.
IMHO when implementing mathematical concepts into the language, the A&D phase should be that given by the mathematics, its primitive conceptual design should be retained.
> Think of a scalar as a zero-dimensional array; a vector as a one dimentional array, and a matrix as a two dimentional array. A scalar is a tensor with rank zero; a vector is a tensor with rank one; a matrix is a tensor with rank two. This completely generalises for tensors of arbitrary (non negative integer) rank.
> (There is a complication though, in that you have to distinguish between contravariant and covariant indeces)
> If tensor mathematics were implemented, vectors and matrices could be trivially implemented in terms of tensors.
> See http://mathworld.wolfram.com/Tensor.html
> (That might be going a bit further than people are ever going to need
> though! :-) )
if it happens to be well implemented, i don't think so.