From: Dave Steffen (steffend_at_[hidden])
Date: 2001-03-12 20:32:56
Howard Hinnant writes:
> >It's not crazy to imagine *inner* and *outer*. Of course we might
> >need to use 2 separate namespaces for the different defaults of
> >plain operator* ;-(.
> This is coming completely out of the blue, and I don't yet know how
> to implement it. But terms like *inner* and *outer* can be
> limiting. Tensor notation can be very liberating. It would be
> cool if we could do something like:
> TensorIndex i, j, k, l;
> A[i][j][l] = B[i][k] * C[k][j] * D[k][l] * E[k];
> Probably just a pipe dream...
Not at all - this is more or less how Blitz++ does it, although the
syntax isn't quite as clean. It looks something like
A = sum(B(i,k) * C(k,j), k); // A_ij = B_ik * C_jk
Yes, it would be nice if your example generated code that only had
one loop (summing on k) instead of 4; but this is exactly the kind of
problem that (AFAIK) Blitz++ is trying to solve.
While it'd be really nice to implement full-blown tensor notation, I
A) most people really only use vectors and matrices, so we
don't really need higher-rank tensors right away;
B) most people really just need inner and outer products, so
if we can get those right, we're in reasonably good shape;
C) most people need _either_ inner _or_ outer products in
a given project; that is, the number of programming tasks
requiring _both_ inner _and_ outer products is fairly
I also suspect that deciding whether operator*() implements an inner
or outer product will generate a lot of heat, and either way people
won't be happy. It would be nice to allow both; there are several
mechanisms that might do the trick.
So: I'd restrict our efforts to first and second order tensors
(i.e. vectors and matrices), and settle for writing
A = B * C * D;
for the product of three matrices.
Dave Steffen Wave after wave will flow with the tide
Dept. of Physics And bury the world as it does
Colorado State University Tide after tide will flow and recede
steffend_at_[hidden] Leaving life to go on as it was...
- Peart / RUSH
"The reason that our people suffer in this way....
is that our ancestors failed to rule wisely". -General Choi, Hong Hi
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk