Mercurial > hg > octave-terminal
changeset 4853:66b3cce2bf37
[project @ 2004-04-06 18:11:52 by jwe]
author | jwe |
---|---|
date | Tue, 06 Apr 2004 18:11:52 +0000 |
parents | 404c7122853e |
children | 4b0f3b055331 |
files | ChangeLog aclocal.m4 configure.in src/DLD-FUNCTIONS/sort.cc |
diffstat | 4 files changed, 76 insertions(+), 80 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2004-04-06 John W. Eaton <jwe@bevo.che.wisc.edu> + * configure.in: Delete code for --with-ieee754. + Use OCTAVE_IEEE754_DATA_FORMAT. + + * aclocal.m4 (OCTAVE_IEEE754_DATA_FORMAT): New macro, based on + configure.in code for HAVE_IEEE754_COMPLIANCE. + +2004-04-06 David Bateman <dbateman@free.fr> + * configure.in : add the option --with-ieee754 and use it to define HAVE_IEEE754_COMPLIANCE
--- a/aclocal.m4 +++ b/aclocal.m4 @@ -774,3 +774,32 @@ AC_SUBST([SED], $octave_cv_path_sed) AC_MSG_RESULT([$SED]) ]) +# OCTAVE_IEEE754_DATA_FORMAT +# -------------- +# Check for IEEE 754 data format. +AC_DEFUN([OCTAVE_IEEE754_DATA_FORMAT], +[AC_MSG_CHECKING([for IEEE 754 data format]) +AC_CACHE_VAL(octave_cv_ieee754_data_format, +[AC_TRY_RUN([ +int +main (void) +{ + typedef union { unsigned char c[8]; double d; } ieeebytes; + + ieeebytes l = {0x1c, 0xbc, 0x6e, 0xf2, 0x54, 0x8b, 0x11, 0x43}; + ieeebytes b = {0x43, 0x11, 0x8b, 0x54, 0xf2, 0x6e, 0xbc, 0x1c}; + + return l.d != 1234567891234567.0 && b.d != 1234567891234567.0; +}], + octave_cv_ieee754_data_format=yes, + octave_cv_ieee754_data_format=no, + octave_cv_ieee754_data_format=no)]) +if test "$cross_compiling" = yes; then + AC_MSG_RESULT([$octave_cv_ieee754_data_format assumed for cross compilation]) +else + AC_MSG_RESULT($octave_cv_ieee754_data_format) +fi +if test "$octave_cv_ieee754_data_format" = yes; then + AC_DEFINE(HAVE_IEEE754_DATA_FORMAT, 1, [Define if your system uses IEEE 754 data format.]) +fi +])
--- a/configure.in +++ b/configure.in @@ -29,7 +29,7 @@ EXTERN_CXXFLAGS="$CXXFLAGS" AC_INIT -AC_REVISION($Revision: 1.451 $) +AC_REVISION($Revision: 1.452 $) AC_PREREQ(2.57) AC_CONFIG_SRCDIR([src/octave.cc]) AC_CONFIG_HEADER(config.h) @@ -431,48 +431,7 @@ AC_DEFINE(HAVE_MPI, 1, [Define if MPI is available.])])]) fi - -# Check for IEEE 754 compliance -AC_ARG_WITH(ieee754, [ --with-ieee754 force IEEE754 compliance], - with_ieee754=$withval, with_ieee754=no) - -AC_MSG_CHECKING([IEEE 754 compliance]) -if test "$with_ieee754" = yes; then - AC_MSG_RESULT(forced) -else - # Test for conformance to IEEE 754 or IEEE 854 standards - # Need to temporarily change the quote to print "[]" - changequote(<-, ->)dnl - cat > conftest.c << EOF - int main (void) - { - /* Test for IEEE754 floating point representation. */ - union { unsigned char c[8]; double d; } - l = {{0x1c, 0xbc, 0x6e, 0xf2, 0x54, 0x8b, 0x11, 0x43}}, - b = {{0x43, 0x11, 0x8b, 0x54, 0xf2, 0x6e, 0xbc, 0x1c}}; - return l.d!=1234567891234567.0 && b.d!=1234567891234567.0; - } -EOF - changequote([, ])dnl - - ac_try="$CC -o conftest conftest.c" - if AC_TRY_EVAL(ac_try) ; then - ac_try="./conftest" - if AC_TRY_EVAL(ac_try) ; then - with_ieee754=yes - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - fi - else - AC_MSG_RESULT(no) - fi - rm -f conftest* -fi - -if test "$with_ieee754" = yes; then - AC_DEFINE(HAVE_IEEE754_COMPLIANCE, 1, [Define if the system is IEEE754 complant.]) -fi +OCTAVE_IEEE754_DATA_FORMAT # ----------------------------------------------------------------------
--- a/src/DLD-FUNCTIONS/sort.cc +++ b/src/DLD-FUNCTIONS/sort.cc @@ -37,12 +37,11 @@ #include "ov-cx-mat.h" #include "oct-sort.cc" -/* If we are IEEE 754 or IEEE 854 compliant, then we can use the trick of - * casting doubles as unsigned eight byte integers, and with a little - * bit of magic we can automatically sort the NaN's correctly. - */ +// If we have IEEE 754 data format, then we can use the trick of +// casting doubles as unsigned eight byte integers, and with a little +// bit of magic we can automatically sort the NaN's correctly. -#if defined(HAVE_IEEE754_COMPLIANCE) && defined(EIGHT_BYTE_INT) +#if defined (HAVE_IEEE754_DATA_FORMAT) && defined (EIGHT_BYTE_INT) static inline unsigned EIGHT_BYTE_INT FloatFlip(unsigned EIGHT_BYTE_INT f) { @@ -123,7 +122,7 @@ for (unsigned int i = 0; i < (unsigned int)dim; i++) stride *= dv(i); -#if defined(HAVE_IEEE754_COMPLIANCE) && defined(EIGHT_BYTE_INT) +#if defined (HAVE_IEEE754_DATA_FORMAT) && defined (EIGHT_BYTE_INT) double *v = m.fortran_vec (); unsigned EIGHT_BYTE_INT *p = (unsigned EIGHT_BYTE_INT *)v; @@ -151,9 +150,9 @@ } offset += offset2 * stride * ns; - /* Flip the data in the vector so that int compares on - * IEEE754 give the correct ordering - */ + // Flip the data in the vector so that int compares on + // IEEE754 give the correct ordering. + for (unsigned int i = 0; i < ns; i++) { vi[i]->vec = FloatFlip (p[i*stride + offset]); @@ -162,19 +161,19 @@ indexed_ieee754_sort.sort (vi, ns); - /* Flip the data out of the vector so that int compares on - * IEEE754 give the correct ordering - */ + // Flip the data out of the vector so that int compares on + // IEEE754 give the correct ordering + for (unsigned int i = 0; i < ns; i++) { p[i*stride + offset] = IFloatFlip (vi[i]->vec); idx(i*stride + offset) = vi[i]->indx; } - /* There are two representations of NaN. One will be sorted to - * the beginning of the vector and the other to the end. If it - * will be sorted to the beginning, fix things up. - */ + // There are two representations of NaN. One will be sorted + // to the beginning of the vector and the other to the end. + // If it will be sorted to the beginning, fix things up. + if (lo_ieee_signbit (octave_NaN)) { unsigned int i = 0; @@ -205,24 +204,25 @@ { for (unsigned int j = 0; j < iter; j++) { - /* Flip the data in the vector so that int compares on - * IEEE754 give the correct ordering - */ + // Flip the data in the vector so that int compares on + // IEEE754 give the correct ordering. + for (unsigned int i = 0; i < ns; i++) p[i] = FloatFlip (p[i]); ieee754_sort.sort (p, ns); - /* Flip the data out of the vector so that int compares on - * IEEE754 give the correct ordering - */ + // Flip the data out of the vector so that int compares + // on IEEE754 give the correct ordering. + for (unsigned int i = 0; i < ns; i++) p[i] = IFloatFlip (p[i]); - /* There are two representations of NaN. One will be sorted to - * the beginning of the vector and the other to the end. If it - * will be sorted to the beginning, fix things up. - */ + // There are two representations of NaN. One will be + // sorted to the beginning of the vector and the other + // to the end. If it will be sorted to the beginning, + // fix things up. + if (lo_ieee_signbit (octave_NaN)) { unsigned int i = 0; @@ -253,24 +253,25 @@ } offset += offset2 * stride * ns; - /* Flip the data in the vector so that int compares on - * IEEE754 give the correct ordering - */ + // Flip the data in the vector so that int compares on + // IEEE754 give the correct ordering. + for (unsigned int i = 0; i < ns; i++) vi[i] = FloatFlip (p[i*stride + offset]); ieee754_sort.sort (vi, ns); - /* Flip the data out of the vector so that int compares on - * IEEE754 give the correct ordering - */ + // Flip the data out of the vector so that int compares + // on IEEE754 give the correct ordering. + for (unsigned int i = 0; i < ns; i++) p[i*stride + offset] = IFloatFlip (vi[i]); - /* There are two representations of NaN. One will be sorted to - * the beginning of the vector and the other to the end. If it - * will be sorted to the beginning, fix things up. - */ + // There are two representations of NaN. One will be + // sorted to the beginning of the vector and the other + // to the end. If it will be sorted to the beginning, + // fix things up. + if (lo_ieee_signbit (octave_NaN)) { unsigned int i = 0; @@ -599,7 +600,6 @@ return retval; } - /* ;;; Local Variables: *** ;;; mode: C++ ***