On Wed, 29 Jun 2005, Henning Thielemann wrote: > On Wed, 29 Jun 2005, Jacques Carette wrote: > > > This is called operator overloading. It is completely harmless because > > you can tell the two * apart from their type signatures. It is a > > complete and total waste of time to use two different symbols to mean > > the same thing. > > But the multiplication in A*x already needs multi-parameter type classes. > :-)
I'm uncertain about how who want to put the different kinds of multiplication into one method, even with multi-parameter type classes. You need instances (*) :: Matrix -> Matrix -> Matrix (*) :: RowVector -> Matrix -> RowVector (*) :: Matrix -> ColumnVector -> ColumnVector (*) :: RowVector -> ColumnVector -> Scalar (*) :: ColumnVector -> RowVector -> Matrix (*) :: Scalar -> RowVector -> RowVector (*) :: RowVector -> Scalar -> RowVector (*) :: Scalar -> ColumnVector -> ColumnVector (*) :: ColumnVector -> Scalar -> ColumnVector but you have to make sure that it is not possible to write an expression which needs (*) :: Matrix -> RowVector -> RowVector Further you need transpose :: RowVector -> ColumnVector transpose :: ColumnVector -> RowVector transpose :: Matrix -> Matrix and you must forbid, say transpose :: RowVector -> RowVector Not to mention many special (linear) operators which need to be prepared for both column and row vectors, like Fourier transform, component permutation, convolution, which essentially do the same on both types. I assume that you mean with "common linear algebra idioms" transforms like the following one. (x and y are column vectors) (x * y^T)^2 = x * y^T * x * y^T = x * (y^T * x) * y^T | because y^T * x is "scalar" = (y^T * x) * (x * y^T) (Analogously this can be done with bra-ket notation, i.e. <y| and |x>, then transposition must be adjoint) Now your concerns are that this becomes too complicated if the distinction between row and column vectors is dropped and instead different operators are used? > > I should know better than to get into a discussion like this with > > someone who believes they singlehandedly know better than tens of > > thousands of mathematicians... Is the design discussion related to linear algebra for Maple documented somewhere? For Modula-3 such a discussion was recorded on video tape (then got lost :-( ) and was later edited in "Systems programming with Modula-3" by Greg Nelson. It's fun to read and very informative and I haven't seen such a discussion for other languages. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe