Mercurial > hg > octave-lyh
diff src/ov-cx-mat.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 | 39930366b709 |
children | 7cbe01c21986 |
line wrap: on
line diff
--- a/src/ov-cx-mat.cc +++ b/src/ov-cx-mat.cc @@ -44,6 +44,7 @@ #include "ov-base-mat.cc" #include "ov-complex.h" #include "ov-cx-mat.h" +#include "ov-flt-cx-mat.h" #include "ov-re-mat.h" #include "ov-scalar.h" #include "pr-output.h" @@ -60,6 +61,20 @@ DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_complex_matrix, "complex matrix", "double"); +static octave_base_value * +default_numeric_demotion_function (const octave_base_value& a) +{ + CAST_CONV_ARG (const octave_complex_matrix&); + + return new octave_float_complex_matrix (v.float_complex_matrix_value ()); +} + +octave_base_value::type_conv_fcn +octave_complex_matrix::numeric_demotion_function (void) const +{ + return default_numeric_demotion_function; +} + octave_base_value * octave_complex_matrix::try_narrowing_conversion (void) { @@ -142,6 +157,28 @@ return retval; } +float +octave_complex_matrix::float_value (bool force_conversion) const +{ + float retval = lo_ieee_float_nan_value (); + + if (! force_conversion) + gripe_implicit_conversion ("Octave:imag-to-real", + "complex matrix", "real scalar"); + + if (rows () > 0 && columns () > 0) + { + gripe_implicit_conversion ("Octave:array-as-scalar", + "complex matrix", "real scalar"); + + retval = std::real (matrix (0, 0)); + } + else + gripe_invalid_conversion ("complex matrix", "real scalar"); + + return retval; +} + Matrix octave_complex_matrix::matrix_value (bool force_conversion) const { @@ -156,6 +193,20 @@ return retval; } +FloatMatrix +octave_complex_matrix::float_matrix_value (bool force_conversion) const +{ + FloatMatrix retval; + + if (! force_conversion) + gripe_implicit_conversion ("Octave:imag-to-real", + "complex matrix", "real matrix"); + + retval = ::real (matrix.matrix_value ()); + + return retval; +} + Complex octave_complex_matrix::complex_value (bool) const { @@ -176,12 +227,38 @@ return retval; } +FloatComplex +octave_complex_matrix::float_complex_value (bool) const +{ + float tmp = lo_ieee_float_nan_value (); + + FloatComplex retval (tmp, tmp); + + if (rows () > 0 && columns () > 0) + { + gripe_implicit_conversion ("Octave:array-as-scalar", + "complex matrix", "complex scalar"); + + retval = matrix (0, 0); + } + else + gripe_invalid_conversion ("complex matrix", "complex scalar"); + + return retval; +} + ComplexMatrix octave_complex_matrix::complex_matrix_value (bool) const { return matrix.matrix_value (); } +FloatComplexMatrix +octave_complex_matrix::float_complex_matrix_value (bool) const +{ + return FloatComplexMatrix (matrix.matrix_value ()); +} + charNDArray octave_complex_matrix::char_array_value (bool frc_str_conv) const { @@ -202,6 +279,12 @@ return retval; } +FloatComplexNDArray +octave_complex_matrix::float_complex_array_value (bool) const +{ + return FloatComplexNDArray (matrix); +} + SparseMatrix octave_complex_matrix::sparse_matrix_value (bool force_conversion) const {