Mercurial > octave
changeset 22274:edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
* lo-mappers.h (arg, conj, imag, real): Provide overloads for real
arguments in octave::math namespace instead of importing them from
std namespace.
* __ichol__.cc, ls-mat4.cc, ls-mat5.cc, __eigs__.cc, ov-complex.cc,
ov-complex.h, ov-cx-mat.cc, ov-cx-sparse.cc, ov-flt-complex.cc,
ov-flt-complex.h, ov-flt-cx-mat.cc, CMatrix.cc, CNDArray.cc,
CSparse.cc, MatrixType.cc, dMatrix.cc, dSparse.cc, fCMatrix.cc,
fCNDArray.cc, fMatrix.cc, chol.cc, eigs-base.cc, lo-mappers.cc,
lo-specfun.cc, sparse-qr.cc: Update for arg, conj, imag, and real
functions in octave::math namespace. Prefer member function versions
of real and imag for simple variables. Use std:: namespace versions
directly for known complex values. Use octave::math namespace
versions otherwise
line wrap: on
line diff
--- a/libinterp/corefcn/__ichol__.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/libinterp/corefcn/__ichol__.cc Thu Aug 11 16:26:56 2016 -0400 @@ -35,11 +35,11 @@ Complex ichol_mult_complex (Complex a, Complex b) { #if defined (HAVE_CXX_COMPLEX_SETTERS) - b.imag (-std::imag (b)); + b.imag (-b.imag ()); #elif defined (HAVE_CXX_COMPLEX_REFERENCE_ACCESSORS) - b.imag () = -std::imag (b); + b.imag () = -b.imag (); #else - b = std::conj (b); + b = b.conj (); #endif return a * b; }
--- a/libinterp/corefcn/ls-mat4.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/libinterp/corefcn/ls-mat4.cc Thu Aug 11 16:26:56 2016 -0400 @@ -512,13 +512,13 @@ os.write (reinterpret_cast<const char *> (&ds), 8); for (octave_idx_type i = 0; i < len; i++) - dtmp[i] = std::real (m.data (i)); + dtmp[i] = octave::math::real (m.data (i)); os.write (reinterpret_cast<const char *> (dtmp), n_bytes); ds = 0.; os.write (reinterpret_cast<const char *> (&ds), 8); for (octave_idx_type i = 0; i < len; i++) - dtmp[i] = std::imag (m.data (i)); + dtmp[i] = octave::math::imag (m.data (i)); os.write (reinterpret_cast<const char *> (dtmp), n_bytes); os.write (reinterpret_cast<const char *> (&ds), 8); }
--- a/libinterp/corefcn/ls-mat5.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/libinterp/corefcn/ls-mat5.cc Thu Aug 11 16:26:56 2016 -0400 @@ -2015,12 +2015,12 @@ OCTAVE_LOCAL_BUFFER (double, tmp, nel); for (octave_idx_type i = 1; i < nel; i++) - tmp[i] = std::real (val[i]); + tmp[i] = octave::math::real (val[i]); ret = save_mat5_array_length (tmp, nel, save_as_floats); for (octave_idx_type i = 1; i < nel; i++) - tmp[i] = std::imag (val[i]); + tmp[i] = octave::math::imag (val[i]); ret += save_mat5_array_length (tmp, nel, save_as_floats); @@ -2036,12 +2036,12 @@ OCTAVE_LOCAL_BUFFER (float, tmp, nel); for (octave_idx_type i = 1; i < nel; i++) - tmp[i] = std::real (val[i]); + tmp[i] = octave::math::real (val[i]); ret = save_mat5_array_length (tmp, nel, save_as_floats); for (octave_idx_type i = 1; i < nel; i++) - tmp[i] = std::imag (val[i]); + tmp[i] = octave::math::imag (val[i]); ret += save_mat5_array_length (tmp, nel, save_as_floats); @@ -2458,12 +2458,12 @@ NDArray buf (dim_vector (nnz, 1)); for (octave_idx_type i = 0; i < nnz; i++) - buf (i) = std::real (m.data (i)); + buf (i) = octave::math::real (m.data (i)); write_mat5_array (os, buf, save_as_floats); for (octave_idx_type i = 0; i < nnz; i++) - buf (i) = std::imag (m.data (i)); + buf (i) = octave::math::imag (m.data (i)); write_mat5_array (os, buf, save_as_floats); }
--- a/libinterp/dldfcn/__eigs__.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/libinterp/dldfcn/__eigs__.cc Thu Aug 11 16:26:56 2016 -0400 @@ -295,8 +295,8 @@ } } - sigmar = std::real (sigma); - sigmai = std::imag (sigma); + sigmar = sigma.real (); + sigmai = sigma.imag (); if (nargin > (3+arg_offset)) {
--- a/libinterp/octave-value/ov-complex.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/libinterp/octave-value/ov-complex.cc Thu Aug 11 16:26:56 2016 -0400 @@ -105,10 +105,10 @@ { octave_base_value *retval = 0; - double im = std::imag (scalar); + double im = scalar.imag (); if (im == 0.0) - retval = new octave_scalar (std::real (scalar)); + retval = new octave_scalar (scalar.real ()); return retval; } @@ -136,7 +136,7 @@ octave_complex::index_vector (bool) const { std::ostringstream buf; - buf << std::real (scalar) << std::showpos << std::imag (scalar) << "i"; + buf << scalar.real () << std::showpos << scalar.imag () << "i"; complex_index_exception e (buf.str ()); throw e; @@ -151,7 +151,7 @@ warn_implicit_conversion ("Octave:imag-to-real", "complex scalar", "real scalar"); - retval = std::real (scalar); + retval = scalar.real (); return retval; } @@ -165,7 +165,7 @@ warn_implicit_conversion ("Octave:imag-to-real", "complex scalar", "real scalar"); - retval = std::real (scalar); + retval = scalar.real (); return retval; } @@ -179,7 +179,7 @@ warn_implicit_conversion ("Octave:imag-to-real", "complex scalar", "real matrix"); - retval = Matrix (1, 1, std::real (scalar)); + retval = Matrix (1, 1, scalar.real ()); return retval; } @@ -193,7 +193,7 @@ warn_implicit_conversion ("Octave:imag-to-real", "complex scalar", "real matrix"); - retval = FloatMatrix (1, 1, std::real (scalar)); + retval = FloatMatrix (1, 1, scalar.real ()); return retval; } @@ -207,7 +207,7 @@ warn_implicit_conversion ("Octave:imag-to-real", "complex scalar", "real matrix"); - retval = NDArray (dim_vector (1, 1), std::real (scalar)); + retval = NDArray (dim_vector (1, 1), scalar.real ()); return retval; } @@ -221,7 +221,7 @@ warn_implicit_conversion ("Octave:imag-to-real", "complex scalar", "real matrix"); - retval = FloatNDArray (dim_vector (1, 1), std::real (scalar)); + retval = FloatNDArray (dim_vector (1, 1), scalar.real ()); return retval; } @@ -463,8 +463,8 @@ double *pr = static_cast<double *> (retval->get_data ()); double *pi = static_cast<double *> (retval->get_imag_data ()); - pr[0] = std::real (scalar); - pi[0] = std::imag (scalar); + pr[0] = scalar.real (); + pi[0] = scalar.imag (); return retval; }
--- a/libinterp/octave-value/ov-complex.h Fri Aug 12 00:19:11 2016 +0100 +++ b/libinterp/octave-value/ov-complex.h Thu Aug 11 16:26:56 2016 -0400 @@ -86,8 +86,8 @@ octave_value any (int = 0) const { return (scalar != Complex (0, 0) - && ! (lo_ieee_isnan (std::real (scalar)) - || lo_ieee_isnan (std::imag (scalar)))); + && ! (lo_ieee_isnan (scalar.real ()) + || lo_ieee_isnan (scalar.imag ()))); } builtin_type_t builtin_type (void) const { return btyp_complex; }
--- a/libinterp/octave-value/ov-cx-mat.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/libinterp/octave-value/ov-cx-mat.cc Thu Aug 11 16:26:56 2016 -0400 @@ -88,8 +88,8 @@ { Complex c = matrix (0); - if (std::imag (c) == 0.0) - retval = new octave_scalar (std::real (c)); + if (c.imag () == 0.0) + retval = new octave_scalar (c.real ()); else retval = new octave_complex (c); } @@ -114,7 +114,7 @@ warn_implicit_conversion ("Octave:array-to-scalar", "complex matrix", "real scalar"); - retval = std::real (matrix(0, 0)); + retval = octave::math::real (matrix(0, 0)); return retval; } @@ -134,7 +134,7 @@ warn_implicit_conversion ("Octave:array-to-scalar", "complex matrix", "real scalar"); - retval = std::real (matrix(0, 0)); + retval = octave::math::real (matrix(0, 0)); return retval; } @@ -255,7 +255,7 @@ octave_idx_type nel = numel (); for (octave_idx_type i = 0; i < nel; i++) - retval.elem (i) = static_cast<char>(std::real (matrix.elem (i))); + retval.elem (i) = static_cast<char>(octave::math::real (matrix.elem (i))); } return retval; @@ -731,8 +731,8 @@ for (mwIndex i = 0; i < nel; i++) { - pr[i] = std::real (p[i]); - pi[i] = std::imag (p[i]); + pr[i] = octave::math::real (p[i]); + pi[i] = octave::math::imag (p[i]); } return retval;
--- a/libinterp/octave-value/ov-cx-sparse.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/libinterp/octave-value/ov-cx-sparse.cc Thu Aug 11 16:26:56 2016 -0400 @@ -75,8 +75,8 @@ Complex c = tmp (0, 0); - if (std::imag (c) == 0.0) - retval = new octave_scalar (std::real (c)); + if (c.imag () == 0.0) + retval = new octave_scalar (c.real ()); else retval = new octave_complex (c); } @@ -120,7 +120,7 @@ warn_implicit_conversion ("Octave:array-to-scalar", "complex sparse matrix", "real scalar"); - retval = std::real (matrix(0, 0)); + retval = octave::math::real (matrix(0, 0)); return retval; } @@ -188,7 +188,7 @@ for (octave_idx_type j = 0; j < nc; j++) for (octave_idx_type i = matrix.cidx (j); i < matrix.cidx (j+1); i++) retval(matrix.ridx (i) + nr * j) = - static_cast<char>(std::real (matrix.data (i))); + static_cast<char>(octave::math::real (matrix.data (i))); } return retval; @@ -886,8 +886,8 @@ for (mwIndex i = 0; i < nz; i++) { Complex val = matrix.data (i); - pr[i] = std::real (val); - pi[i] = std::imag (val); + pr[i] = val.real (); + pi[i] = val.imag (); ir[i] = matrix.ridx (i); }
--- a/libinterp/octave-value/ov-flt-complex.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/libinterp/octave-value/ov-flt-complex.cc Thu Aug 11 16:26:56 2016 -0400 @@ -64,10 +64,10 @@ { octave_base_value *retval = 0; - float im = std::imag (scalar); + float im = scalar.imag (); if (im == 0.0) - retval = new octave_float_scalar (std::real (scalar)); + retval = new octave_float_scalar (scalar.real ()); return retval; } @@ -100,7 +100,7 @@ warn_implicit_conversion ("Octave:imag-to-real", "complex scalar", "real scalar"); - retval = std::real (scalar); + retval = scalar.real (); return retval; } @@ -114,7 +114,7 @@ warn_implicit_conversion ("Octave:imag-to-real", "complex scalar", "real scalar"); - retval = std::real (scalar); + retval = scalar.real (); return retval; } @@ -128,7 +128,7 @@ warn_implicit_conversion ("Octave:imag-to-real", "complex scalar", "real matrix"); - retval = Matrix (1, 1, std::real (scalar)); + retval = Matrix (1, 1, scalar.real ()); return retval; } @@ -142,7 +142,7 @@ warn_implicit_conversion ("Octave:imag-to-real", "complex scalar", "real matrix"); - retval = FloatMatrix (1, 1, std::real (scalar)); + retval = FloatMatrix (1, 1, scalar.real ()); return retval; } @@ -156,7 +156,7 @@ warn_implicit_conversion ("Octave:imag-to-real", "complex scalar", "real matrix"); - retval = NDArray (dim_vector (1, 1), std::real (scalar)); + retval = NDArray (dim_vector (1, 1), scalar.real ()); return retval; } @@ -170,7 +170,7 @@ warn_implicit_conversion ("Octave:imag-to-real", "complex scalar", "real matrix"); - retval = FloatNDArray (dim_vector (1, 1), std::real (scalar)); + retval = FloatNDArray (dim_vector (1, 1), scalar.real ()); return retval; } @@ -413,8 +413,8 @@ float *pr = static_cast<float *> (retval->get_data ()); float *pi = static_cast<float *> (retval->get_imag_data ()); - pr[0] = std::real (scalar); - pi[0] = std::imag (scalar); + pr[0] = scalar.real (); + pi[0] = scalar.imag (); return retval; }
--- a/libinterp/octave-value/ov-flt-complex.h Fri Aug 12 00:19:11 2016 +0100 +++ b/libinterp/octave-value/ov-flt-complex.h Thu Aug 11 16:26:56 2016 -0400 @@ -82,8 +82,8 @@ octave_value any (int = 0) const { return (scalar != FloatComplex (0, 0) - && ! (lo_ieee_isnan (std::real (scalar)) - || lo_ieee_isnan (std::imag (scalar)))); + && ! (lo_ieee_isnan (scalar.real ()) + || lo_ieee_isnan (scalar.imag ()))); } builtin_type_t builtin_type (void) const { return btyp_float_complex; }
--- a/libinterp/octave-value/ov-flt-cx-mat.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/libinterp/octave-value/ov-flt-cx-mat.cc Thu Aug 11 16:26:56 2016 -0400 @@ -76,8 +76,8 @@ { FloatComplex c = matrix (0); - if (std::imag (c) == 0.0) - retval = new octave_float_scalar (std::real (c)); + if (c.imag () == 0.0) + retval = new octave_float_scalar (c.real ()); else retval = new octave_float_complex (c); } @@ -102,7 +102,7 @@ warn_implicit_conversion ("Octave:array-to-scalar", "complex matrix", "real scalar"); - retval = std::real (matrix(0, 0)); + retval = octave::math::real (matrix(0, 0)); return retval; } @@ -122,7 +122,7 @@ warn_implicit_conversion ("Octave:array-to-scalar", "complex matrix", "real scalar"); - retval = std::real (matrix(0, 0)); + retval = octave::math::real (matrix(0, 0)); return retval; } @@ -229,7 +229,7 @@ octave_idx_type nel = numel (); for (octave_idx_type i = 0; i < nel; i++) - retval.elem (i) = static_cast<char>(std::real (matrix.elem (i))); + retval.elem (i) = static_cast<char>(octave::math::real (matrix.elem (i))); } return retval; @@ -682,8 +682,8 @@ for (mwIndex i = 0; i < nel; i++) { - pr[i] = std::real (p[i]); - pi[i] = std::imag (p[i]); + pr[i] = octave::math::real (p[i]); + pi[i] = octave::math::imag (p[i]); } return retval;
--- a/liboctave/array/CMatrix.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/liboctave/array/CMatrix.cc Thu Aug 11 16:26:56 2016 -0400 @@ -1037,7 +1037,7 @@ F77_XFCN (zgetri, ZGETRI, (nc, F77_DBLE_CMPLX_ARG (tmp_data), nr, pipvt, F77_DBLE_CMPLX_ARG (z.fortran_vec ()), lwork, info)); - lwork = static_cast<octave_idx_type> (std::real (z(0))); + lwork = static_cast<octave_idx_type> (octave::math::real (z(0))); lwork = (lwork < 2 *nc ? 2*nc : lwork); z.resize (dim_vector (lwork, 1)); Complex *pz = z.fortran_vec (); @@ -2665,18 +2665,18 @@ const octave_idx_type lworkaround = 4*m + m*m + addend; - if (std::real (work(0)) < lworkaround) + if (octave::math::real (work(0)) < lworkaround) work(0) = lworkaround; } else if (m >= n) { octave_idx_type lworkaround = 2*m + m*nrhs; - if (std::real (work(0)) < lworkaround) + if (octave::math::real (work(0)) < lworkaround) work(0) = lworkaround; } - lwork = static_cast<octave_idx_type> (std::real (work(0))); + lwork = static_cast<octave_idx_type> (octave::math::real (work(0))); work.resize (dim_vector (lwork, 1)); F77_XFCN (zgelsd, ZGELSD, (m, n, nrhs, F77_DBLE_CMPLX_ARG (tmp_data), m, F77_DBLE_CMPLX_ARG (pretval), @@ -2834,7 +2834,7 @@ ps, rcon, rank, F77_DBLE_CMPLX_ARG (work.fortran_vec ()), lwork, prwork, piwork, info)); - lwork = static_cast<octave_idx_type> (std::real (work(0))); + lwork = static_cast<octave_idx_type> (octave::math::real (work(0))); work.resize (dim_vector (lwork, 1)); rwork.resize (dim_vector (static_cast<octave_idx_type> (rwork(0)), 1)); iwork.resize (dim_vector (iwork(0), 1)); @@ -3094,7 +3094,7 @@ for (octave_idx_type j = 0; j < nc; j++) { - if (std::imag (elem (i, j)) != 0.0) + if (octave::math::imag (elem (i, j)) != 0.0) { retval = false; break; @@ -3113,7 +3113,7 @@ for (octave_idx_type i = 0; i < nr; i++) { - if (std::imag (elem (i, j)) != 0.0) + if (octave::math::imag (elem (i, j)) != 0.0) { retval = false; break; @@ -3159,7 +3159,7 @@ if (! octave::math::isnan (tmp_min)) { - abs_min = real_only ? std::real (tmp_min) + abs_min = real_only ? tmp_min.real () : std::abs (tmp_min); break; } @@ -3172,7 +3172,7 @@ if (octave::math::isnan (tmp)) continue; - double abs_tmp = real_only ? std::real (tmp) : std::abs (tmp); + double abs_tmp = real_only ? tmp.real () : std::abs (tmp); if (abs_tmp < abs_min) { @@ -3234,7 +3234,7 @@ if (! octave::math::isnan (tmp_max)) { - abs_max = real_only ? std::real (tmp_max) + abs_max = real_only ? tmp_max.real () : std::abs (tmp_max); break; } @@ -3247,7 +3247,7 @@ if (octave::math::isnan (tmp)) continue; - double abs_tmp = real_only ? std::real (tmp) : std::abs (tmp); + double abs_tmp = real_only ? tmp.real () : std::abs (tmp); if (abs_tmp > abs_max) { @@ -3309,7 +3309,7 @@ if (! octave::math::isnan (tmp_min)) { - abs_min = real_only ? std::real (tmp_min) + abs_min = real_only ? tmp_min.real () : std::abs (tmp_min); break; } @@ -3322,7 +3322,7 @@ if (octave::math::isnan (tmp)) continue; - double abs_tmp = real_only ? std::real (tmp) : std::abs (tmp); + double abs_tmp = real_only ? tmp.real () : std::abs (tmp); if (abs_tmp < abs_min) { @@ -3384,7 +3384,7 @@ if (! octave::math::isnan (tmp_max)) { - abs_max = real_only ? std::real (tmp_max) + abs_max = real_only ? tmp_max.real () : std::abs (tmp_max); break; } @@ -3397,7 +3397,7 @@ if (octave::math::isnan (tmp)) continue; - double abs_tmp = real_only ? std::real (tmp) : std::abs (tmp); + double abs_tmp = real_only ? tmp.real () : std::abs (tmp); if (abs_tmp > abs_max) { @@ -3624,7 +3624,7 @@ F77_CHAR_ARG_LEN (1))); for (octave_idx_type j = 0; j < a_nr; j++) for (octave_idx_type i = 0; i < j; i++) - retval.xelem (j,i) = std::conj (retval.xelem (i,j)); + retval.xelem (j,i) = octave::math::conj (retval.xelem (i,j)); } else { @@ -3657,7 +3657,7 @@ { F77_FUNC (xzdotu, XZDOTU) (a_nc, F77_CONST_DBLE_CMPLX_ARG (a.data ()), 1, F77_CONST_DBLE_CMPLX_ARG (b.data ()), 1, F77_DBLE_CMPLX_ARG (c)); - if (cja) *c = std::conj (*c); + if (cja) *c = octave::math::conj (*c); } else if (cja) F77_FUNC (xzdotc, XZDOTC) (a_nc, F77_CONST_DBLE_CMPLX_ARG (a.data ()), 1, F77_CONST_DBLE_CMPLX_ARG (b.data ()), 1, @@ -3756,7 +3756,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - if (std::imag (a(i, j)) != 0.0 || std::imag (b(i, j)) != 0.0) + if (octave::math::imag (a(i, j)) != 0.0 || octave::math::imag (b(i, j)) != 0.0) { columns_are_real_only = false; break; @@ -3766,7 +3766,7 @@ if (columns_are_real_only) { for (octave_idx_type i = 0; i < nr; i++) - result(i, j) = octave::math::min (std::real (a(i, j)), std::real (b(i, j))); + result(i, j) = octave::math::min (octave::math::real (a(i, j)), octave::math::real (b(i, j))); } else { @@ -3827,7 +3827,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - if (std::imag (a(i, j)) != 0.0 || std::imag (b(i, j)) != 0.0) + if (octave::math::imag (a(i, j)) != 0.0 || octave::math::imag (b(i, j)) != 0.0) { columns_are_real_only = false; break; @@ -3840,7 +3840,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result(i, j) = octave::math::max (std::real (a(i, j)), std::real (b(i, j))); + result(i, j) = octave::math::max (octave::math::real (a(i, j)), octave::math::real (b(i, j))); } } else
--- a/liboctave/array/CNDArray.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/liboctave/array/CNDArray.cc Thu Aug 11 16:26:56 2016 -0400 @@ -540,8 +540,8 @@ { Complex val = elem (0); - double r_val = std::real (val); - double i_val = std::imag (val); + double r_val = val.real (); + double i_val = val.imag (); max_val = r_val; min_val = r_val; @@ -559,8 +559,8 @@ { Complex val = elem (i); - double r_val = std::real (val); - double i_val = std::imag (val); + double r_val = val.real (); + double i_val = val.imag (); if (r_val > max_val) max_val = r_val;
--- a/liboctave/array/CSparse.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/liboctave/array/CSparse.cc Thu Aug 11 16:26:56 2016 -0400 @@ -3727,11 +3727,11 @@ for (octave_idx_type j = 0; j < nc-1; j++) { - D[j] = std::real (data (ii++)); + D[j] = octave::math::real (data (ii++)); DL[j] = data (ii); ii += 2; } - D[nc-1] = std::real (data (ii)); + D[nc-1] = octave::math::real (data (ii)); } else { @@ -3746,7 +3746,7 @@ for (octave_idx_type i = cidx (j); i < cidx (j+1); i++) { if (ridx (i) == j) - D[j] = std::real (data (i)); + D[j] = octave::math::real (data (i)); else if (ridx (i) == j + 1) DL[j] = data (i); } @@ -4024,11 +4024,11 @@ for (octave_idx_type j = 0; j < nc-1; j++) { - D[j] = std::real (data (ii++)); + D[j] = octave::math::real (data (ii++)); DL[j] = data (ii); ii += 2; } - D[nc-1] = std::real (data (ii)); + D[nc-1] = octave::math::real (data (ii)); } else { @@ -4043,7 +4043,7 @@ for (octave_idx_type i = cidx (j); i < cidx (j+1); i++) { if (ridx (i) == j) - D[j] = std::real (data (i)); + D[j] = octave::math::real (data (i)); else if (ridx (i) == j + 1) DL[j] = data (i); } @@ -7238,15 +7238,15 @@ if (nel == 0) return false; - max_val = std::real (data (0)); - min_val = std::real (data (0)); + max_val = octave::math::real (data (0)); + min_val = octave::math::real (data (0)); for (octave_idx_type i = 0; i < nel; i++) { Complex val = data (i); - double r_val = std::real (val); - double i_val = std::imag (val); + double r_val = val.real (); + double i_val = val.imag (); if (r_val > max_val) max_val = r_val;
--- a/liboctave/array/MatrixType.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/liboctave/array/MatrixType.cc Thu Aug 11 16:26:56 2016 -0400 @@ -177,7 +177,7 @@ std::complex<T> aji = a.elem (j,i); lower = lower && (aij == zero); upper = upper && (aji == zero); - hermitian = hermitian && (aij == std::conj (aji) + hermitian = hermitian && (aij == octave::math::conj (aji) && std::norm (aij) < diag[i]*diag[j]); } } @@ -507,8 +507,9 @@ if (a.ridx (i) == j) { T d = a.data (i); - is_herm = std::real (d) > 0.0 && std::imag (d) == 0.0; - diag(j) = std::real (d); + is_herm = (octave::math::real (d) > 0.0 + && octave::math::imag (d) == 0.0); + diag(j) = octave::math::real (d); break; } } @@ -527,7 +528,7 @@ T d = a.data (i); if (std::norm (d) < diag(j)*diag(k)) { - d = std::conj (d); + d = octave::math::conj (d); for (octave_idx_type l = a.cidx (k); l < a.cidx (k+1); l++) { if (a.ridx (l) == j)
--- a/liboctave/array/dMatrix.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/liboctave/array/dMatrix.cc Thu Aug 11 16:26:56 2016 -0400 @@ -1959,8 +1959,8 @@ double *rd = retval.fortran_vec (); for (octave_idx_type i = 0; i < nel; i++) { - rd[i] = std::real (cmd[i]); - rd[nel+i] = std::imag (cmd[i]); + rd[i] = octave::math::real (cmd[i]); + rd[nel+i] = octave::math::imag (cmd[i]); } return retval; }
--- a/liboctave/array/dSparse.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/liboctave/array/dSparse.cc Thu Aug 11 16:26:56 2016 -0400 @@ -649,7 +649,7 @@ for (octave_idx_type i = 0; i < nz; i++) { - r.data (i) = std::real (a.data (i)); + r.data (i) = octave::math::real (a.data (i)); r.ridx (i) = a.ridx (i); } @@ -670,7 +670,7 @@ for (octave_idx_type i = 0; i < nz; i++) { - r.data (i) = std::imag (a.data (i)); + r.data (i) = octave::math::imag (a.data (i)); r.ridx (i) = a.ridx (i); } @@ -4337,8 +4337,8 @@ for (octave_idx_type i = 0; i < b_nr; i++) { Complex c = b(i,j); - Bx[i] = std::real (c); - Bz[i] = std::imag (c); + Bx[i] = c.real (); + Bz[i] = c.imag (); } F77_XFCN (dgttrs, DGTTRS, @@ -5087,8 +5087,8 @@ for (octave_idx_type i = 0; i < b_nr; i++) { Complex c = b(i,j); - Bx[i] = std::real (c); - Bz[i] = std::imag (c); + Bx[i] = c.real (); + Bz[i] = c.imag (); } F77_XFCN (dpbtrs, DPBTRS, @@ -5235,8 +5235,8 @@ for (octave_idx_type i = 0; i < nr; i++) { Complex c = b(i, j); - Bx[i] = std::real (c); - Bz[i] = std::imag (c); + Bx[i] = c.real (); + Bz[i] = c.imag (); } F77_XFCN (dgbtrs, DGBTRS, @@ -5389,8 +5389,8 @@ for (octave_idx_type i = 0; i < b_nr; i++) { Complex c = b(i,j); - Bx[i] = std::real (c); - Bz[i] = std::imag (c); + Bx[i] = c.real (); + Bz[i] = c.imag (); } F77_XFCN (dpbtrs, DPBTRS, @@ -5571,8 +5571,8 @@ i < b.cidx (j+1); i++) { Complex c = b.data (i); - Bx[b.ridx (i)] = std::real (c); - Bz[b.ridx (i)] = std::imag (c); + Bx[b.ridx (i)] = c.real (); + Bz[b.ridx (i)] = c.imag (); } F77_XFCN (dgbtrs, DGBTRS, @@ -6428,8 +6428,8 @@ for (octave_idx_type i = 0; i < b_nr; i++) { Complex c = b(i,j); - Bx[i] = std::real (c); - Bz[i] = std::imag (c); + Bx[i] = c.real (); + Bz[i] = c.imag (); } status = UMFPACK_DNAME (solve) (UMFPACK_A, Ap, @@ -6690,8 +6690,8 @@ for (octave_idx_type i = 0; i < b_nr; i++) { Complex c = b(i,j); - Bx[i] = std::real (c); - Bz[i] = std::imag (c); + Bx[i] = c.real (); + Bz[i] = c.imag (); } status = UMFPACK_DNAME (solve) (UMFPACK_A, Ap,
--- a/liboctave/array/fCMatrix.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/liboctave/array/fCMatrix.cc Thu Aug 11 16:26:56 2016 -0400 @@ -1042,7 +1042,7 @@ F77_XFCN (cgetri, CGETRI, (nc, F77_CMPLX_ARG (tmp_data), nr, pipvt, F77_CMPLX_ARG (z.fortran_vec ()), lwork, info)); - lwork = static_cast<octave_idx_type> (std::real (z(0))); + lwork = static_cast<octave_idx_type> (octave::math::real (z(0))); lwork = (lwork < 2 *nc ? 2*nc : lwork); z.resize (dim_vector (lwork, 1)); FloatComplex *pz = z.fortran_vec (); @@ -2685,18 +2685,18 @@ const octave_idx_type lworkaround = 4*m + m*m + addend; - if (std::real (work(0)) < lworkaround) + if (octave::math::real (work(0)) < lworkaround) work(0) = lworkaround; } else if (m >= n) { octave_idx_type lworkaround = 2*m + m*nrhs; - if (std::real (work(0)) < lworkaround) + if (octave::math::real (work(0)) < lworkaround) work(0) = lworkaround; } - lwork = static_cast<octave_idx_type> (std::real (work(0))); + lwork = static_cast<octave_idx_type> (octave::math::real (work(0))); work.resize (dim_vector (lwork, 1)); F77_XFCN (cgelsd, CGELSD, (m, n, nrhs, F77_CMPLX_ARG (tmp_data), m, F77_CMPLX_ARG (pretval), @@ -2857,7 +2857,7 @@ ps, rcon, rank, F77_CMPLX_ARG (work.fortran_vec ()), lwork, prwork, piwork, info)); - lwork = static_cast<octave_idx_type> (std::real (work(0))); + lwork = static_cast<octave_idx_type> (octave::math::real (work(0))); work.resize (dim_vector (lwork, 1)); rwork.resize (dim_vector (static_cast<octave_idx_type> (rwork(0)), 1)); iwork.resize (dim_vector (iwork(0), 1)); @@ -3120,7 +3120,7 @@ for (octave_idx_type j = 0; j < nc; j++) { - if (std::imag (elem (i, j)) != 0.0) + if (octave::math::imag (elem (i, j)) != 0.0) { retval = false; break; @@ -3139,7 +3139,7 @@ for (octave_idx_type i = 0; i < nr; i++) { - if (std::imag (elem (i, j)) != 0.0) + if (octave::math::imag (elem (i, j)) != 0.0) { retval = false; break; @@ -3185,7 +3185,7 @@ if (! octave::math::isnan (tmp_min)) { - abs_min = real_only ? std::real (tmp_min) + abs_min = real_only ? tmp_min.real () : std::abs (tmp_min); break; } @@ -3198,7 +3198,7 @@ if (octave::math::isnan (tmp)) continue; - float abs_tmp = real_only ? std::real (tmp) : std::abs (tmp); + float abs_tmp = real_only ? tmp.real () : std::abs (tmp); if (abs_tmp < abs_min) { @@ -3260,7 +3260,7 @@ if (! octave::math::isnan (tmp_max)) { - abs_max = real_only ? std::real (tmp_max) + abs_max = real_only ? tmp_max.real () : std::abs (tmp_max); break; } @@ -3273,7 +3273,7 @@ if (octave::math::isnan (tmp)) continue; - float abs_tmp = real_only ? std::real (tmp) : std::abs (tmp); + float abs_tmp = real_only ? tmp.real () : std::abs (tmp); if (abs_tmp > abs_max) { @@ -3335,7 +3335,7 @@ if (! octave::math::isnan (tmp_min)) { - abs_min = real_only ? std::real (tmp_min) + abs_min = real_only ? tmp_min.real () : std::abs (tmp_min); break; } @@ -3348,7 +3348,7 @@ if (octave::math::isnan (tmp)) continue; - float abs_tmp = real_only ? std::real (tmp) : std::abs (tmp); + float abs_tmp = real_only ? tmp.real () : std::abs (tmp); if (abs_tmp < abs_min) { @@ -3410,7 +3410,7 @@ if (! octave::math::isnan (tmp_max)) { - abs_max = real_only ? std::real (tmp_max) + abs_max = real_only ? tmp_max.real () : std::abs (tmp_max); break; } @@ -3423,7 +3423,7 @@ if (octave::math::isnan (tmp)) continue; - float abs_tmp = real_only ? std::real (tmp) : std::abs (tmp); + float abs_tmp = real_only ? tmp.real () : std::abs (tmp); if (abs_tmp > abs_max) { @@ -3652,7 +3652,7 @@ F77_CHAR_ARG_LEN (1))); for (octave_idx_type j = 0; j < a_nr; j++) for (octave_idx_type i = 0; i < j; i++) - retval.xelem (j,i) = std::conj (retval.xelem (i,j)); + retval.xelem (j,i) = octave::math::conj (retval.xelem (i,j)); } else { @@ -3685,7 +3685,7 @@ { F77_FUNC (xcdotu, XCDOTU) (a_nc, F77_CONST_CMPLX_ARG (a.data ()), 1, F77_CONST_CMPLX_ARG (b.data ()), 1, F77_CMPLX_ARG (c)); - if (cja) *c = std::conj (*c); + if (cja) *c = octave::math::conj (*c); } else if (cja) F77_FUNC (xcdotc, XCDOTC) (a_nc, F77_CONST_CMPLX_ARG (a.data ()), 1, F77_CONST_CMPLX_ARG (b.data ()), 1, @@ -3785,7 +3785,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - if (std::imag (a(i, j)) != 0.0 || std::imag (b(i, j)) != 0.0) + if (octave::math::imag (a(i, j)) != 0.0 || octave::math::imag (b(i, j)) != 0.0) { columns_are_real_only = false; break; @@ -3795,7 +3795,7 @@ if (columns_are_real_only) { for (octave_idx_type i = 0; i < nr; i++) - result(i, j) = octave::math::min (std::real (a(i, j)), std::real (b(i, j))); + result(i, j) = octave::math::min (octave::math::real (a(i, j)), octave::math::real (b(i, j))); } else { @@ -3856,7 +3856,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - if (std::imag (a(i, j)) != 0.0 || std::imag (b(i, j)) != 0.0) + if (octave::math::imag (a(i, j)) != 0.0 || octave::math::imag (b(i, j)) != 0.0) { columns_are_real_only = false; break; @@ -3868,7 +3868,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result(i, j) = octave::math::max (std::real (a(i, j)), std::real (b(i, j))); + result(i, j) = octave::math::max (octave::math::real (a(i, j)), octave::math::real (b(i, j))); } } else
--- a/liboctave/array/fCNDArray.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/liboctave/array/fCNDArray.cc Thu Aug 11 16:26:56 2016 -0400 @@ -537,8 +537,8 @@ { FloatComplex val = elem (0); - float r_val = std::real (val); - float i_val = std::imag (val); + float r_val = val.real (); + float i_val = val.imag (); max_val = r_val; min_val = r_val; @@ -556,8 +556,8 @@ { FloatComplex val = elem (i); - float r_val = std::real (val); - float i_val = std::imag (val); + float r_val = val.real (); + float i_val = val.imag (); if (r_val > max_val) max_val = r_val;
--- a/liboctave/array/fMatrix.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/liboctave/array/fMatrix.cc Thu Aug 11 16:26:56 2016 -0400 @@ -1983,8 +1983,8 @@ float *rd = retval.fortran_vec (); for (octave_idx_type i = 0; i < nel; i++) { - rd[i] = std::real (cmd[i]); - rd[nel+i] = std::imag (cmd[i]); + rd[i] = octave::math::real (cmd[i]); + rd[nel+i] = octave::math::imag (cmd[i]); } return retval; }
--- a/liboctave/numeric/chol.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/liboctave/numeric/chol.cc Thu Aug 11 16:26:56 2016 -0400 @@ -516,7 +516,7 @@ if (singular (chol_mat)) info = 2; - else if (std::imag (u(j)) != zero) + else if (octave::math::imag (u(j)) != zero) info = 3; else { @@ -528,7 +528,7 @@ if (l == j) a1(k, l) = u(k); else if (k == j) - a1(k, l) = std::conj (u(l)); + a1(k, l) = octave::math::conj (u(l)); else a1(k, l) = a(k < j ? k : k-1, l < j ? l : l-1); }
--- a/liboctave/numeric/eigs-base.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/liboctave/numeric/eigs-base.cc Thu Aug 11 16:26:56 2016 -0400 @@ -1781,7 +1781,7 @@ { octave_idx_type off1 = i * n; octave_idx_type off2 = (i+1) * n; - if (std::imag (eig_val(i)) == 0) + if (octave::math::imag (eig_val(i)) == 0) { for (octave_idx_type j = 0; j < n; j++) eig_vec(j,i) = @@ -2127,7 +2127,7 @@ { octave_idx_type off1 = i * n; octave_idx_type off2 = (i+1) * n; - if (std::imag (eig_val(i)) == 0) + if (octave::math::imag (eig_val(i)) == 0) { for (octave_idx_type j = 0; j < n; j++) eig_vec(j,i) = @@ -2410,7 +2410,7 @@ { octave_idx_type off1 = i * n; octave_idx_type off2 = (i+1) * n; - if (std::imag (eig_val(i)) == 0) + if (octave::math::imag (eig_val(i)) == 0) { for (octave_idx_type j = 0; j < n; j++) eig_vec(j,i) =
--- a/liboctave/numeric/lo-mappers.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/liboctave/numeric/lo-mappers.cc Thu Aug 11 16:26:56 2016 -0400 @@ -59,7 +59,7 @@ bool is_NA (const Complex& x) { - return (is_NA (real (x)) || is_NA (imag (x))); + return (is_NA (std::real (x)) || is_NA (std::imag (x))); } bool @@ -71,19 +71,19 @@ bool is_NA (const FloatComplex& x) { - return (is_NA (real (x)) || is_NA (imag (x))); + return (is_NA (std::real (x)) || is_NA (std::imag (x))); } bool is_NaN_or_NA (const Complex& x) { - return (isnan (real (x)) || isnan (imag (x))); + return (isnan (std::real (x)) || isnan (std::imag (x))); } bool is_NaN_or_NA (const FloatComplex& x) { - return (isnan (real (x)) || isnan (imag (x))); + return (isnan (std::real (x)) || isnan (std::imag (x))); } Complex @@ -92,8 +92,8 @@ #if defined (HAVE_COMPLEX_STD_ACOS) Complex y = std::acos (x); - if (imag (x) == 0.0 && real (x) > 1.0) - return conj (y); + if (std::imag (x) == 0.0 && std::real (x) > 1.0) + return std::conj (y); else return y; #else @@ -101,12 +101,12 @@ Complex tmp; - if (imag (x) == 0.0) + if (std::imag (x) == 0.0) { // If the imaginary part of X is 0, then avoid generating an // imaginary part of -0 for the expression 1-x*x. // This effectively chooses the same phase of the branch cut as Matlab. - double xr = real (x); + double xr = std::real (x); tmp = Complex (1.0 - xr*xr); } else @@ -122,8 +122,8 @@ #if defined (HAVE_COMPLEX_STD_ACOS) FloatComplex y = std::acos (x); - if (imag (x) == 0.0f && real (x) > 1.0f) - return conj (y); + if (std::imag (x) == 0.0f && std::real (x) > 1.0f) + return std::conj (y); else return y; #else @@ -131,12 +131,12 @@ FloatComplex tmp; - if (imag (x) == 0.0f) + if (std::imag (x) == 0.0f) { // If the imaginary part of X is 0, then avoid generating an // imaginary part of -0 for the expression 1-x*x. // This effectively chooses the same phase of the branch cut as Matlab. - float xr = real (x); + float xr = std::real (x); tmp = FloatComplex (1.0f - xr*xr); } else @@ -152,8 +152,8 @@ #if defined (HAVE_COMPLEX_STD_ASIN) Complex y = std::asin (x); - if (imag (x) == 0.0 && real (x) > 1.0) - return conj (y); + if (std::imag (x) == 0.0 && std::real (x) > 1.0) + return std::conj (y); else return y; #else @@ -161,12 +161,12 @@ Complex tmp; - if (imag (x) == 0.0) + if (std::imag (x) == 0.0) { // If the imaginary part of X is 0, then avoid generating an // imaginary part of -0 for the expression 1-x*x. // This effectively chooses the same phase of the branch cut as Matlab. - double xr = real (x); + double xr = std::real (x); tmp = Complex (1.0 - xr*xr); } else @@ -182,8 +182,8 @@ #if defined (HAVE_COMPLEX_STD_ASIN) FloatComplex y = std::asin (x); - if (imag (x) == 0.0f && real (x) > 1.0f) - return conj (y); + if (std::imag (x) == 0.0f && std::real (x) > 1.0f) + return std::conj (y); else return y; #else @@ -191,12 +191,12 @@ FloatComplex tmp; - if (imag (x) == 0.0f) + if (std::imag (x) == 0.0f) { // If the imaginary part of X is 0, then avoid generating an // imaginary part of -0 for the expression 1-x*x. // This effectively chooses the same phase of the branch cut as Matlab. - float xr = real (x); + float xr = std::real (x); tmp = FloatComplex (1.0f - xr*xr); } else
--- a/liboctave/numeric/lo-mappers.h Fri Aug 12 00:19:11 2016 +0100 +++ b/liboctave/numeric/lo-mappers.h Thu Aug 11 16:26:56 2016 -0400 @@ -46,6 +46,20 @@ extern OCTAVE_API bool is_NaN_or_NA (const Complex& x); extern OCTAVE_API bool is_NaN_or_NA (const FloatComplex& x); + extern OCTAVE_API double copysign (double x, double y); + extern OCTAVE_API float copysign (float x, float y); + + extern OCTAVE_API double signbit (double x); + extern OCTAVE_API float signbit (float x); + + // Test for negative sign. + extern OCTAVE_API bool negative_sign (double x); + extern OCTAVE_API bool negative_sign (float x); + + // Test for positive sign. + inline bool positive_sign (double x) { return ! negative_sign (x); } + inline bool positive_sign (float x) { return ! negative_sign (x); } + extern OCTAVE_API Complex acos (const Complex& x); extern OCTAVE_API FloatComplex acos (const FloatComplex& x); @@ -62,14 +76,49 @@ using std::atan; // C++ now provides versions of the following funtions for - // arguments of type std::complex<T> and T so we no longer need to - // provide our own wrappers for real-valued arguments. Import - // them to the octave::math namespace for convenience. + // arguments of type std::complex<T> and T. But some compilers + // (I'm looking at you, clang) apparently don't get this right + // yet... So we provide our own wrappers for real-valued arguments. + + inline double arg (double x) { return signbit (x) ? M_PI : 0; } + inline float arg (float x) { return signbit (x) ? M_PI : 0; } + + template <typename T> + T + arg (const std::complex<T>& x) + { + return std::arg (x); + } + + inline double conj (double x) { return x; } + inline float conj (float x) { return x; } - using std::arg; - using std::conj; - using std::imag; - using std::real; + template <typename T> + std::complex<T> + conj (const std::complex<T>& x) + { + return std::conj (x); + } + + inline double imag (double) { return 0; } + inline float imag (float) { return 0; } + + template <typename T> + T + imag (const std::complex<T>& x) + { + return std::imag (x); + } + + inline double real (double x) { return x; } + inline float real (float x) { return x; } + + template <typename T> + T + real (const std::complex<T>& x) + { + return std::real (x); + } extern OCTAVE_API double log2 (double x); extern OCTAVE_API float log2 (float x); @@ -93,23 +142,9 @@ std::complex<T> ceil (const std::complex<T>& x) { - return std::complex<T> (ceil (real (x)), ceil (imag (x))); + return std::complex<T> (ceil (std::real (x)), ceil (std::imag (x))); } - extern OCTAVE_API double copysign (double x, double y); - extern OCTAVE_API float copysign (float x, float y); - - extern OCTAVE_API double signbit (double x); - extern OCTAVE_API float signbit (float x); - - // Test for negative sign. - extern OCTAVE_API bool negative_sign (double x); - extern OCTAVE_API bool negative_sign (float x); - - // Test for positive sign. - inline bool positive_sign (double x) { return ! negative_sign (x); } - inline bool positive_sign (float x) { return ! negative_sign (x); } - extern OCTAVE_API double trunc (double x); extern OCTAVE_API float trunc (float x); @@ -117,7 +152,7 @@ std::complex<T> trunc (const std::complex<T>& x) { - return std::complex<T> (trunc (real (x)), trunc (imag (x))); + return std::complex<T> (trunc (std::real (x)), trunc (std::imag (x))); } inline double fix (double x) { return trunc (x); } @@ -137,7 +172,7 @@ std::complex<T> floor (const std::complex<T>& x) { - return std::complex<T> (floor (real (x)), floor (imag (x))); + return std::complex<T> (floor (std::real (x)), floor (std::imag (x))); } extern OCTAVE_API double round (double x); @@ -147,7 +182,7 @@ std::complex<T> round (const std::complex<T>& x) { - return std::complex<T> (round (real (x)), round (imag (x))); + return std::complex<T> (round (std::real (x)), round (std::imag (x))); } inline double @@ -166,8 +201,8 @@ { float t = round (x); - if (fabsf (x - t) == 0.5) - t = 2 * trunc (0.5 * t); + if (fabsf (x - t) == 0.5f) + t = 2 * trunc (0.5f * t); return t; } @@ -176,7 +211,7 @@ std::complex<T> roundb (const std::complex<T>& x) { - return std::complex<T> (roundb (real (x)), roundb (imag (x))); + return std::complex<T> (roundb (std::real (x)), roundb (std::imag (x))); } extern OCTAVE_API double frexp (double x, int *expptr); @@ -191,7 +226,7 @@ bool isnan (const std::complex<T>& x) { - return (isnan (real (x)) || isnan (imag (x))); + return (isnan (std::real (x)) || isnan (std::imag (x))); } extern OCTAVE_API bool finite (double x); @@ -201,7 +236,7 @@ bool finite (const std::complex<T>& x) { - return (finite (real (x)) && finite (imag (x))); + return (finite (std::real (x)) && finite (std::imag (x))); } extern OCTAVE_API bool isinf (double x); @@ -211,7 +246,7 @@ bool isinf (const std::complex<T>& x) { - return (isinf (real (x)) || isinf (imag (x))); + return (isinf (std::real (x)) || isinf (std::imag (x))); } // Some useful tests, that are commonly repeated.
--- a/liboctave/numeric/lo-specfun.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/liboctave/numeric/lo-specfun.cc Thu Aug 11 16:26:56 2016 -0400 @@ -367,9 +367,9 @@ FloatComplex erf (const FloatComplex& x) { - Complex xd (real (x), imag (x)); + Complex xd (x.real (), x.imag ()); Complex ret = Faddeeva::erf (xd, std::numeric_limits<float>::epsilon ()); - return FloatComplex (real (ret), imag (ret)); + return FloatComplex (ret.real (), ret.imag ()); } double @@ -406,9 +406,9 @@ FloatComplex erfc (const FloatComplex& x) { - Complex xd (real (x), imag (x)); + Complex xd (x.real (), x.imag ()); Complex ret = Faddeeva::erfc (xd, std::numeric_limits<float>::epsilon ()); - return FloatComplex (real (ret), imag (ret)); + return FloatComplex (ret.real (), ret.imag ()); } // Real and complex scaled complementary error function from Faddeeva package @@ -424,9 +424,9 @@ FloatComplex erfcx (const FloatComplex& x) { - Complex xd (real (x), imag (x)); + Complex xd (x.real (), x.imag ()); Complex ret = Faddeeva::erfcx (xd, std::numeric_limits<float>::epsilon ()); - return FloatComplex (real (ret), imag (ret)); + return FloatComplex (ret.real (), ret.imag ()); } // Real and complex imaginary error function from Faddeeva package @@ -442,9 +442,9 @@ FloatComplex erfi (const FloatComplex& x) { - Complex xd (real (x), imag (x)); + Complex xd (x.real (), x.imag ()); Complex ret = Faddeeva::erfi (xd, std::numeric_limits<float>::epsilon ()); - return FloatComplex (real (ret), imag (ret)); + return FloatComplex (ret.real (), ret.imag ()); } // Real and complex Dawson function (= scaled erfi) from Faddeeva package @@ -460,9 +460,9 @@ FloatComplex dawson (const FloatComplex& x) { - Complex xd (real (x), imag (x)); + Complex xd (x.real (), x.imag ()); Complex ret = Faddeeva::Dawson (xd, std::numeric_limits<float>::epsilon ()); - return FloatComplex (real (ret), imag (ret)); + return FloatComplex (ret.real (), ret.imag ()); } double @@ -1133,8 +1133,8 @@ { Complex expz = exp (-z); - double rexpz = real (expz); - double iexpz = imag (expz); + double rexpz = expz.real (); + double iexpz = expz.imag (); double tmp = yr*rexpz - yi*iexpz; @@ -1179,8 +1179,8 @@ { Complex expz = exp (Complex (0.0, 1.0) * z); - double rexpz = real (expz); - double iexpz = imag (expz); + double rexpz = expz.real (); + double iexpz = expz.imag (); double tmp = yr*rexpz - yi*iexpz; @@ -1225,8 +1225,8 @@ { Complex expz = exp (-Complex (0.0, 1.0) * z); - double rexpz = real (expz); - double iexpz = imag (expz); + double rexpz = expz.real (); + double iexpz = expz.imag (); double tmp = yr*rexpz - yi*iexpz; @@ -1563,11 +1563,11 @@ if (kode != 2) { - float expz = exp (std::abs (imag (z))); + float expz = exp (std::abs (z.imag ())); y *= expz; } - if (imag (z) == 0.0 && real (z) >= 0.0) + if (z.imag () == 0.0 && z.real () >= 0.0) y = FloatComplex (y.real (), 0.0); retval = bessel_return_value (y, ierr); @@ -1618,7 +1618,7 @@ ierr = 0; - if (real (z) == 0.0 && imag (z) == 0.0) + if (z.real () == 0.0 && z.imag () == 0.0) { y = FloatComplex (-octave::numeric_limits<float>::Inf (), 0.0); } @@ -1628,11 +1628,11 @@ if (kode != 2) { - float expz = exp (std::abs (imag (z))); + float expz = exp (std::abs (z.imag ())); y *= expz; } - if (imag (z) == 0.0 && real (z) >= 0.0) + if (z.imag () == 0.0 && z.real () >= 0.0) y = FloatComplex (y.real (), 0.0); } @@ -1684,11 +1684,11 @@ if (kode != 2) { - float expz = exp (std::abs (real (z))); + float expz = exp (std::abs (z.real ())); y *= expz; } - if (imag (z) == 0.0 && real (z) >= 0.0) + if (z.imag () == 0.0 && z.real () >= 0.0) y = FloatComplex (y.real (), 0.0); retval = bessel_return_value (y, ierr); @@ -1736,7 +1736,7 @@ ierr = 0; - if (real (z) == 0.0 && imag (z) == 0.0) + if (z.real () == 0.0 && z.imag () == 0.0) { y = FloatComplex (octave::numeric_limits<float>::Inf (), 0.0); } @@ -1748,16 +1748,16 @@ { FloatComplex expz = exp (-z); - float rexpz = real (expz); - float iexpz = imag (expz); - - float tmp_r = real (y) * rexpz - imag (y) * iexpz; - float tmp_i = real (y) * iexpz + imag (y) * rexpz; + float rexpz = expz.real (); + float iexpz = expz.imag (); + + float tmp_r = y.real () * rexpz - y.imag () * iexpz; + float tmp_i = y.real () * iexpz + y.imag () * rexpz; y = FloatComplex (tmp_r, tmp_i); } - if (imag (z) == 0.0 && real (z) >= 0.0) + if (z.imag () == 0.0 && z.real () >= 0.0) y = FloatComplex (y.real (), 0.0); } @@ -1790,11 +1790,11 @@ { FloatComplex expz = exp (FloatComplex (0.0, 1.0) * z); - float rexpz = real (expz); - float iexpz = imag (expz); - - float tmp_r = real (y) * rexpz - imag (y) * iexpz; - float tmp_i = real (y) * iexpz + imag (y) * rexpz; + float rexpz = expz.real (); + float iexpz = expz.imag (); + + float tmp_r = y.real () * rexpz - y.imag () * iexpz; + float tmp_i = y.real () * iexpz + y.imag () * rexpz; y = FloatComplex (tmp_r, tmp_i); } @@ -1833,11 +1833,11 @@ { FloatComplex expz = exp (-FloatComplex (0.0, 1.0) * z); - float rexpz = real (expz); - float iexpz = imag (expz); - - float tmp_r = real (y) * rexpz - imag (y) * iexpz; - float tmp_i = real (y) * iexpz + imag (y) * rexpz; + float rexpz = expz.real (); + float iexpz = expz.imag (); + + float tmp_r = y.real () * rexpz - y.imag () * iexpz; + float tmp_i = y.real () * iexpz + y.imag () * rexpz; y = FloatComplex (tmp_r, tmp_i); } @@ -2124,8 +2124,8 @@ { Complex expz = exp (- 2.0 / 3.0 * z * sqrt (z)); - double rexpz = real (expz); - double iexpz = imag (expz); + double rexpz = expz.real (); + double iexpz = expz.imag (); double tmp = ar*rexpz - ai*iexpz; @@ -2154,10 +2154,10 @@ if (! scaled) { - Complex expz = exp (std::abs (real (2.0 / 3.0 * z * sqrt (z)))); - - double rexpz = real (expz); - double iexpz = imag (expz); + Complex expz = exp (std::abs (std::real (2.0 / 3.0 * z * sqrt (z)))); + + double rexpz = expz.real (); + double iexpz = expz.imag (); double tmp = ar*rexpz - ai*iexpz; @@ -2257,8 +2257,8 @@ { FloatComplex expz = exp (- 2.0f / 3.0f * z * sqrt (z)); - float rexpz = real (expz); - float iexpz = imag (expz); + float rexpz = expz.real (); + float iexpz = expz.imag (); float tmp = ar*rexpz - ai*iexpz; @@ -2286,10 +2286,10 @@ if (! scaled) { - FloatComplex expz = exp (std::abs (real (2.0f / 3.0f * z * sqrt (z)))); - - float rexpz = real (expz); - float iexpz = imag (expz); + FloatComplex expz = exp (std::abs (std::real (2.0f / 3.0f * z * sqrt (z)))); + + float rexpz = expz.real (); + float iexpz = expz.imag (); float tmp = ar*rexpz - ai*iexpz; @@ -3721,8 +3721,8 @@ { double m1 = 1 - m, ss1, cc1, dd1; - ellipj (imag (u), m1, ss1, cc1, dd1, err); - if (real (u) == 0) + ellipj (u.imag (), m1, ss1, cc1, dd1, err); + if (u.real () == 0) { // u is pure imag: Jacoby imag. transf. sn = Complex (0, ss1/cc1); @@ -3734,7 +3734,7 @@ // u is generic complex double ss, cc, dd, ddd; - ellipj (real (u), m, ss, cc, dd, err); + ellipj (u.real (), m, ss, cc, dd, err); ddd = cc1*cc1 + m*ss*ss*ss1*ss1; sn = Complex (ss*dd1/ddd, cc*dd*ss1*cc1/ddd); cn = Complex (cc*cc1/ddd, -ss*dd*ss1*dd1/ddd);
--- a/liboctave/numeric/sparse-qr.cc Fri Aug 12 00:19:11 2016 +0100 +++ b/liboctave/numeric/sparse-qr.cc Thu Aug 11 16:26:56 2016 -0400 @@ -770,8 +770,8 @@ for (octave_idx_type j = 0; j < b_nr; j++) { Complex c = b.xelem (j,i); - Xx[j] = std::real (c); - Xz[j] = std::imag (c); + Xx[j] = c.real (); + Xz[j] = c.imag (); } for (octave_idx_type j = nr; j < S->m2; j++) @@ -866,8 +866,8 @@ for (octave_idx_type j = 0; j < b_nr; j++) { Complex c = b.xelem (j,i); - Xx[j] = std::real (c); - Xz[j] = std::imag (c); + Xx[j] = c.real (); + Xz[j] = c.imag (); } for (octave_idx_type j = nr; j < nbuf; j++) @@ -1213,8 +1213,8 @@ for (octave_idx_type j = 0; j < b_nr; j++) { Complex c = b.xelem (j,i); - Xx[j] = std::real (c); - Xz[j] = std::imag (c); + Xx[j] = c.real (); + Xz[j] = c.imag (); } for (octave_idx_type j = nr; j < S->m2; j++) @@ -1332,8 +1332,8 @@ for (octave_idx_type j = 0; j < b_nr; j++) { Complex c = b.xelem (j,i); - Xx[j] = std::real (c); - Xz[j] = std::imag (c); + Xx[j] = c.real (); + Xz[j] = c.imag (); } for (octave_idx_type j = nr; j < nbuf; j++)