# HG changeset patch # User jwe # Date 1099979591 0 # Node ID 97b62f0c1beeb0f5a41aee85488810d5a9b2bf5a # Parent 7b24fd17c263c0a24955b0dfba5fc8051d49d63b [project @ 2004-11-09 05:51:30 by jwe] diff -r 7b24fd17c263 -r 97b62f0c1bee liboctave/ChangeLog --- a/liboctave/ChangeLog Fri Feb 01 21:15:17 2008 -0500 +++ b/liboctave/ChangeLog Tue Nov 09 05:53:11 2004 +0000 @@ -1,3 +1,16 @@ +2004-11-08 John W. Eaton + + * oct-inttypes.cc: New file. + * Makefile.in (TI_SRC): Add it to the list. + * oct-inttypes.h (OCTAVE_US_TYPE1_CMP_OP, OCTAVE_US_TYPE1_CMP_OPS, + OCTAVE_SU_TYPE1_CMP_OP, OCTAVE_SU_TYPE1_CMP_OPS, + OCTAVE_TYPE1_CMP_OPS, OCTAVE_US_TYPE2_CMP_OP, + OCTAVE_US_TYPE2_CMP_OPS, OCTAVE_SU_TYPE2_CMP_OP, + OCTAVE_SU_TYPE2_CMP_OPS, OCTAVE_TYPE2_CMP_OPS): + New macros for comparison operations. Avoid potential + problems with default conversions when comparing signed and + unsigned values. + 2004-11-03 John W. Eaton * dMatrix.cc (Matrix::inverse): Return info == -1 for any failure. diff -r 7b24fd17c263 -r 97b62f0c1bee liboctave/Makefile.in --- a/liboctave/Makefile.in Fri Feb 01 21:15:17 2008 -0500 +++ b/liboctave/Makefile.in Tue Nov 09 05:53:11 2004 +0000 @@ -72,7 +72,8 @@ TI_SRC := Array-C.cc Array-b.cc Array-ch.cc Array-i.cc Array-d.cc \ Array-s.cc Array-so.cc Array-str.cc Array-idx-vec.cc \ - MArray-C.cc MArray-ch.cc MArray-i.cc MArray-d.cc MArray-s.cc + MArray-C.cc MArray-ch.cc MArray-i.cc MArray-d.cc MArray-s.cc \ + oct-inttypes.cc MATRIX_SRC := Array-flags.cc Array-util.cc CColVector.cc \ CDiagMatrix.cc CMatrix.cc CNDArray.cc CRowVector.cc \ diff -r 7b24fd17c263 -r 97b62f0c1bee liboctave/oct-inttypes.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/liboctave/oct-inttypes.cc Tue Nov 09 05:53:11 2004 +0000 @@ -0,0 +1,381 @@ +/* + +Copyright (C) 2004 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "oct-inttypes.h" + +#define INSTANTIATE_INT_DOUBLE_BIN_OP(T, OP) \ + template octave_int operator OP (const octave_int&, double) + +#define INSTANTIATE_INT_DOUBLE_BIN_OPS(T) \ + INSTANTIATE_INT_DOUBLE_BIN_OP (T, +); \ + INSTANTIATE_INT_DOUBLE_BIN_OP (T, -); \ + INSTANTIATE_INT_DOUBLE_BIN_OP (T, *); \ + INSTANTIATE_INT_DOUBLE_BIN_OP (T, /) + +#define INSTANTIATE_DOUBLE_INT_BIN_OP(T, OP) \ + template octave_int operator OP (double, const octave_int&) + +#define INSTANTIATE_DOUBLE_INT_BIN_OPS(T) \ + INSTANTIATE_DOUBLE_INT_BIN_OP (T, +); \ + INSTANTIATE_DOUBLE_INT_BIN_OP (T, -); \ + INSTANTIATE_DOUBLE_INT_BIN_OP (T, *); \ + INSTANTIATE_DOUBLE_INT_BIN_OP (T, /) + +#define INSTANTIATE_INT_DOUBLE_CMP_OP(T, OP) \ + template bool operator OP (const octave_int&, const double&) + +#define INSTANTIATE_INT_DOUBLE_CMP_OPS(T) \ + INSTANTIATE_INT_DOUBLE_CMP_OP (T, <); \ + INSTANTIATE_INT_DOUBLE_CMP_OP (T, <=); \ + INSTANTIATE_INT_DOUBLE_CMP_OP (T, >=); \ + INSTANTIATE_INT_DOUBLE_CMP_OP (T, >); \ + INSTANTIATE_INT_DOUBLE_CMP_OP (T, ==); \ + INSTANTIATE_INT_DOUBLE_CMP_OP (T, !=) + +#define INSTANTIATE_DOUBLE_INT_CMP_OP(T, OP) \ + template bool operator OP (const double&, const octave_int&) + +#define INSTANTIATE_DOUBLE_INT_CMP_OPS(T) \ + INSTANTIATE_DOUBLE_INT_CMP_OP (T, <); \ + INSTANTIATE_DOUBLE_INT_CMP_OP (T, <=); \ + INSTANTIATE_DOUBLE_INT_CMP_OP (T, >=); \ + INSTANTIATE_DOUBLE_INT_CMP_OP (T, >); \ + INSTANTIATE_DOUBLE_INT_CMP_OP (T, ==); \ + INSTANTIATE_DOUBLE_INT_CMP_OP (T, !=) + +#define INSTANTIATE_INT_BITCMP_OP(T, OP) \ + template octave_int \ + operator OP (const octave_int&, const octave_int&) + +#define INSTANTIATE_INT_BITCMP_OPS(T) \ + INSTANTIATE_INT_BITCMP_OP (T, &); \ + INSTANTIATE_INT_BITCMP_OP (T, |); \ + INSTANTIATE_INT_BITCMP_OP (T, ^) + +#define INSTANTIATE_INTTYPE(T) \ + template class octave_int; \ + template octave_int pow (const octave_int&, const octave_int&); \ + template octave_int pow (double, const octave_int&); \ + template octave_int pow (const octave_int&, double b); \ + template std::ostream& operator << (std::ostream&, const octave_int&); \ + template std::istream& operator >> (std::istream&, octave_int&); \ + template octave_int \ + bitshift (const octave_int&, int, const octave_int&); \ + INSTANTIATE_INT_DOUBLE_BIN_OPS (T); \ + INSTANTIATE_DOUBLE_INT_BIN_OPS (T); \ + INSTANTIATE_INT_DOUBLE_CMP_OPS (T); \ + INSTANTIATE_DOUBLE_INT_CMP_OPS (T); \ + INSTANTIATE_INT_BITCMP_OPS (T) + +INSTANTIATE_INTTYPE (octave_int8_t); +INSTANTIATE_INTTYPE (octave_int16_t); +INSTANTIATE_INTTYPE (octave_int32_t); +INSTANTIATE_INTTYPE (octave_int64_t); + +INSTANTIATE_INTTYPE (octave_uint8_t); +INSTANTIATE_INTTYPE (octave_uint16_t); +INSTANTIATE_INTTYPE (octave_uint32_t); +INSTANTIATE_INTTYPE (octave_uint64_t); + +#define INSTANTIATE_INTTYPE_BIN_OP(T1, T2, OP) \ + template octave_int::TR> \ + operator OP (const octave_int&, const octave_int&) + +#define INSTANTIATE_INTTYPE_BIN_OPS(T1, T2) \ + INSTANTIATE_INTTYPE_BIN_OP (T1, T2, +); \ + INSTANTIATE_INTTYPE_BIN_OP (T1, T2, -); \ + INSTANTIATE_INTTYPE_BIN_OP (T1, T2, *); \ + INSTANTIATE_INTTYPE_BIN_OP (T1, T2, /) + +INSTANTIATE_INTTYPE_BIN_OPS (octave_int8_t, octave_int8_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int8_t, octave_int16_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int8_t, octave_int32_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int8_t, octave_int64_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int8_t, octave_uint8_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int8_t, octave_uint16_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int8_t, octave_uint32_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int8_t, octave_uint64_t); + +INSTANTIATE_INTTYPE_BIN_OPS (octave_int16_t, octave_int8_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int16_t, octave_int16_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int16_t, octave_int32_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int16_t, octave_int64_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int16_t, octave_uint8_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int16_t, octave_uint16_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int16_t, octave_uint32_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int16_t, octave_uint64_t); + +INSTANTIATE_INTTYPE_BIN_OPS (octave_int32_t, octave_int8_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int32_t, octave_int16_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int32_t, octave_int32_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int32_t, octave_int64_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int32_t, octave_uint8_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int32_t, octave_uint16_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int32_t, octave_uint32_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int32_t, octave_uint64_t); + +INSTANTIATE_INTTYPE_BIN_OPS (octave_int64_t, octave_int8_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int64_t, octave_int16_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int64_t, octave_int32_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int64_t, octave_int64_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int64_t, octave_uint8_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int64_t, octave_uint16_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int64_t, octave_uint32_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_int64_t, octave_uint64_t); + +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint8_t, octave_int8_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint8_t, octave_int16_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint8_t, octave_int32_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint8_t, octave_int64_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint8_t, octave_uint8_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint8_t, octave_uint16_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint8_t, octave_uint32_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint8_t, octave_uint64_t); + +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint16_t, octave_int8_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint16_t, octave_int16_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint16_t, octave_int32_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint16_t, octave_int64_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint16_t, octave_uint8_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint16_t, octave_uint16_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint16_t, octave_uint32_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint16_t, octave_uint64_t); + +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint32_t, octave_int8_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint32_t, octave_int16_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint32_t, octave_int32_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint32_t, octave_int64_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint32_t, octave_uint8_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint32_t, octave_uint16_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint32_t, octave_uint32_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint32_t, octave_uint64_t); + +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint64_t, octave_int8_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint64_t, octave_int16_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint64_t, octave_int32_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint64_t, octave_int64_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint64_t, octave_uint8_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint64_t, octave_uint16_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint64_t, octave_uint32_t); +INSTANTIATE_INTTYPE_BIN_OPS (octave_uint64_t, octave_uint64_t); + +#define INSTANTIATE_INTTYPE_SHIFT_OP(T, OP) \ + template octave_int operator OP (const octave_int&, const int&) + +#define INSTANTIATE_INTTYPE_SHIFT_OPS(T) \ + INSTANTIATE_INTTYPE_SHIFT_OP (T, <<); \ + INSTANTIATE_INTTYPE_SHIFT_OP (T, >>) + +INSTANTIATE_INTTYPE_SHIFT_OPS (octave_int8_t); +INSTANTIATE_INTTYPE_SHIFT_OPS (octave_int16_t); +INSTANTIATE_INTTYPE_SHIFT_OPS (octave_int32_t); +INSTANTIATE_INTTYPE_SHIFT_OPS (octave_int64_t); +INSTANTIATE_INTTYPE_SHIFT_OPS (octave_uint8_t); +INSTANTIATE_INTTYPE_SHIFT_OPS (octave_uint16_t); +INSTANTIATE_INTTYPE_SHIFT_OPS (octave_uint32_t); +INSTANTIATE_INTTYPE_SHIFT_OPS (octave_uint64_t); + +#define INSTANTIATE_OCTAVE_INT_CMP_OP(OP, T1, T2) \ + template bool operator OP (const octave_int&, const octave_int&) + +#define INSTANTIATE_OCTAVE_INT_CMP_OPS(T1, T2) \ + INSTANTIATE_OCTAVE_INT_CMP_OP (<, T1, T2); \ + INSTANTIATE_OCTAVE_INT_CMP_OP (<=, T1, T2); \ + INSTANTIATE_OCTAVE_INT_CMP_OP (>=, T1, T2); \ + INSTANTIATE_OCTAVE_INT_CMP_OP (>, T1, T2); \ + INSTANTIATE_OCTAVE_INT_CMP_OP (==, T1, T2); \ + INSTANTIATE_OCTAVE_INT_CMP_OP (!=, T1, T2) + +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int8_t, octave_int8_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int8_t, octave_int16_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int8_t, octave_int32_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int8_t, octave_int64_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int8_t, octave_uint8_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int8_t, octave_uint16_t); +// INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int8_t, octave_uint32_t); +// INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int8_t, octave_uint64_t); + +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int16_t, octave_int8_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int16_t, octave_int16_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int16_t, octave_int32_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int16_t, octave_int64_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int16_t, octave_uint8_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int16_t, octave_uint16_t); +// INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int16_t, octave_uint32_t); +// INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int16_t, octave_uint64_t); + +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int32_t, octave_int8_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int32_t, octave_int16_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int32_t, octave_int32_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int32_t, octave_int64_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int32_t, octave_uint8_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int32_t, octave_uint16_t); +// INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int32_t, octave_uint32_t); +// INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int32_t, octave_uint64_t); + +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int64_t, octave_int8_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int64_t, octave_int16_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int64_t, octave_int32_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int64_t, octave_int64_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int64_t, octave_uint8_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int64_t, octave_uint16_t); +// INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int64_t, octave_uint32_t); +// INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_int64_t, octave_uint64_t); + +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint8_t, octave_int8_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint8_t, octave_int16_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint8_t, octave_int32_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint8_t, octave_int64_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint8_t, octave_uint8_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint8_t, octave_uint16_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint8_t, octave_uint32_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint8_t, octave_uint64_t); + +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint16_t, octave_int8_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint16_t, octave_int16_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint16_t, octave_int32_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint16_t, octave_int64_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint16_t, octave_uint8_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint16_t, octave_uint16_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint16_t, octave_uint32_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint16_t, octave_uint64_t); + +// INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint32_t, octave_int8_t); +// INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint32_t, octave_int16_t); +// INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint32_t, octave_int32_t); +// INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint32_t, octave_int64_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint32_t, octave_uint8_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint32_t, octave_uint16_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint32_t, octave_uint32_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint32_t, octave_uint64_t); + +// INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint64_t, octave_int8_t); +// INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint64_t, octave_int16_t); +// INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint64_t, octave_int32_t); +// INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint64_t, octave_int64_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint64_t, octave_uint8_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint64_t, octave_uint16_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint64_t, octave_uint32_t); +INSTANTIATE_OCTAVE_INT_CMP_OPS (octave_uint64_t, octave_uint64_t); + +// The following apply if the unsigned type is at least as wide as the +// signed type (then we can cast postive signed values to the unsigned +// type and compare). + +#define OCTAVE_US_TYPE1_CMP_OP(OP, LTZ_VAL, UT, ST) \ + bool \ + operator OP (const octave_int& lhs, const octave_int& rhs) \ + { \ + return rhs.value () < 0 ? LTZ_VAL \ + : lhs.value () OP static_cast (rhs.value ()); \ + } + +#define OCTAVE_US_TYPE1_CMP_OPS(UT, ST) \ + OCTAVE_US_TYPE1_CMP_OP (<, false, UT, ST) \ + OCTAVE_US_TYPE1_CMP_OP (<=, false, UT, ST) \ + OCTAVE_US_TYPE1_CMP_OP (>=, true, UT, ST) \ + OCTAVE_US_TYPE1_CMP_OP (>, true, UT, ST) \ + OCTAVE_US_TYPE1_CMP_OP (==, false, UT, ST) \ + OCTAVE_US_TYPE1_CMP_OP (!=, true, UT, ST) + +#define OCTAVE_SU_TYPE1_CMP_OP(OP, LTZ_VAL, ST, UT) \ + bool \ + operator OP (const octave_int& lhs, const octave_int& rhs) \ + { \ + return lhs.value () < 0 ? LTZ_VAL \ + : static_cast (lhs.value ()) OP rhs.value (); \ + } + +#define OCTAVE_SU_TYPE1_CMP_OPS(ST, UT) \ + OCTAVE_SU_TYPE1_CMP_OP (<, true, ST, UT) \ + OCTAVE_SU_TYPE1_CMP_OP (<=, true, ST, UT) \ + OCTAVE_SU_TYPE1_CMP_OP (>=, false, ST, UT) \ + OCTAVE_SU_TYPE1_CMP_OP (>, false, ST, UT) \ + OCTAVE_SU_TYPE1_CMP_OP (==, false, ST, UT) \ + OCTAVE_SU_TYPE1_CMP_OP (!=, true, ST, UT) + +#define OCTAVE_TYPE1_CMP_OPS(UT, ST) \ + OCTAVE_US_TYPE1_CMP_OPS (UT, ST) \ + OCTAVE_SU_TYPE1_CMP_OPS (ST, UT) + +OCTAVE_TYPE1_CMP_OPS (octave_uint32_t, octave_int8_t) +OCTAVE_TYPE1_CMP_OPS (octave_uint32_t, octave_int16_t) +OCTAVE_TYPE1_CMP_OPS (octave_uint32_t, octave_int32_t) + +OCTAVE_TYPE1_CMP_OPS (octave_uint64_t, octave_int8_t) +OCTAVE_TYPE1_CMP_OPS (octave_uint64_t, octave_int16_t) +OCTAVE_TYPE1_CMP_OPS (octave_uint64_t, octave_int32_t) +OCTAVE_TYPE1_CMP_OPS (octave_uint64_t, octave_int64_t) + +// The following apply if the signed type is wider than the unsigned +// type (then we can cast unsigned values to the signed type and +// compare if the signed value is positive). + +#define OCTAVE_US_TYPE2_CMP_OP(OP, LTZ_VAL, UT, ST) \ + bool \ + operator OP (const octave_int& lhs, const octave_int& rhs) \ + { \ + return rhs.value () < 0 ? LTZ_VAL \ + : static_cast (lhs.value ()) OP rhs.value (); \ + } + +#define OCTAVE_US_TYPE2_CMP_OPS(ST, UT) \ + OCTAVE_US_TYPE2_CMP_OP (<, false, ST, UT) \ + OCTAVE_US_TYPE2_CMP_OP (<=, false, ST, UT) \ + OCTAVE_US_TYPE2_CMP_OP (>=, true, ST, UT) \ + OCTAVE_US_TYPE2_CMP_OP (>, true, ST, UT) \ + OCTAVE_US_TYPE2_CMP_OP (==, false, ST, UT) \ + OCTAVE_US_TYPE2_CMP_OP (!=, true, ST, UT) + +#define OCTAVE_SU_TYPE2_CMP_OP(OP, LTZ_VAL, ST, UT) \ + bool \ + operator OP (const octave_int& lhs, const octave_int& rhs) \ + { \ + return lhs.value () < 0 ? LTZ_VAL \ + : lhs.value () OP static_cast (rhs.value ()); \ + } + +#define OCTAVE_SU_TYPE2_CMP_OPS(ST, UT) \ + OCTAVE_SU_TYPE2_CMP_OP (<, true, ST, UT) \ + OCTAVE_SU_TYPE2_CMP_OP (<=, true, ST, UT) \ + OCTAVE_SU_TYPE2_CMP_OP (>=, false, ST, UT) \ + OCTAVE_SU_TYPE2_CMP_OP (>, false, ST, UT) \ + OCTAVE_SU_TYPE2_CMP_OP (==, false, ST, UT) \ + OCTAVE_SU_TYPE2_CMP_OP (!=, true, ST, UT) + +#define OCTAVE_TYPE2_CMP_OPS(UT, ST) \ + OCTAVE_US_TYPE2_CMP_OPS (UT, ST) \ + OCTAVE_SU_TYPE2_CMP_OPS (ST, UT) + +OCTAVE_TYPE2_CMP_OPS (octave_uint32_t, octave_int64_t) + + + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/ diff -r 7b24fd17c263 -r 97b62f0c1bee liboctave/oct-inttypes.h --- a/liboctave/oct-inttypes.h Fri Feb 01 21:15:17 2008 -0500 +++ b/liboctave/oct-inttypes.h Tue Nov 09 05:53:11 2004 +0000 @@ -142,7 +142,7 @@ // This should always be OK because the maximum value should always be // positive. -#define US_S_FTR(T1, T2, TC) \ +#define OCTAVE_US_S_FTR(T1, T2, TC) \ template <> \ inline T2 \ octave_int_fit_to_range (const T1& x, const T2&, const T2& mx) \ @@ -150,26 +150,26 @@ return x > static_cast (mx) ? mx : x; \ } -#define US_S_FTR_FCNS(T) \ - US_S_FTR(T, char, unsigned char) \ - US_S_FTR(T, signed char, unsigned char) \ - US_S_FTR(T, short, unsigned short) \ - US_S_FTR(T, int, unsigned int) \ - US_S_FTR(T, long, unsigned long) \ - US_S_FTR(T, long long, unsigned long long) +#define OCTAVE_US_S_FTR_FCNS(T) \ + OCTAVE_US_S_FTR (T, char, unsigned char) \ + OCTAVE_US_S_FTR (T, signed char, unsigned char) \ + OCTAVE_US_S_FTR (T, short, unsigned short) \ + OCTAVE_US_S_FTR (T, int, unsigned int) \ + OCTAVE_US_S_FTR (T, long, unsigned long) \ + OCTAVE_US_S_FTR (T, long long, unsigned long long) -US_S_FTR_FCNS (unsigned char) -US_S_FTR_FCNS (unsigned short) -US_S_FTR_FCNS (unsigned int) -US_S_FTR_FCNS (unsigned long) -US_S_FTR_FCNS (unsigned long long) +OCTAVE_US_S_FTR_FCNS (unsigned char) +OCTAVE_US_S_FTR_FCNS (unsigned short) +OCTAVE_US_S_FTR_FCNS (unsigned int) +OCTAVE_US_S_FTR_FCNS (unsigned long) +OCTAVE_US_S_FTR_FCNS (unsigned long long) // If X is signed and the new type is unsigned, then we only have to // check the lower limit (which will always be 0 for an unsigned // type). The upper limit will be enforced correctly by converting to // the new type, even if the type of X is wider than the new type. -#define S_US_FTR(T1, T2) \ +#define OCTAVE_S_US_FTR(T1, T2) \ template <> \ inline T2 \ octave_int_fit_to_range (const T1& x, const T2&, const T2&) \ @@ -177,19 +177,19 @@ return x < 0 ? 0 : x; \ } -#define S_US_FTR_FCNS(T) \ - S_US_FTR(T, unsigned char) \ - S_US_FTR(T, unsigned short) \ - S_US_FTR(T, unsigned int) \ - S_US_FTR(T, unsigned long) \ - S_US_FTR(T, unsigned long long) +#define OCTAVE_S_US_FTR_FCNS(T) \ + OCTAVE_S_US_FTR (T, unsigned char) \ + OCTAVE_S_US_FTR (T, unsigned short) \ + OCTAVE_S_US_FTR (T, unsigned int) \ + OCTAVE_S_US_FTR (T, unsigned long) \ + OCTAVE_S_US_FTR (T, unsigned long long) -S_US_FTR_FCNS (char) -S_US_FTR_FCNS (signed char) -S_US_FTR_FCNS (short) -S_US_FTR_FCNS (int) -S_US_FTR_FCNS (long) -S_US_FTR_FCNS (long long) +OCTAVE_S_US_FTR_FCNS (char) +OCTAVE_S_US_FTR_FCNS (signed char) +OCTAVE_S_US_FTR_FCNS (short) +OCTAVE_S_US_FTR_FCNS (int) +OCTAVE_S_US_FTR_FCNS (long) +OCTAVE_S_US_FTR_FCNS (long long) #define OCTAVE_INT_FIT_TO_RANGE(r, T) \ octave_int_fit_to_range (r, \ @@ -405,7 +405,6 @@ typedef octave_int octave_uint64; #define OCTAVE_INT_BIN_OP(OP) \ - \ template \ octave_int::TR> \ operator OP (const octave_int& x, const octave_int& y) \ @@ -431,7 +430,6 @@ } #define OCTAVE_INT_DOUBLE_BIN_OP(OP) \ - \ template \ octave_int \ operator OP (const octave_int& x, double y) \ @@ -448,7 +446,6 @@ OCTAVE_INT_DOUBLE_BIN_OP(/) #define OCTAVE_DOUBLE_INT_BIN_OP(OP) \ - \ template \ octave_int \ operator OP (double x, const octave_int& y) \ @@ -497,7 +494,6 @@ OCTAVE_DOUBLE_INT_CMP_OP (!=) #define OCTAVE_INT_BITCMP_OP(OP) \ - \ template \ octave_int \ operator OP (const octave_int& x, const octave_int& y) \ @@ -538,18 +534,12 @@ return a; } -// XXX FIXME XXX -- need partial specializations for int64 and uint64 -// types. - #define OCTAVE_INT_CMP_OP(OP) \ - \ template \ bool \ operator OP (const octave_int& x, const octave_int& y) \ { \ - double tx = static_cast (x.value ()); \ - double ty = static_cast (y.value ()); \ - return tx OP ty; \ + return x.value () OP y.value (); \ } OCTAVE_INT_CMP_OP (<) @@ -559,6 +549,77 @@ OCTAVE_INT_CMP_OP (==) OCTAVE_INT_CMP_OP (!=) +// The following apply if the unsigned type is at least as wide as the +// signed type (then we can cast postive signed values to the unsigned +// type and compare). + +#define OCTAVE_US_TYPE1_CMP_OP_DECL(OP, LTZ_VAL, UT, ST) \ + bool operator OP (const octave_int& lhs, const octave_int& rhs); + +#define OCTAVE_US_TYPE1_CMP_OP_DECLS(UT, ST) \ + OCTAVE_US_TYPE1_CMP_OP_DECL (<, false, UT, ST) \ + OCTAVE_US_TYPE1_CMP_OP_DECL (<=, false, UT, ST) \ + OCTAVE_US_TYPE1_CMP_OP_DECL (>=, true, UT, ST) \ + OCTAVE_US_TYPE1_CMP_OP_DECL (>, true, UT, ST) \ + OCTAVE_US_TYPE1_CMP_OP_DECL (==, false, UT, ST) \ + OCTAVE_US_TYPE1_CMP_OP_DECL (!=, true, UT, ST) + +#define OCTAVE_SU_TYPE1_CMP_OP_DECL(OP, LTZ_VAL, ST, UT) \ + bool operator OP (const octave_int& lhs, const octave_int& rhs); + +#define OCTAVE_SU_TYPE1_CMP_OP_DECLS(ST, UT) \ + OCTAVE_SU_TYPE1_CMP_OP_DECL (<, true, ST, UT) \ + OCTAVE_SU_TYPE1_CMP_OP_DECL (<=, true, ST, UT) \ + OCTAVE_SU_TYPE1_CMP_OP_DECL (>=, false, ST, UT) \ + OCTAVE_SU_TYPE1_CMP_OP_DECL (>, false, ST, UT) \ + OCTAVE_SU_TYPE1_CMP_OP_DECL (==, false, ST, UT) \ + OCTAVE_SU_TYPE1_CMP_OP_DECL (!=, true, ST, UT) + +#define OCTAVE_TYPE1_CMP_OP_DECLS(UT, ST) \ + OCTAVE_US_TYPE1_CMP_OP_DECLS (UT, ST) \ + OCTAVE_SU_TYPE1_CMP_OP_DECLS (ST, UT) + +OCTAVE_TYPE1_CMP_OP_DECLS (octave_uint32_t, octave_int8_t) +OCTAVE_TYPE1_CMP_OP_DECLS (octave_uint32_t, octave_int16_t) +OCTAVE_TYPE1_CMP_OP_DECLS (octave_uint32_t, octave_int32_t) + +OCTAVE_TYPE1_CMP_OP_DECLS (octave_uint64_t, octave_int8_t) +OCTAVE_TYPE1_CMP_OP_DECLS (octave_uint64_t, octave_int16_t) +OCTAVE_TYPE1_CMP_OP_DECLS (octave_uint64_t, octave_int32_t) +OCTAVE_TYPE1_CMP_OP_DECLS (octave_uint64_t, octave_int64_t) + +// The following apply if the signed type is wider than the unsigned +// type (then we can cast unsigned values to the signed type and +// compare if the signed value is positive). + +#define OCTAVE_US_TYPE2_CMP_OP_DECL(OP, LTZ_VAL, UT, ST) \ + bool operator OP (const octave_int& lhs, const octave_int& rhs); + +#define OCTAVE_US_TYPE2_CMP_OP_DECLS(ST, UT) \ + OCTAVE_US_TYPE2_CMP_OP_DECL (<, false, ST, UT) \ + OCTAVE_US_TYPE2_CMP_OP_DECL (<=, false, ST, UT) \ + OCTAVE_US_TYPE2_CMP_OP_DECL (>=, true, ST, UT) \ + OCTAVE_US_TYPE2_CMP_OP_DECL (>, true, ST, UT) \ + OCTAVE_US_TYPE2_CMP_OP_DECL (==, false, ST, UT) \ + OCTAVE_US_TYPE2_CMP_OP_DECL (!=, true, ST, UT) + +#define OCTAVE_SU_TYPE2_CMP_OP_DECL(OP, LTZ_VAL, ST, UT) \ + bool operator OP (const octave_int& lhs, const octave_int& rhs); + +#define OCTAVE_SU_TYPE2_CMP_OP_DECLS(ST, UT) \ + OCTAVE_SU_TYPE2_CMP_OP_DECL (<, true, ST, UT) \ + OCTAVE_SU_TYPE2_CMP_OP_DECL (<=, true, ST, UT) \ + OCTAVE_SU_TYPE2_CMP_OP_DECL (>=, false, ST, UT) \ + OCTAVE_SU_TYPE2_CMP_OP_DECL (>, false, ST, UT) \ + OCTAVE_SU_TYPE2_CMP_OP_DECL (==, false, ST, UT) \ + OCTAVE_SU_TYPE2_CMP_OP_DECL (!=, true, ST, UT) + +#define OCTAVE_TYPE2_CMP_OP_DECLS(UT, ST) \ + OCTAVE_US_TYPE2_CMP_OP_DECLS (UT, ST) \ + OCTAVE_SU_TYPE2_CMP_OP_DECLS (ST, UT) + +OCTAVE_TYPE2_CMP_OP_DECLS (octave_uint32_t, octave_int64_t) + #define OCTAVE_INT_CONCAT_FN(TYPE) \ intNDArray< TYPE > \ concat (const intNDArray< TYPE >& ra, const intNDArray< TYPE >& rb, \ @@ -574,16 +635,32 @@ concat (const intNDArray< TYPE >& ra, const intNDArray< TYPE >& rb, \ const Array& ra_idx); -#undef OCTAVE_INT_TRAIT #undef OCTAVE_INT_BINOP_TRAIT -#undef OCTAVE_INT_MIN_VAL -#undef OCTAVE_INT_MAX_VAL +#undef OCTAVE_US_S_FTR +#undef OCTAVE_US_S_FTR_FCNS +#undef OCTAVE_S_US_FTR +#undef OCTAVE_S_US_FTR_FCNS #undef OCTAVE_INT_FIT_TO_RANGE #undef OCTAVE_INT_MIN_VAL2 #undef OCTAVE_INT_MAX_VAL2 #undef OCTAVE_INT_FIT_TO_RANGE2 #undef OCTAVE_INT_BIN_OP +#undef OCTAVE_INT_DOUBLE_BIN_OP +#undef OCTAVE_DOUBLE_INT_BIN_OP +#undef OCTAVE_INT_DOUBLE_CMP_OP +#undef OCTAVE_DOUBLE_INT_CMP_OP +#undef OCTAVE_INT_BITCMP_OP #undef OCTAVE_INT_CMP_OP +#undef OCTAVE_US_TYPE1_CMP_OP_DECL +#undef OCTAVE_US_TYPE1_CMP_OP_DECLS +#undef OCTAVE_SU_TYPE1_CMP_OP_DECL +#undef OCTAVE_SU_TYPE1_CMP_OP_DECLS +#undef OCTAVE_TYPE1_CMP_OP_DECLS +#undef OCTAVE_US_TYPE2_CMP_OP_DECL +#undef OCTAVE_US_TYPE2_CMP_OP_DECLS +#undef OCTAVE_SU_TYPE2_CMP_OP_DECL +#undef OCTAVE_SU_TYPE2_CMP_OP_DECLS +#undef OCTAVE_TYPE2__DECLS #endif diff -r 7b24fd17c263 -r 97b62f0c1bee scripts/ChangeLog --- a/scripts/ChangeLog Fri Feb 01 21:15:17 2008 -0500 +++ b/scripts/ChangeLog Tue Nov 09 05:53:11 2004 +0000 @@ -1,3 +1,8 @@ +2004-11-08 John W. Eaton + + * plot/__plt2vm__.m: Delete debugging statement. + From Dmitri A. Sergatskov . + 2004-11-04 John W. Eaton * plot/hist.m: Always return row vectors for vector args. diff -r 7b24fd17c263 -r 97b62f0c1bee scripts/plot/__plt2vm__.m --- a/scripts/plot/__plt2vm__.m Fri Feb 01 21:15:17 2008 -0500 +++ b/scripts/plot/__plt2vm__.m Tue Nov 09 05:53:11 2004 +0000 @@ -70,7 +70,6 @@ k++; endif endfor - cmd eval (cmd); else error ("__plt2vm__: arguments must be a matrices");