Mercurial > hg > octave-shane
changeset 8650:a1ae2aae903e
abs,real,imag,conj: use code from mx-inlines rather than the generic map
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 02 Feb 2009 15:35:32 +0100 |
parents | e50b44b75891 |
children | ea8e65ca234f |
files | liboctave/CMatrix.cc liboctave/CMatrix.h liboctave/CNDArray.cc liboctave/CNDArray.h liboctave/ChangeLog liboctave/dMatrix.cc liboctave/dMatrix.h liboctave/dNDArray.cc liboctave/dNDArray.h liboctave/fCMatrix.cc liboctave/fCMatrix.h liboctave/fCNDArray.cc liboctave/fCNDArray.h liboctave/fMatrix.cc liboctave/fMatrix.h liboctave/fNDArray.cc liboctave/fNDArray.h liboctave/mx-inlines.cc src/ChangeLog src/ov-cx-mat.cc src/ov-flt-cx-mat.cc src/ov-flt-re-diag.cc src/ov-flt-re-mat.cc src/ov-re-diag.cc src/ov-re-mat.cc |
diffstat | 25 files changed, 198 insertions(+), 150 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/CMatrix.cc +++ b/liboctave/CMatrix.cc @@ -908,12 +908,8 @@ ComplexMatrix conj (const ComplexMatrix& a) { - octave_idx_type a_len = a.length (); - ComplexMatrix retval; - if (a_len > 0) - retval = ComplexMatrix (mx_inline_conj_dup (a.data (), a_len), - a.rows (), a.cols ()); - return retval; + return ComplexMatrix (mx_inline_conj_dup (a.data (), a.length ()), + a.rows (), a.cols ()); } // resize is the destructive equivalent for this one @@ -3308,16 +3304,8 @@ Matrix ComplexMatrix::abs (void) const { - octave_idx_type nr = rows (); - octave_idx_type nc = cols (); - - Matrix retval (nr, nc); - - for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = 0; i < nr; i++) - retval (i, j) = std::abs (elem (i, j)); - - return retval; + return Matrix (mx_inline_cabs_dup (data (), length ()), + rows (), cols ()); } ComplexMatrix
--- a/liboctave/CMatrix.h +++ b/liboctave/CMatrix.h @@ -373,6 +373,8 @@ ComplexMatrix (Complex *d, octave_idx_type r, octave_idx_type c) : MArray2<Complex> (d, r, c) { } }; +extern OCTAVE_API ComplexMatrix conj (const ComplexMatrix& a); + // column vector by row vector -> matrix operations extern OCTAVE_API ComplexMatrix
--- a/liboctave/CNDArray.cc +++ b/liboctave/CNDArray.cc @@ -890,14 +890,15 @@ NDArray ComplexNDArray::abs (void) const { - NDArray retval (dims ()); - - octave_idx_type nel = nelem (); + return NDArray (mx_inline_cabs_dup (data (), length ()), + dims ()); +} - for (octave_idx_type i = 0; i < nel; i++) - retval(i) = std::abs (elem (i)); - - return retval; +ComplexNDArray +conj (const ComplexNDArray& a) +{ + return ComplexNDArray (mx_inline_conj_dup (a.data (), a.length ()), + a.dims ()); } ComplexNDArray&
--- a/liboctave/CNDArray.h +++ b/liboctave/CNDArray.h @@ -91,6 +91,8 @@ NDArray abs (void) const; + friend ComplexNDArray conj (const ComplexNDArray& a); + ComplexNDArray fourier (int dim = 1) const; ComplexNDArray ifourier (int dim = 1) const; @@ -137,6 +139,8 @@ : MArrayN<Complex> (d, dv) { } }; +extern OCTAVE_API ComplexNDArray conj (const ComplexNDArray& a); + extern OCTAVE_API ComplexNDArray min (const Complex& c, const ComplexNDArray& m); extern OCTAVE_API ComplexNDArray min (const ComplexNDArray& m, const Complex& c); extern OCTAVE_API ComplexNDArray min (const ComplexNDArray& a, const ComplexNDArray& b);
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,21 @@ +2009-02-02 Jaroslav Hajek <highegg@gmail.com> + + * mx-inlines.cc (mx_inline_fabs_dup, mx_inline_cabs_dup): New funcs. + + * dMatrix.cc (real, imag, Matrix::abs): Simplify. + * fMatrix.cc (real, imag, FloatMatrix::abs): Simplify. + * CMatrix.cc (ComplexMatrix::abs, ComplexMatrix::conj): Simplify. + * fCMatrix.cc (FloatComplexMatrix::abs, FloatComplexMatrix::conj): Simplify. + + * CMatrix.h, fCMatrix.h (conj): Add missing decl. + + * dNDArray.cc (real, imag, NDArray::abs): Simplify. + * fNDArray.cc (real, imag, FloatNDArray::abs): Simplify. + * CNDArray.cc (ComplexNDArray::abs, ComplexNDArray::conj): Simplify. + * fCNDArray.cc (FloatComplexNDArray::abs, FloatComplexNDArray::conj): Simplify. + + * CMatrix.h, fCMatrix.h (conj): New decl. + 2009-01-29 John W. Eaton <jwe@octave.org> * intNDArray.h (intNDArray<T>:any_element_is_nan): New function.
--- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -583,23 +583,15 @@ Matrix real (const ComplexMatrix& a) { - octave_idx_type a_len = a.length (); - Matrix retval; - if (a_len > 0) - retval = Matrix (mx_inline_real_dup (a.data (), a_len), - a.rows (), a.cols ()); - return retval; + return Matrix (mx_inline_real_dup (a.data (), a.length ()), + a.rows (), a.cols ()); } Matrix imag (const ComplexMatrix& a) { - octave_idx_type a_len = a.length (); - Matrix retval; - if (a_len > 0) - retval = Matrix (mx_inline_imag_dup (a.data (), a_len), - a.rows (), a.cols ()); - return retval; + return Matrix (mx_inline_imag_dup (a.data (), a.length ()), + a.rows (), a.cols ()); } Matrix @@ -2847,16 +2839,8 @@ Matrix Matrix::abs (void) const { - octave_idx_type nr = rows (); - octave_idx_type nc = cols (); - - Matrix retval (nr, nc); - - for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = 0; i < nr; i++) - retval (i, j) = fabs (elem (i, j)); - - return retval; + return Matrix (mx_inline_fabs_dup (data (), length ()), + rows (), cols ()); } Matrix
--- a/liboctave/dMatrix.h +++ b/liboctave/dMatrix.h @@ -104,6 +104,8 @@ friend OCTAVE_API Matrix real (const ComplexMatrix& a); friend OCTAVE_API Matrix imag (const ComplexMatrix& a); + friend class ComplexMatrix; + Matrix transpose (void) const { return MArray2<double>::transpose (); } // resize is the destructive equivalent for this one
--- a/liboctave/dNDArray.cc +++ b/liboctave/dNDArray.cc @@ -942,21 +942,15 @@ NDArray real (const ComplexNDArray& a) { - octave_idx_type a_len = a.length (); - NDArray retval; - if (a_len > 0) - retval = NDArray (mx_inline_real_dup (a.data (), a_len), a.dims ()); - return retval; + return NDArray (mx_inline_real_dup (a.data (), a.length ()), + a.dims ()); } NDArray imag (const ComplexNDArray& a) { - octave_idx_type a_len = a.length (); - NDArray retval; - if (a_len > 0) - retval = NDArray (mx_inline_imag_dup (a.data (), a_len), a.dims ()); - return retval; + return NDArray (mx_inline_imag_dup (a.data (), a.length ()), + a.dims ()); } NDArray& @@ -976,14 +970,8 @@ NDArray NDArray::abs (void) const { - NDArray retval (dims ()); - - octave_idx_type nel = nelem (); - - for (octave_idx_type i = 0; i < nel; i++) - retval(i) = fabs (elem (i)); - - return retval; + return NDArray (mx_inline_fabs_dup (data (), length ()), + dims ()); } Matrix
--- a/liboctave/dNDArray.h +++ b/liboctave/dNDArray.h @@ -114,6 +114,8 @@ friend OCTAVE_API NDArray real (const ComplexNDArray& a); friend OCTAVE_API NDArray imag (const ComplexNDArray& a); + friend class ComplexNDArray; + Matrix matrix_value (void) const; NDArray squeeze (void) const { return MArrayN<double>::squeeze (); }
--- a/liboctave/fCMatrix.cc +++ b/liboctave/fCMatrix.cc @@ -902,12 +902,8 @@ FloatComplexMatrix conj (const FloatComplexMatrix& a) { - octave_idx_type a_len = a.length (); - FloatComplexMatrix retval; - if (a_len > 0) - retval = FloatComplexMatrix (mx_inline_conj_dup (a.data (), a_len), - a.rows (), a.cols ()); - return retval; + return FloatComplexMatrix (mx_inline_conj_dup (a.data (), a.length ()), + a.rows (), a.cols ()); } // resize is the destructive equivalent for this one @@ -3342,16 +3338,8 @@ FloatMatrix FloatComplexMatrix::abs (void) const { - octave_idx_type nr = rows (); - octave_idx_type nc = cols (); - - FloatMatrix retval (nr, nc); - - for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = 0; i < nr; i++) - retval (i, j) = std::abs (elem (i, j)); - - return retval; + return FloatMatrix (mx_inline_cabs_dup (data (), length ()), + rows (), cols ()); } FloatComplexMatrix
--- a/liboctave/fCMatrix.h +++ b/liboctave/fCMatrix.h @@ -373,6 +373,8 @@ FloatComplexMatrix (FloatComplex *d, octave_idx_type r, octave_idx_type c) : MArray2<FloatComplex> (d, r, c) { } }; +extern OCTAVE_API FloatComplexMatrix conj (const FloatComplexMatrix& a); + // column vector by row vector -> matrix operations extern OCTAVE_API FloatComplexMatrix
--- a/liboctave/fCNDArray.cc +++ b/liboctave/fCNDArray.cc @@ -884,14 +884,15 @@ FloatNDArray FloatComplexNDArray::abs (void) const { - FloatNDArray retval (dims ()); - - octave_idx_type nel = nelem (); + return FloatNDArray (mx_inline_cabs_dup (data (), length ()), + dims ()); +} - for (octave_idx_type i = 0; i < nel; i++) - retval(i) = std::abs (elem (i)); - - return retval; +FloatComplexNDArray +conj (const FloatComplexNDArray& a) +{ + return FloatComplexNDArray (mx_inline_conj_dup (a.data (), a.length ()), + a.dims ()); } FloatComplexNDArray&
--- a/liboctave/fCNDArray.h +++ b/liboctave/fCNDArray.h @@ -91,6 +91,8 @@ FloatNDArray abs (void) const; + friend FloatComplexNDArray conj (const FloatComplexNDArray& a); + FloatComplexNDArray fourier (int dim = 1) const; FloatComplexNDArray ifourier (int dim = 1) const; @@ -137,6 +139,8 @@ : MArrayN<FloatComplex> (d, dv) { } }; +extern OCTAVE_API FloatComplexNDArray conj (const FloatComplexNDArray& a); + extern OCTAVE_API FloatComplexNDArray min (const FloatComplex& c, const FloatComplexNDArray& m); extern OCTAVE_API FloatComplexNDArray min (const FloatComplexNDArray& m, const FloatComplex& c); extern OCTAVE_API FloatComplexNDArray min (const FloatComplexNDArray& a, const FloatComplexNDArray& b);
--- a/liboctave/fMatrix.cc +++ b/liboctave/fMatrix.cc @@ -582,23 +582,15 @@ FloatMatrix real (const FloatComplexMatrix& a) { - octave_idx_type a_len = a.length (); - FloatMatrix retval; - if (a_len > 0) - retval = FloatMatrix (mx_inline_real_dup (a.data (), a_len), - a.rows (), a.cols ()); - return retval; + return FloatMatrix (mx_inline_real_dup (a.data (), a.length ()), + a.rows (), a.cols ()); } FloatMatrix imag (const FloatComplexMatrix& a) { - octave_idx_type a_len = a.length (); - FloatMatrix retval; - if (a_len > 0) - retval = FloatMatrix (mx_inline_imag_dup (a.data (), a_len), - a.rows (), a.cols ()); - return retval; + return FloatMatrix (mx_inline_imag_dup (a.data (), a.length ()), + a.rows (), a.cols ()); } FloatMatrix @@ -2846,16 +2838,8 @@ FloatMatrix FloatMatrix::abs (void) const { - octave_idx_type nr = rows (); - octave_idx_type nc = cols (); - - FloatMatrix retval (nr, nc); - - for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = 0; i < nr; i++) - retval (i, j) = fabs (elem (i, j)); - - return retval; + return FloatMatrix (mx_inline_fabs_dup (data (), length ()), + rows (), cols ()); } FloatMatrix
--- a/liboctave/fMatrix.h +++ b/liboctave/fMatrix.h @@ -105,6 +105,8 @@ friend OCTAVE_API FloatMatrix real (const FloatComplexMatrix& a); friend OCTAVE_API FloatMatrix imag (const FloatComplexMatrix& a); + friend class FloatComplexMatrix; + FloatMatrix transpose (void) const { return MArray2<float>::transpose (); } // resize is the destructive equivalent for this one
--- a/liboctave/fNDArray.cc +++ b/liboctave/fNDArray.cc @@ -897,21 +897,15 @@ FloatNDArray real (const FloatComplexNDArray& a) { - octave_idx_type a_len = a.length (); - FloatNDArray retval; - if (a_len > 0) - retval = FloatNDArray (mx_inline_real_dup (a.data (), a_len), a.dims ()); - return retval; + return FloatNDArray (mx_inline_real_dup (a.data (), a.length ()), + a.dims ()); } FloatNDArray imag (const FloatComplexNDArray& a) { - octave_idx_type a_len = a.length (); - FloatNDArray retval; - if (a_len > 0) - retval = FloatNDArray (mx_inline_imag_dup (a.data (), a_len), a.dims ()); - return retval; + return FloatNDArray (mx_inline_imag_dup (a.data (), a.length ()), + a.dims ()); } FloatNDArray& @@ -931,14 +925,8 @@ FloatNDArray FloatNDArray::abs (void) const { - FloatNDArray retval (dims ()); - - octave_idx_type nel = nelem (); - - for (octave_idx_type i = 0; i < nel; i++) - retval(i) = fabs (elem (i)); - - return retval; + return FloatNDArray (mx_inline_fabs_dup (data (), length ()), + dims ()); } Matrix
--- a/liboctave/fNDArray.h +++ b/liboctave/fNDArray.h @@ -111,6 +111,8 @@ friend OCTAVE_API FloatNDArray real (const FloatComplexNDArray& a); friend OCTAVE_API FloatNDArray imag (const FloatComplexNDArray& a); + friend class FloatComplexNDArray; + Matrix matrix_value (void) const; FloatNDArray squeeze (void) const { return MArrayN<float>::squeeze (); }
--- a/liboctave/mx-inlines.cc +++ b/liboctave/mx-inlines.cc @@ -25,6 +25,7 @@ #define octave_mx_inlines_h 1 #include <cstddef> +#include <cmath> #include "quit.h" @@ -261,6 +262,8 @@ OP_DUP_FCN (-, mx_inline_change_sign, double, double) OP_DUP_FCN (-, mx_inline_change_sign, Complex, Complex) +OP_DUP_FCN (std::abs, mx_inline_fabs_dup, double, double) +OP_DUP_FCN (std::abs, mx_inline_cabs_dup, double, Complex) OP_DUP_FCN (real, mx_inline_real_dup, double, Complex) OP_DUP_FCN (imag, mx_inline_imag_dup, double, Complex) OP_DUP_FCN (conj, mx_inline_conj_dup, Complex, Complex) @@ -273,6 +276,8 @@ OP_DUP_FCN (-, mx_inline_change_sign, float, float) OP_DUP_FCN (-, mx_inline_change_sign, FloatComplex, FloatComplex) +OP_DUP_FCN (std::abs, mx_inline_fabs_dup, float, float) +OP_DUP_FCN (std::abs, mx_inline_cabs_dup, float, FloatComplex) OP_DUP_FCN (real, mx_inline_real_dup, float, FloatComplex) OP_DUP_FCN (imag, mx_inline_imag_dup, float, FloatComplex) OP_DUP_FCN (conj, mx_inline_conj_dup, FloatComplex, FloatComplex)
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2009-02-02 Jaroslav Hajek <highegg@gmail.com> + + * ov-re-mat.cc (octave_matrix::abs, octave_matrix::real, + octave_matrix::imag, octave_matrix::conj): Use special code. + * ov-flt-re-mat.cc (octave_float_matrix::abs, octave_float_matrix::real, + octave_float_matrix::imag, octave_float_matrix::conj): Use special code. + * ov-cx-mat.cc (octave_complex_matrix::abs, octave_complex_matrix::real, + octave_complex_matrix::imag, octave_complex_matrix::conj): Use special code. + * ov-flt-cx-mat.cc (octave_float_complex_matrix::abs, octave_float_complex_matrix::real, + octave_float_complex_matrix::imag, octave_float_complex_matrix::conj): Use special code. + 2009-01-30 Jaroslav Hajek <highegg@gmail.com> * DLD-FUNCTIONS/lookup.cc (Flookup): Add missing check.
--- a/src/ov-cx-mat.cc +++ b/src/ov-cx-mat.cc @@ -850,12 +850,36 @@ } \ } +// The fast mappers. +octave_value +octave_complex_matrix::abs (void) const +{ + return matrix.abs (); +} + +octave_value +octave_complex_matrix::real (void) const +{ + return ::real (matrix); +} + +octave_value +octave_complex_matrix::conj (void) const +{ + return ::conj (matrix); +} + +octave_value +octave_complex_matrix::imag (void) const +{ + return ::imag (matrix); +} + DARRAY_MAPPER (erf, NDArray::dmapper, ::erf) DARRAY_MAPPER (erfc, NDArray::dmapper, ::erfc) DARRAY_MAPPER (gamma, NDArray::dmapper, xgamma) CD_ARRAY_MAPPER (lgamma, xlgamma, xlgamma, 0.0, octave_Inf) -ARRAY_MAPPER (abs, ComplexNDArray::dmapper, xabs) ARRAY_MAPPER (acos, ComplexNDArray::cmapper, ::acos) ARRAY_MAPPER (acosh, ComplexNDArray::cmapper, ::acosh) ARRAY_MAPPER (angle, ComplexNDArray::dmapper, std::arg) @@ -865,19 +889,16 @@ ARRAY_MAPPER (atan, ComplexNDArray::cmapper, ::atan) ARRAY_MAPPER (atanh, ComplexNDArray::cmapper, ::atanh) ARRAY_MAPPER (ceil, ComplexNDArray::cmapper, ::ceil) -ARRAY_MAPPER (conj, ComplexNDArray::cmapper, std::conj) ARRAY_MAPPER (cos, ComplexNDArray::cmapper, std::cos) ARRAY_MAPPER (cosh, ComplexNDArray::cmapper, std::cosh) ARRAY_MAPPER (exp, ComplexNDArray::cmapper, std::exp) ARRAY_MAPPER (expm1, ComplexNDArray::cmapper, ::expm1) ARRAY_MAPPER (fix, ComplexNDArray::cmapper, ::fix) ARRAY_MAPPER (floor, ComplexNDArray::cmapper, ::floor) -ARRAY_MAPPER (imag, ComplexNDArray::dmapper, ximag) ARRAY_MAPPER (log, ComplexNDArray::cmapper, std::log) ARRAY_MAPPER (log2, ComplexNDArray::cmapper, xlog2) ARRAY_MAPPER (log10, ComplexNDArray::cmapper, std::log10) ARRAY_MAPPER (log1p, ComplexNDArray::cmapper, ::log1p) -ARRAY_MAPPER (real, ComplexNDArray::dmapper, xreal) ARRAY_MAPPER (round, ComplexNDArray::cmapper, xround) ARRAY_MAPPER (roundb, ComplexNDArray::cmapper, xroundb) ARRAY_MAPPER (signum, ComplexNDArray::cmapper, ::signum)
--- a/src/ov-flt-cx-mat.cc +++ b/src/ov-flt-cx-mat.cc @@ -817,12 +817,36 @@ } \ } +// The fast mappers. +octave_value +octave_float_complex_matrix::abs (void) const +{ + return matrix.abs (); +} + +octave_value +octave_float_complex_matrix::real (void) const +{ + return ::real (matrix); +} + +octave_value +octave_float_complex_matrix::conj (void) const +{ + return ::conj (matrix); +} + +octave_value +octave_float_complex_matrix::imag (void) const +{ + return ::imag (matrix); +} + DARRAY_MAPPER (erf, FloatNDArray::dmapper, ::erff) DARRAY_MAPPER (erfc, FloatNDArray::dmapper, ::erfcf) DARRAY_MAPPER (gamma, FloatNDArray::dmapper, xgamma) CD_ARRAY_MAPPER (lgamma, xlgamma, xlgamma, 0.0, octave_Inf) -ARRAY_MAPPER (abs, FloatComplexNDArray::dmapper, xabs) ARRAY_MAPPER (acos, FloatComplexNDArray::cmapper, ::acos) ARRAY_MAPPER (acosh, FloatComplexNDArray::cmapper, ::acosh) ARRAY_MAPPER (angle, FloatComplexNDArray::dmapper, std::arg) @@ -832,19 +856,16 @@ ARRAY_MAPPER (atan, FloatComplexNDArray::cmapper, ::atan) ARRAY_MAPPER (atanh, FloatComplexNDArray::cmapper, ::atanh) ARRAY_MAPPER (ceil, FloatComplexNDArray::cmapper, ::ceil) -ARRAY_MAPPER (conj, FloatComplexNDArray::cmapper, std::conj) ARRAY_MAPPER (cos, FloatComplexNDArray::cmapper, std::cos) ARRAY_MAPPER (cosh, FloatComplexNDArray::cmapper, std::cosh) ARRAY_MAPPER (exp, FloatComplexNDArray::cmapper, std::exp) ARRAY_MAPPER (expm1, FloatComplexNDArray::cmapper, ::expm1f) ARRAY_MAPPER (fix, FloatComplexNDArray::cmapper, ::fix) ARRAY_MAPPER (floor, FloatComplexNDArray::cmapper, ::floor) -ARRAY_MAPPER (imag, FloatComplexNDArray::dmapper, ximag) ARRAY_MAPPER (log, FloatComplexNDArray::cmapper, std::log) ARRAY_MAPPER (log2, FloatComplexNDArray::cmapper, xlog2) ARRAY_MAPPER (log10, FloatComplexNDArray::cmapper, std::log10) ARRAY_MAPPER (log1p, FloatComplexNDArray::cmapper, ::log1pf) -ARRAY_MAPPER (real, FloatComplexNDArray::dmapper, xreal) ARRAY_MAPPER (round, FloatComplexNDArray::cmapper, xround) ARRAY_MAPPER (roundb, FloatComplexNDArray::cmapper, xroundb) ARRAY_MAPPER (signum, FloatComplexNDArray::cmapper, ::signum)
--- a/src/ov-flt-re-diag.cc +++ b/src/ov-flt-re-diag.cc @@ -111,7 +111,7 @@ octave_value octave_float_diag_matrix::imag (void) const { - return DiagMatrix (matrix.rows (), matrix.cols ()); + return DiagMatrix (matrix.rows (), matrix.cols (), 0.0f); } bool
--- a/src/ov-flt-re-mat.cc +++ b/src/ov-flt-re-mat.cc @@ -742,17 +742,35 @@ : octave_value (matrix.map (dmap)))); \ } -static float -xconj (float x) +// The fast mappers. +octave_value +octave_float_matrix::abs (void) const +{ + return matrix.abs (); +} + +octave_value +octave_float_matrix::real (void) const { - return x; + return matrix; +} + +octave_value +octave_float_matrix::conj (void) const +{ + return matrix; +} + +octave_value +octave_float_matrix::imag (void) const +{ + return FloatNDArray (matrix.dims (), 0.0); } ARRAY_MAPPER (erf, FloatNDArray::dmapper, ::erff) ARRAY_MAPPER (erfc, FloatNDArray::dmapper, ::erfcf) ARRAY_MAPPER (gamma, FloatNDArray::dmapper, xgamma) CD_ARRAY_MAPPER (lgamma, xlgamma, xlgamma, 0.0, octave_Float_Inf) -ARRAY_MAPPER (abs, FloatNDArray::dmapper, ::fabsf) ARRAY_MAPPER (acos, FloatNDArray::dmapper, ::acosf) CD_ARRAY_MAPPER (acosh, ::acoshf, ::acosh, 1.0, octave_Float_Inf) ARRAY_MAPPER (angle, FloatNDArray::dmapper, ::arg) @@ -762,19 +780,16 @@ ARRAY_MAPPER (atan, FloatNDArray::dmapper, ::atanf) CD_ARRAY_MAPPER (atanh, ::atanhf, ::atanh, -1.0, 1.0) ARRAY_MAPPER (ceil, FloatNDArray::dmapper, ::ceilf) -ARRAY_MAPPER (conj, FloatNDArray::dmapper, xconj) ARRAY_MAPPER (cos, FloatNDArray::dmapper, ::cosf) ARRAY_MAPPER (cosh, FloatNDArray::dmapper, ::coshf) ARRAY_MAPPER (exp, FloatNDArray::dmapper, ::expf) ARRAY_MAPPER (expm1, FloatNDArray::dmapper, ::expm1f) ARRAY_MAPPER (fix, FloatNDArray::dmapper, ::fix) ARRAY_MAPPER (floor, FloatNDArray::dmapper, ::floorf) -ARRAY_MAPPER (imag, FloatNDArray::dmapper, ::imag) CD_ARRAY_MAPPER (log, ::logf, std::log, 0.0, octave_Float_Inf) CD_ARRAY_MAPPER (log2, xlog2, xlog2, 0.0, octave_Float_Inf) CD_ARRAY_MAPPER (log10, ::log10f, std::log10, 0.0, octave_Float_Inf) CD_ARRAY_MAPPER (log1p, ::log1pf, ::log1pf, -1.0, octave_Float_Inf) -ARRAY_MAPPER (real, FloatNDArray::dmapper, ::real) ARRAY_MAPPER (round, FloatNDArray::dmapper, xround) ARRAY_MAPPER (roundb, FloatNDArray::dmapper, xroundb) ARRAY_MAPPER (signum, FloatNDArray::dmapper, ::signum)
--- a/src/ov-re-diag.cc +++ b/src/ov-re-diag.cc @@ -126,7 +126,7 @@ octave_value octave_diag_matrix::imag (void) const { - return DiagMatrix (matrix.rows (), matrix.cols ()); + return DiagMatrix (matrix.rows (), matrix.cols (), 0.0); } bool
--- a/src/ov-re-mat.cc +++ b/src/ov-re-mat.cc @@ -769,17 +769,35 @@ : octave_value (matrix.map (dmap)))); \ } -static double -xconj (double x) +// The fast mappers. +octave_value +octave_matrix::abs (void) const +{ + return matrix.abs (); +} + +octave_value +octave_matrix::real (void) const { - return x; + return matrix; +} + +octave_value +octave_matrix::conj (void) const +{ + return matrix; +} + +octave_value +octave_matrix::imag (void) const +{ + return NDArray (matrix.dims (), 0.0); } ARRAY_MAPPER (erf, NDArray::dmapper, ::erf) ARRAY_MAPPER (erfc, NDArray::dmapper, ::erfc) ARRAY_MAPPER (gamma, NDArray::dmapper, xgamma) CD_ARRAY_MAPPER (lgamma, xlgamma, xlgamma, 0.0, octave_Inf) -ARRAY_MAPPER (abs, NDArray::dmapper, ::fabs) ARRAY_MAPPER (acos, NDArray::dmapper, ::acos) CD_ARRAY_MAPPER (acosh, ::acosh, ::acosh, 1.0, octave_Inf) ARRAY_MAPPER (angle, NDArray::dmapper, ::arg) @@ -789,19 +807,16 @@ ARRAY_MAPPER (atan, NDArray::dmapper, ::atan) CD_ARRAY_MAPPER (atanh, ::atanh, ::atanh, -1.0, 1.0) ARRAY_MAPPER (ceil, NDArray::dmapper, ::ceil) -ARRAY_MAPPER (conj, NDArray::dmapper, xconj) ARRAY_MAPPER (cos, NDArray::dmapper, ::cos) ARRAY_MAPPER (cosh, NDArray::dmapper, ::cosh) ARRAY_MAPPER (exp, NDArray::dmapper, ::exp) ARRAY_MAPPER (expm1, NDArray::dmapper, ::expm1) ARRAY_MAPPER (fix, NDArray::dmapper, ::fix) ARRAY_MAPPER (floor, NDArray::dmapper, ::floor) -ARRAY_MAPPER (imag, NDArray::dmapper, ::imag) CD_ARRAY_MAPPER (log, ::log, std::log, 0.0, octave_Inf) CD_ARRAY_MAPPER (log2, xlog2, xlog2, 0.0, octave_Inf) CD_ARRAY_MAPPER (log10, ::log10, std::log10, 0.0, octave_Inf) CD_ARRAY_MAPPER (log1p, ::log1p, ::log1p, -1.0, octave_Inf) -ARRAY_MAPPER (real, NDArray::dmapper, ::real) ARRAY_MAPPER (round, NDArray::dmapper, xround) ARRAY_MAPPER (roundb, NDArray::dmapper, xroundb) ARRAY_MAPPER (signum, NDArray::dmapper, ::signum)