# HG changeset patch # User John W. Eaton # Date 1248531961 -7200 # Node ID 4dc74edc832177b77990dd6aa4ef36dce1ae24b6 # Parent e929449b9b037408ada1cf3046632b09218a2401 avoid complex -> real conversion when constructing arrays with [] diff -r e929449b9b03 -r 4dc74edc8321 src/ChangeLog --- a/src/ChangeLog Sat Jul 25 16:22:40 2009 +0200 +++ b/src/ChangeLog Sat Jul 25 16:26:01 2009 +0200 @@ -1,3 +1,8 @@ +2009-07-24 John W. Eaton + + * 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 * DLD-FUNCTIONS/chol.cc (Fcholupdate, diff -r e929449b9b03 -r 4dc74edc8321 src/pt-mat.cc --- a/src/pt-mat.cc Sat Jul 25 16:22:40 2009 +0200 +++ b/src/pt-mat.cc Sat Jul 25 16:26:01 2009 +0200 @@ -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") {