Mercurial > hg > octave-lyh
diff liboctave/dMatrix.cc @ 6162:b3c425131211
[project @ 2006-11-14 15:33:22 by jwe]
author | jwe |
---|---|
date | Tue, 14 Nov 2006 15:33:22 +0000 |
parents | ae09df27153f |
children | 3c92b8d892dd |
line wrap: on
line diff
--- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -2980,6 +2980,23 @@ // matrix by matrix -> matrix operations +/* Simple Dot Product, Matrix-Vector and Matrix-Matrix Unit tests +%!assert([1 2 3] * [ 4 ; 5 ; 6], 32, 1e-14) +%!assert([1 2 ; 3 4 ] * [5 ; 6], [17 ; 39 ], 1e-14) +%!assert([1 2 ; 3 4 ] * [5 6 ; 7 8], [19 22; 43 50], 1e-14) +*/ + +/* Test some simple identities +%!shared M, cv, rv +%! M = randn(10,10); +%! cv = randn(10,1); +%! rv = randn(1,10); +%!assert([M*cv,M*cv],M*[cv,cv],1e-14) +%!assert([rv*M;rv*M],[rv;rv]*M,1e-14) +%!assert(2*rv*cv,[rv,rv]*[cv;cv],1e-14) +*/ + + Matrix operator * (const Matrix& m, const Matrix& a) {