Mercurial > hg > octave-lojdl
changeset 12048:4dc74edc8321 release-3-2-x
avoid complex -> real conversion when constructing arrays with []
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 25 Jul 2009 16:26:01 +0200 |
parents | e929449b9b03 |
children | bf90777b58c9 |
files | src/ChangeLog src/pt-mat.cc |
diffstat | 2 files changed, 28 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2009-07-24 John W. Eaton <jwe@octave.org> + + * pt-mat.cc (DO_SINGLE_TYPE_CONCAT_NO_MUTATE): New macro. + (tree_matrix::rvalue1): Use it to avoid complex -> real conversion. + 2009-07-23 Jaroslav Hajek <highegg@gmail.com> * DLD-FUNCTIONS/chol.cc (Fcholupdate,
--- a/src/pt-mat.cc +++ b/src/pt-mat.cc @@ -41,6 +41,8 @@ #include "ov.h" #include "variables.h" +#include "ov-cx-mat.h" +#include "ov-flt-cx-mat.h" #include "ov-re-sparse.h" #include "ov-cx-sparse.h" @@ -766,12 +768,23 @@ { \ TYPE result (dv); \ \ - SINGLE_TYPE_CONCAT(TYPE, EXTRACTOR); \ + SINGLE_TYPE_CONCAT (TYPE, EXTRACTOR); \ \ retval = result; \ } \ while (0) +#define DO_SINGLE_TYPE_CONCAT_NO_MUTATE(TYPE, EXTRACTOR, OV_TYPE) \ + do \ + { \ + TYPE result (dv); \ + \ + SINGLE_TYPE_CONCAT (TYPE, EXTRACTOR); \ + \ + retval = octave_value (new OV_TYPE (result)); \ + } \ + while (0) + octave_value tree_matrix::rvalue1 (int) { @@ -874,14 +887,18 @@ if (all_real_p) DO_SINGLE_TYPE_CONCAT (SparseMatrix, sparse_matrix_value); else - DO_SINGLE_TYPE_CONCAT (SparseComplexMatrix, sparse_complex_matrix_value); + DO_SINGLE_TYPE_CONCAT_NO_MUTATE (SparseComplexMatrix, + sparse_complex_matrix_value, + octave_sparse_complex_matrix); } else { if (all_real_p) DO_SINGLE_TYPE_CONCAT (NDArray, array_value); else - DO_SINGLE_TYPE_CONCAT (ComplexNDArray, complex_array_value); + DO_SINGLE_TYPE_CONCAT_NO_MUTATE (ComplexNDArray, + complex_array_value, + octave_complex_matrix); } } else if (result_type == "single") @@ -889,8 +906,9 @@ if (all_real_p) DO_SINGLE_TYPE_CONCAT (FloatNDArray, float_array_value); else - DO_SINGLE_TYPE_CONCAT (FloatComplexNDArray, - float_complex_array_value); + DO_SINGLE_TYPE_CONCAT_NO_MUTATE (FloatComplexNDArray, + float_complex_array_value, + octave_float_complex_matrix); } else if (result_type == "char") {