Mercurial > octave
diff src/DLD-FUNCTIONS/pinv.cc @ 7789:82be108cc558
First attempt at single precision tyeps
* * *
corrections to qrupdate single precision routines
* * *
prefer demotion to single over promotion to double
* * *
Add single precision support to log2 function
* * *
Trivial PROJECT file update
* * *
Cache optimized hermitian/transpose methods
* * *
Add tests for tranpose/hermitian and ChangeLog entry for new transpose code
author | David Bateman <dbateman@free.fr> |
---|---|
date | Sun, 27 Apr 2008 22:34:17 +0200 |
parents | a1dbe9d80eee |
children | c690e3772583 |
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/pinv.cc Wed May 14 18:09:56 2008 +0200 +++ b/src/DLD-FUNCTIONS/pinv.cc Sun Apr 27 22:34:17 2008 +0200 @@ -58,19 +58,6 @@ octave_value arg = args(0); - double tol = 0.0; - if (nargin == 2) - tol = args(1).double_value (); - - if (error_state) - return retval; - - if (tol < 0.0) - { - error ("pinv: tol must be greater than zero"); - return retval; - } - int arg_is_empty = empty_arg ("pinv", arg.rows (), arg.columns ()); if (arg_is_empty < 0) @@ -78,23 +65,73 @@ else if (arg_is_empty > 0) return octave_value (Matrix ()); - if (arg.is_real_type ()) + if (arg.is_single_type ()) { - Matrix m = arg.matrix_value (); + float tol = 0.0; + if (nargin == 2) + tol = args(1).float_value (); + + if (error_state) + return retval; + + if (tol < 0.0) + { + error ("pinv: tol must be greater than zero"); + return retval; + } - if (! error_state) - retval = m.pseudo_inverse (tol); - } - else if (arg.is_complex_type ()) - { - ComplexMatrix m = arg.complex_matrix_value (); + if (arg.is_real_type ()) + { + FloatMatrix m = arg.float_matrix_value (); - if (! error_state) - retval = m.pseudo_inverse (tol); + if (! error_state) + retval = m.pseudo_inverse (tol); + } + else if (arg.is_complex_type ()) + { + FloatComplexMatrix m = arg.float_complex_matrix_value (); + + if (! error_state) + retval = m.pseudo_inverse (tol); + } + else + { + gripe_wrong_type_arg ("pinv", arg); + } } else { - gripe_wrong_type_arg ("pinv", arg); + double tol = 0.0; + if (nargin == 2) + tol = args(1).double_value (); + + if (error_state) + return retval; + + if (tol < 0.0) + { + error ("pinv: tol must be greater than zero"); + return retval; + } + + if (arg.is_real_type ()) + { + Matrix m = arg.matrix_value (); + + if (! error_state) + retval = m.pseudo_inverse (tol); + } + else if (arg.is_complex_type ()) + { + ComplexMatrix m = arg.complex_matrix_value (); + + if (! error_state) + retval = m.pseudo_inverse (tol); + } + else + { + gripe_wrong_type_arg ("pinv", arg); + } } return retval;