From bug-octave-request at bevo dot che dot wisc dot edu Tue Jan 19 01:22:40 1999 Subject: Multiplication of ColumnVector by RowVector in liboctave gets an error. From: Samsung Lim To: bug-octave at bevo dot che dot wisc dot edu Date: Tue, 19 Jan 1999 16:20:28 +0900 Bug report for Octave 2.0.13 configured for sparc-sun-solaris2.5.1 Description: ----------- When the liboctave library is used, the muliplication of a column vector by a row vector gets an error unless two vectors have the same dimensions. (Of course, it doesn't happen in octave, though). I think this is due to the definition of the multiplication in the "liboctave/dMatrix.cc". The following is the original source code. It checks if "len != a_len", but why? ### BEGIN CODE ### // column vector by row vector -> matrix operations Matrix operator * (const ColumnVector& v, const RowVector& a) { Matrix retval; int len = v.length (); int a_len = a.length (); if (len != a_len) gripe_nonconformant ("operator *", len, 1, 1, a_len); else { if (len != 0) { retval.resize (len, a_len); double *c = retval.fortran_vec (); F77_XFCN (dgemm, DGEMM, ("N", "N", len, a_len, 1, 1.0, v.data (), len, a.data (), 1, 0.0, c, len, 1L, 1L)); if (f77_exception_encountered) (*current_liboctave_error_handler) ("unrecoverable error in dgemm"); } } return retval; } ### END CODE ### Fix: --- Why not "len != a_len"? Shouldn't it be fixed like this? ### BEGIN CODE ### // column vector by row vector -> matrix operations Matrix operator * (const ColumnVector& v, const RowVector& a) { Matrix retval; int len = v.length (); int a_len = a.length (); if (len != 0) { retval.resize (len, a_len); double *c = retval.fortran_vec (); F77_XFCN (dgemm, DGEMM, ("N", "N", len, a_len, 1, 1.0, v.data (), len, a.data (), 1, 0.0, c, len, 1L, 1L)); if (f77_exception_encountered) (*current_liboctave_error_handler) ("unrecoverable error in dgemm"); } return retval; } ### END CODE ###