# HG changeset patch # User jwe # Date 1069611199 0 # Node ID eff8f977508cd953fd33d154339d0752bf2f3ab7 # Parent bd2067547b40cd8f89c0b91806819593845ad82f [project @ 2003-11-23 18:13:19 by jwe] diff -r bd2067547b40 -r eff8f977508c liboctave/ChangeLog --- a/liboctave/ChangeLog Sun Nov 23 08:07:53 2003 +0000 +++ b/liboctave/ChangeLog Sun Nov 23 18:13:19 2003 +0000 @@ -1,3 +1,11 @@ +2003-11-23 John W. Eaton + + * MArray-defs.h (DO_VS_OP2, DO_VV_OP2): Accept args for element + type and the names of the left and right operands. Change all uses. + + * so-array.cc, so-array.h: New files. Move streamoff_array here + from src/ov-streamoff.h and src/ov-streamoff.cc. + 2003-11-20 John W. Eaton * MArrayN.cc (operator -=, operator +=): Check dimensions, not diff -r bd2067547b40 -r eff8f977508c liboctave/MArray-defs.h --- a/liboctave/MArray-defs.h Sun Nov 23 08:07:53 2003 +0000 +++ b/liboctave/MArray-defs.h Sun Nov 23 18:13:19 2003 +0000 @@ -31,7 +31,7 @@ r[i] = -x[i]; \ } -#define DO_VS_OP2(OP) \ +#define DO_VS_OP2(T, a, OP, s) \ int l = a.length (); \ if (l > 0) \ { \ @@ -40,7 +40,7 @@ tmp[i] OP s; \ } -#define DO_VV_OP2(OP) \ +#define DO_VV_OP2(T, a, OP, b) \ do \ { \ T *a_tmp = a.fortran_vec (); \ diff -r bd2067547b40 -r eff8f977508c liboctave/MArray.cc --- a/liboctave/MArray.cc Sun Nov 23 08:07:53 2003 +0000 +++ b/liboctave/MArray.cc Sun Nov 23 18:13:19 2003 +0000 @@ -41,7 +41,7 @@ MArray& operator += (MArray& a, const T& s) { - DO_VS_OP2 (+=) + DO_VS_OP2 (T, a, +=, s) return a; } @@ -49,7 +49,7 @@ MArray& operator -= (MArray& a, const T& s) { - DO_VS_OP2 (-=) + DO_VS_OP2 (T, a, -=, s) return a; } @@ -66,7 +66,7 @@ if (l != bl) gripe_nonconformant ("operator +=", l, bl); else - DO_VV_OP2 (+=); + DO_VV_OP2 (T, a, +=, b); } return a; } @@ -82,7 +82,7 @@ if (l != bl) gripe_nonconformant ("operator -=", l, bl); else - DO_VV_OP2 (-=); + DO_VV_OP2 (T, a, -=, b); } return a; } diff -r bd2067547b40 -r eff8f977508c liboctave/MArray2.cc --- a/liboctave/MArray2.cc Sun Nov 23 08:07:53 2003 +0000 +++ b/liboctave/MArray2.cc Sun Nov 23 18:13:19 2003 +0000 @@ -41,7 +41,7 @@ MArray2& operator += (MArray2& a, const T& s) { - DO_VS_OP2 (+=) + DO_VS_OP2 (T, a, +=, s) return a; } @@ -49,7 +49,7 @@ MArray2& operator -= (MArray2& a, const T& s) { - DO_VS_OP2 (-=) + DO_VS_OP2 (T, a, -=, s) return a; } @@ -70,7 +70,7 @@ if (r > 0 && c > 0) { int l = a.length (); - DO_VV_OP2 (+=); + DO_VV_OP2 (T, a, +=, b); } } return a; @@ -91,7 +91,7 @@ if (r > 0 && c > 0) { int l = a.length (); - DO_VV_OP2 (-=); + DO_VV_OP2 (T, a, -=, b); } } return a; diff -r bd2067547b40 -r eff8f977508c liboctave/MArrayN.cc --- a/liboctave/MArrayN.cc Sun Nov 23 08:07:53 2003 +0000 +++ b/liboctave/MArrayN.cc Sun Nov 23 18:13:19 2003 +0000 @@ -42,7 +42,7 @@ MArrayN& operator += (MArrayN& a, const T& s) { - DO_VS_OP2 (+=) + DO_VS_OP2 (T, a, +=, s) return a; } @@ -50,7 +50,7 @@ MArrayN& operator -= (MArrayN& a, const T& s) { - DO_VS_OP2 (-=) + DO_VS_OP2 (T, a, -=, s) return a; } @@ -70,7 +70,7 @@ if (a_dims != b_dims) gripe_nonconformant ("operator +=", a_dims, b_dims); else - DO_VV_OP2 (+=); + DO_VV_OP2 (T, a, +=, b); } return a; @@ -90,7 +90,7 @@ if (a_dims != b_dims) gripe_nonconformant ("operator -=", a_dims, b_dims); else - DO_VV_OP2 (-=); + DO_VV_OP2 (T, a, -=, b); } return a; } diff -r bd2067547b40 -r eff8f977508c liboctave/MDiagArray2.cc --- a/liboctave/MDiagArray2.cc Sun Nov 23 08:07:53 2003 +0000 +++ b/liboctave/MDiagArray2.cc Sun Nov 23 18:13:19 2003 +0000 @@ -58,7 +58,7 @@ else { int l = a.length (); - DO_VV_OP2 (+=); + DO_VV_OP2 (T, a, +=, b); } return a; } @@ -81,7 +81,7 @@ else { int l = a.length (); - DO_VV_OP2 (-=); + DO_VV_OP2 (T, a, -=, b); } return a; } diff -r bd2067547b40 -r eff8f977508c liboctave/Makefile.in --- a/liboctave/Makefile.in Sun Nov 23 08:07:53 2003 +0000 +++ b/liboctave/Makefile.in Sun Nov 23 18:13:19 2003 +0000 @@ -59,7 +59,7 @@ oct-env.h oct-fftw.h oct-getopt.h oct-group.h oct-passwd.h \ oct-rand.h oct-rl-edit.h oct-rl-hist.h oct-shlib.h \ oct-syscalls.h oct-time.h pathlen.h pathsearch.h \ - prog-args.h statdefs.h str-vec.h sun-utils.h sysdir.h \ + prog-args.h so-array.h statdefs.h str-vec.h sun-utils.h sysdir.h \ systime.h syswait.h \ $(OPTS_INC) \ $(MATRIX_INC) \ @@ -95,7 +95,7 @@ lo-ieee.cc lo-mappers.cc lo-specfun.cc lo-sysdep.cc \ lo-utils.cc mach-info.cc oct-alloc.cc oct-env.cc \ oct-fftw.cc oct-group.cc oct-passwd.cc oct-rand.cc oct-shlib.cc \ - oct-syscalls.cc oct-time.cc prog-args.cc str-vec.cc \ + oct-syscalls.cc oct-time.cc prog-args.cc so-array.cc str-vec.cc \ $(TEMPLATE_SRC) \ $(TI_SRC) \ $(MATRIX_SRC) \ diff -r bd2067547b40 -r eff8f977508c src/ChangeLog --- a/src/ChangeLog Sun Nov 23 08:07:53 2003 +0000 +++ b/src/ChangeLog Sun Nov 23 18:13:19 2003 +0000 @@ -1,5 +1,9 @@ 2003-11-23 John W. Eaton + * OPERATORS/op-streamoff.cc: Install increment and decrement operators. + * ov-streamoff.h (octave_streamoff::increment, + octave_streamoff::decrement): New functions. + * oct-stream.cc (octave_stream::seek): Extract std::streamoff from tc_offset instead of int. diff -r bd2067547b40 -r eff8f977508c src/OPERATORS/op-streamoff.cc --- a/src/OPERATORS/op-streamoff.cc Sun Nov 23 08:07:53 2003 +0000 +++ b/src/OPERATORS/op-streamoff.cc Sun Nov 23 18:13:19 2003 +0000 @@ -41,8 +41,8 @@ return octave_value (streamoff_array (v.streamoff_array_value().transpose ())); } -// DEFNCUNOP_METHOD (incr, streamoff, increment) -// DEFNCUNOP_METHOD (decr, streamoff, decrement) +DEFNCUNOP_METHOD (incr, streamoff, increment) +DEFNCUNOP_METHOD (decr, streamoff, decrement) // streamoff by streamoff ops. @@ -131,6 +131,9 @@ INSTALL_UNOP (op_transpose, octave_streamoff, transpose); INSTALL_UNOP (op_hermitian, octave_streamoff, transpose); + INSTALL_NCUNOP (op_incr, octave_streamoff, incr); + INSTALL_NCUNOP (op_decr, octave_streamoff, decr); + INSTALL_BINOP (op_eq, octave_streamoff, octave_streamoff, eq); INSTALL_BINOP (op_ne, octave_streamoff, octave_streamoff, ne); diff -r bd2067547b40 -r eff8f977508c src/ov-streamoff.cc --- a/src/ov-streamoff.cc Sun Nov 23 08:07:53 2003 +0000 +++ b/src/ov-streamoff.cc Sun Nov 23 18:13:19 2003 +0000 @@ -30,83 +30,23 @@ #include -#include "Array.h" -#include "Array.cc" -#include "ArrayN.h" -#include "ArrayN.cc" +#include "so-array.h" #include "defun.h" #include "error.h" #include "gripes.h" #include "ov-streamoff.h" #include "oct-obj.h" -#include "unwind-prot.h" #include "utils.h" #include "ov-base-mat.h" #include "ov-base-mat.cc" -INSTANTIATE_ARRAY_AND_ASSIGN (std::streamoff); - -template class ArrayN; - template class octave_base_matrix; DEFINE_OCTAVE_ALLOCATOR (octave_streamoff); DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_streamoff, "streamoff", "streamoff"); -boolNDArray -streamoff_array::all (int dim) const -{ - MX_ND_ANY_ALL_REDUCTION (MX_ND_ALL_EVAL (MX_ND_ALL_EXPR), true); -} - -boolNDArray -streamoff_array::any (int dim) const -{ - MX_ND_ANY_ALL_REDUCTION (MX_ND_ANY_EVAL (MX_ND_ANY_EXPR), false); -} - -#if 0 -streamoff_array& -streamoff_array::operator += (const streamoff_array& a) -{ - // XXX FIXME XXX - return *this; -} - -streamoff_array& -streamoff_array::operator -= (const streamoff_array& a) -{ - // XXX FIXME XXX - return *this; -} -#endif - -int -streamoff_array::compute_index (Array& ra_idx, - const dim_vector& dimensions) -{ - return ::compute_index (ra_idx, dimensions); -} - -SND_CMP_OP (mx_el_eq, ==, std::streamoff, , streamoff_array, , FBM) -SND_CMP_OP (mx_el_ne, !=, std::streamoff, , streamoff_array, , TBM) - -NDS_CMP_OP (mx_el_eq, ==, streamoff_array, , std::streamoff, , FBM) -NDS_CMP_OP (mx_el_ne, !=, streamoff_array, , std::streamoff, , TBM) - -NDND_CMP_OP (mx_el_eq, ==, streamoff_array, , streamoff_array, , FBM, TBM) -NDND_CMP_OP (mx_el_ne, !=, streamoff_array, , streamoff_array, , TBM, FBM) - -NDND_BIN_OP (streamoff_array, operator +, streamoff_array, streamoff_array, mx_inline_add) -NDND_BIN_OP (streamoff_array, operator -, streamoff_array, streamoff_array, mx_inline_subtract) - -NDS_BIN_OP (streamoff_array, operator +, streamoff_array, std::streamoff, mx_inline_add) -NDS_BIN_OP (streamoff_array, operator -, streamoff_array, std::streamoff, mx_inline_subtract) - -SND_BIN_OP (streamoff_array, operator +, std::streamoff, streamoff_array, mx_inline_add) -SND_BIN_OP (streamoff_array, operator -, std::streamoff, streamoff_array, mx_inline_subtract) std::streamoff octave_streamoff::streamoff_value (void) const diff -r bd2067547b40 -r eff8f977508c src/ov-streamoff.h --- a/src/ov-streamoff.h Sun Nov 23 08:07:53 2003 +0000 +++ b/src/ov-streamoff.h Sun Nov 23 18:13:19 2003 +0000 @@ -28,15 +28,11 @@ #endif #include -#include -#include "mx-base.h" -#include "mx-op-defs.h" +#include "so-array.h" #include "oct-alloc.h" -#include "str-vec.h" -#include "error.h" -#include "oct-obj.h" +#include "ov.h" #include "ov-base-mat.h" #include "ov-typeinfo.h" @@ -44,65 +40,6 @@ // Stream offsets. -class streamoff_array : public ArrayN -{ -public: - - streamoff_array (void) : ArrayN () { } - - streamoff_array (const dim_vector& dv, - const std::streamoff& val = resize_fill_value ()) - : ArrayN (dv, val) { } - - streamoff_array (const ArrayN& sa) - : ArrayN (sa) { } - - streamoff_array (const streamoff_array& sa) - : ArrayN (sa) { } - - ~streamoff_array (void) { } - - streamoff_array& operator = (const streamoff_array& a) - { - if (this != &a) - ArrayN::operator = (a); - - return *this; - } - - streamoff_array squeeze (void) const - { return ArrayN::squeeze (); } - - boolNDArray all (int dim = -1) const; - boolNDArray any (int dim = -1) const; - - // streamoff_array& operator += (const streamoff_array& a); - // streamoff_array& operator -= (const streamoff_array& a); - - static int compute_index (Array& ra_idx, - const dim_vector& dimensions); - - static std::streamoff resize_fill_value (void) { return 0; } -}; - -NDCMP_OP_DECL (mx_el_eq, std::streamoff, streamoff_array); -NDCMP_OP_DECL (mx_el_ne, std::streamoff, streamoff_array); - -NDCMP_OP_DECL (mx_el_eq, streamoff_array, std::streamoff); -NDCMP_OP_DECL (mx_el_ne, streamoff_array, std::streamoff); - -NDCMP_OP_DECL (mx_el_eq, streamoff_array, streamoff_array); -NDCMP_OP_DECL (mx_el_ne, streamoff_array, streamoff_array); - -BIN_OP_DECL (streamoff_array, operator +, streamoff_array, streamoff_array); -BIN_OP_DECL (streamoff_array, operator -, streamoff_array, streamoff_array); - -BIN_OP_DECL (streamoff_array, operator +, streamoff_array, std::streamoff); -BIN_OP_DECL (streamoff_array, operator -, streamoff_array, std::streamoff); - -BIN_OP_DECL (streamoff_array, operator +, std::streamoff, streamoff_array); -BIN_OP_DECL (streamoff_array, operator -, std::streamoff, streamoff_array); - class octave_streamoff : public octave_base_matrix { @@ -134,9 +71,9 @@ streamoff_array streamoff_array_value (void) const { return matrix; } - // void increment (void) { matrix += 1; } + void increment (void) { matrix += std::streamoff (1); } - // void decrement (void) { matrix -= 1; } + void decrement (void) { matrix -= std::streamoff (1); } bool print_as_scalar (void) const { return true; }