On Thu, 7 Jul 2005, David Roundy wrote: > Also note that if you have several vectors x for which you want to compute > the dot product with metric A, and if you want to do this efficiently, > you'll have to convert your list of vectors into a matrix anyways. Writing > functions of vectors instead as functions of 1xN matrices allows them to be > efficiently applied to multiple vectors simultaneously, provided they are > written carefully.
Btw. it is interesting that "source code efficiency" differs from runtime efficiency for matrix operations: a*b*c*v where a, b, c are square matrices and v is a column vector/matrix. This expression is interpreted as ((a*b)*c)*v and it need cubic time to multiply matrices. In contrast to that a*(b*(c*v)) needs only quadratic time. If we would use matrices as what they are invented for, namely as representations of linear operators, this efficiency leak would not occur: mulVec a $ mulVec b $ mulVec c v (Read mulVec as the mapping from a matrix to the linear operator it represents.) _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe