Mercurial > hg > octave-terminal
changeset 4646:eff8f977508c
[project @ 2003-11-23 18:13:19 by jwe]
author | jwe |
---|---|
date | Sun, 23 Nov 2003 18:13:19 +0000 |
parents | bd2067547b40 |
children | 6d26997e1fc3 |
files | liboctave/ChangeLog liboctave/MArray-defs.h liboctave/MArray.cc liboctave/MArray2.cc liboctave/MArrayN.cc liboctave/MDiagArray2.cc liboctave/Makefile.in src/ChangeLog src/OPERATORS/op-streamoff.cc src/ov-streamoff.cc src/ov-streamoff.h |
diffstat | 11 files changed, 40 insertions(+), 148 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,11 @@ +2003-11-23 John W. Eaton <jwe@bevo.che.wisc.edu> + + * 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 <jwe@bevo.che.wisc.edu> * MArrayN.cc (operator -=, operator +=): Check dimensions, not
--- a/liboctave/MArray-defs.h +++ b/liboctave/MArray-defs.h @@ -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 (); \
--- a/liboctave/MArray.cc +++ b/liboctave/MArray.cc @@ -41,7 +41,7 @@ MArray<T>& operator += (MArray<T>& a, const T& s) { - DO_VS_OP2 (+=) + DO_VS_OP2 (T, a, +=, s) return a; } @@ -49,7 +49,7 @@ MArray<T>& operator -= (MArray<T>& 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; }
--- a/liboctave/MArray2.cc +++ b/liboctave/MArray2.cc @@ -41,7 +41,7 @@ MArray2<T>& operator += (MArray2<T>& a, const T& s) { - DO_VS_OP2 (+=) + DO_VS_OP2 (T, a, +=, s) return a; } @@ -49,7 +49,7 @@ MArray2<T>& operator -= (MArray2<T>& 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;
--- a/liboctave/MArrayN.cc +++ b/liboctave/MArrayN.cc @@ -42,7 +42,7 @@ MArrayN<T>& operator += (MArrayN<T>& a, const T& s) { - DO_VS_OP2 (+=) + DO_VS_OP2 (T, a, +=, s) return a; } @@ -50,7 +50,7 @@ MArrayN<T>& operator -= (MArrayN<T>& 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; }
--- a/liboctave/MDiagArray2.cc +++ b/liboctave/MDiagArray2.cc @@ -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; }
--- a/liboctave/Makefile.in +++ b/liboctave/Makefile.in @@ -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) \
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2003-11-23 John W. Eaton <jwe@bevo.che.wisc.edu> + * 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.
--- a/src/OPERATORS/op-streamoff.cc +++ b/src/OPERATORS/op-streamoff.cc @@ -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);
--- a/src/ov-streamoff.cc +++ b/src/ov-streamoff.cc @@ -30,83 +30,23 @@ #include <iostream> -#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<std::streamoff>; - template class octave_base_matrix<streamoff_array>; 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<int>& 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
--- a/src/ov-streamoff.h +++ b/src/ov-streamoff.h @@ -28,15 +28,11 @@ #endif #include <iostream> -#include <string> -#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<std::streamoff> -{ -public: - - streamoff_array (void) : ArrayN<std::streamoff> () { } - - streamoff_array (const dim_vector& dv, - const std::streamoff& val = resize_fill_value ()) - : ArrayN<std::streamoff> (dv, val) { } - - streamoff_array (const ArrayN<std::streamoff>& sa) - : ArrayN<std::streamoff> (sa) { } - - streamoff_array (const streamoff_array& sa) - : ArrayN<std::streamoff> (sa) { } - - ~streamoff_array (void) { } - - streamoff_array& operator = (const streamoff_array& a) - { - if (this != &a) - ArrayN<std::streamoff>::operator = (a); - - return *this; - } - - streamoff_array squeeze (void) const - { return ArrayN<std::streamoff>::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<int>& 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<streamoff_array> { @@ -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; }