# HG changeset patch # User John W. Eaton # Date 1267473745 18000 # Node ID 60acc47c203fe59bad62bfda22f11a91e3dee590 # Parent f578e6468d0c7707fb9593851931e2325a5f8fc8 configure checks for complex element setter/reference accessor methods diff -r f578e6468d0c -r 60acc47c203f ChangeLog --- a/ChangeLog Mon Mar 01 15:24:05 2010 +0100 +++ b/ChangeLog Mon Mar 01 15:02:25 2010 -0500 @@ -1,3 +1,9 @@ +2010-03-01 John W. Eaton + + * acinclude.m4 (OCTAVE_CXX_COMPLEX_REFERENCE_ACCESSORS, + OCTAVE_CXX_COMPLEX_SETTERS): New macros. + * configure.ac: Use them. + 2010-02-25 John W. Eaton * gdbinit: New file. diff -r f578e6468d0c -r 60acc47c203f acinclude.m4 --- a/acinclude.m4 Mon Mar 01 15:24:05 2010 +0100 +++ b/acinclude.m4 Mon Mar 01 15:02:25 2010 -0500 @@ -106,6 +106,38 @@ AC_LANG_POP(C++) ]) dnl +dnl See if the C++ library has functions to set real and imaginary +dnl parts of complex numbers independently. +dnl +AC_DEFUN([OCTAVE_CXX_COMPLEX_SETTERS], +[AC_CACHE_CHECK([whether complex class can set components independently], +octave_cv_cxx_complex_setters, +[AC_LANG_PUSH(C++) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], +[[std::complex x; x.real (1.0); x.imag (2.0);]])], +octave_cv_cxx_complex_setters=yes, octave_cv_cxx_complex_setters=no)]) +if test $octave_cv_cxx_complex_setters = yes; then +AC_DEFINE(HAVE_CXX_COMPLEX_SETTERS,1,[Define if C++ complex class has void real (T) and void imag (T) methods]) +fi +AC_LANG_POP(C++) +]) +dnl +dnl See if the C++ library has functions to access real and imaginary +dnl parts of complex numbers independently via references. +dnl +AC_DEFUN([OCTAVE_CXX_COMPLEX_REFERENCE_ACCESSORS], +[AC_CACHE_CHECK([whether complex class can reference components independently], +octave_cv_cxx_complex_reference_accessors, +[AC_LANG_PUSH(C++) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], +[[std::complex x; x.real () = 1.0; x.imag () = 1.0;]])], +octave_cv_cxx_complex_reference_accessors=yes, octave_cv_cxx_complex_reference_accessors=no)]) +if test $octave_cv_cxx_complex_reference_accessors = yes; then +AC_DEFINE(HAVE_CXX_COMPLEX_REFERENCE_ACCESSORS,1,[Define if C++ complex class has T& real (void) and T& imag (void) methods]) +fi +AC_LANG_POP(C++) +]) +dnl dnl The following test is from Karl Berry's Kpathseach library. I'm dnl including it here in case we someday want to make the use of dnl kpathsea optional. diff -r f578e6468d0c -r 60acc47c203f configure.ac --- a/configure.ac Mon Mar 01 15:24:05 2010 +0100 +++ b/configure.ac Mon Mar 01 15:02:25 2010 -0500 @@ -607,6 +607,9 @@ OCTAVE_IEEE754_DATA_FORMAT +OCTAVE_CXX_COMPLEX_SETTERS +OCTAVE_CXX_COMPLEX_REFERENCE_ACCESSORS + ### Check for the QHull library OCTAVE_CHECK_LIBRARY(qhull, QHull, diff -r f578e6468d0c -r 60acc47c203f src/ChangeLog --- a/src/ChangeLog Mon Mar 01 15:24:05 2010 +0100 +++ b/src/ChangeLog Mon Mar 01 15:02:25 2010 -0500 @@ -1,3 +1,9 @@ +2010-03-01 John W. Eaton + + * DLD-FUNCTIONS/str2double.cc (set_component): Use autoconf + macros instead of checking predefined compiler macros. + (str2double1): Pass val to set_component, not c. + 2010-03-01 Jaroslav Hajek * DLD-FUNCTIONS/str2double.cc (set_component): New helper func. diff -r f578e6468d0c -r 60acc47c203f src/DLD-FUNCTIONS/str2double.cc --- a/src/DLD-FUNCTIONS/str2double.cc Mon Mar 01 15:24:05 2010 +0100 +++ b/src/DLD-FUNCTIONS/str2double.cc Mon Mar 01 15:02:25 2010 -0500 @@ -139,12 +139,16 @@ static inline void set_component (Complex& c, double num, bool imag) { - // FIXME: this is C++-0x. -#if defined (__GNUC__) || defined (__MSVC__) +#if defined (HAVE_CXX_COMPLEX_SETTERS) if (imag) - c.imag (r); + c.imag (num); else - c.real (r); + c.real (num); +#elif defined (HAVE_CXX_COMPLEX_REFERENCE_ACCESSORS) + if (imag) + c.imag () = num; + else + c.real () = num; #else if (imag) c = Complex (c.real (), num); @@ -173,14 +177,14 @@ val = octave_NaN; else { - set_component (c, num, i1); + set_component (val, num, i1); if (! is.eof ()) { if (! extract_num (is, num, i2, s2) || i1 == i2 || ! s2) val = octave_NaN; else - set_component (c, num, i2); + set_component (val, num, i2); } }