Mercurial > hg > octave-nkf
diff liboctave/dNDArray.cc @ 8981:ed5055b0a476
fix & simplify ndarray->matrix conversions
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sat, 14 Mar 2009 19:42:50 +0100 |
parents | d91fa4b20bbb |
children | a48fba01e4ac |
line wrap: on
line diff
--- a/liboctave/dNDArray.cc +++ b/liboctave/dNDArray.cc @@ -879,23 +879,11 @@ { Matrix retval; - int nd = ndims (); - - switch (nd) - { - case 1: - retval = Matrix (Array2<double> (*this, dimensions(0), 1)); - break; - - case 2: - retval = Matrix (Array2<double> (*this, dimensions(0), dimensions(1))); - break; - - default: - (*current_liboctave_error_handler) - ("invalid conversion of NDArray to Matrix"); - break; - } + if (ndims () == 2) + retval = Matrix (Array2<double> (*this)); + else + (*current_liboctave_error_handler) + ("invalid conversion of NDArray to Matrix"); return retval; }