Mercurial > hg > octave-nkf
changeset 4669:334a27c8f453
[project @ 2003-11-26 07:02:42 by jwe]
author | jwe |
---|---|
date | Wed, 26 Nov 2003 07:02:42 +0000 |
parents | 7849788ca4bd |
children | 4ad69c3588a9 |
files | liboctave/Array-util.cc liboctave/Array-util.h liboctave/CColVector.cc liboctave/CDiagMatrix.cc liboctave/CMatrix.cc liboctave/CRowVector.cc liboctave/ChangeLog liboctave/MArray-misc.cc liboctave/MArray.cc liboctave/MArray.h liboctave/MArray2.cc liboctave/MArray2.h liboctave/MArrayN.cc liboctave/MArrayN.h liboctave/MDiagArray2.cc liboctave/Makefile.in liboctave/boolMatrix.cc liboctave/boolNDArray.cc liboctave/boolNDArray.h liboctave/dColVector.cc liboctave/dDiagMatrix.cc liboctave/dMatrix.cc liboctave/dRowVector.cc liboctave/mk-ops.awk liboctave/mx-ops src/ChangeLog src/Makefile.in src/OPERATORS/op-b-bm.cc src/OPERATORS/op-bm-b.cc src/OPERATORS/op-bm-bm.cc src/ops.h src/xdiv.cc src/xpow.cc |
diffstat | 33 files changed, 186 insertions(+), 84 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array-util.cc +++ b/liboctave/Array-util.cc @@ -25,6 +25,8 @@ #endif #include "Array-util.h" +#include "dim-vector.h" +#include "lo-error.h" bool index_in_bounds (const Array<int>& ra_idx, const dim_vector& dimensions) @@ -531,6 +533,35 @@ return retval; } +void +gripe_nonconformant (const char *op, int op1_len, int op2_len) +{ + (*current_liboctave_error_handler) + ("%s: nonconformant arguments (op1 len: %d, op2 len: %d)", + op, op1_len, op2_len); +} + +void +gripe_nonconformant (const char *op, int op1_nr, int op1_nc, + int op2_nr, int op2_nc) +{ + (*current_liboctave_error_handler) + ("%s: nonconformant arguments (op1 is %dx%d, op2 is %dx%d)", + op, op1_nr, op1_nc, op2_nr, op2_nc); +} + +void +gripe_nonconformant (const char *op, dim_vector& op1_dims, + dim_vector& op2_dims) +{ + std::string op1_dims_str = op1_dims.str (); + std::string op2_dims_str = op2_dims.str (); + + (*current_liboctave_error_handler) + ("%s: nonconformant arguments (op1 is %s, op2 is %s)", + op, op1_dims_str.c_str (), op2_dims_str.c_str ()); +} + /* ;;; Local Variables: *** ;;; mode: C++ ***
--- a/liboctave/Array-util.h +++ b/liboctave/Array-util.h @@ -89,6 +89,16 @@ extern Array<int> calc_permutated_idx (const Array<int>& old_idx, const Array<int>& perm_vec, bool inv); + +extern void gripe_nonconformant (const char *op, int op1_len, int op2_len); + +extern void gripe_nonconformant (const char *op, int op1_nr, int op1_nc, + int op2_nr, int op2_nc); + + +extern void gripe_nonconformant (const char *op, dim_vector& op1_dims, + dim_vector& op2_dims); + #endif /*
--- a/liboctave/CColVector.cc +++ b/liboctave/CColVector.cc @@ -31,6 +31,7 @@ #include <iostream> +#include "Array-util.h" #include "f77-fcn.h" #include "lo-error.h" #include "mx-base.h"
--- a/liboctave/CDiagMatrix.cc +++ b/liboctave/CDiagMatrix.cc @@ -31,6 +31,7 @@ #include <iostream> +#include "Array-util.h" #include "lo-error.h" #include "mx-base.h" #include "mx-inlines.cc"
--- a/liboctave/CMatrix.cc +++ b/liboctave/CMatrix.cc @@ -38,6 +38,7 @@ #include <sys/types.h> #endif +#include "Array-util.h" #include "CMatrix.h" #include "CmplxAEPBAL.h" #include "CmplxDET.h"
--- a/liboctave/CRowVector.cc +++ b/liboctave/CRowVector.cc @@ -31,6 +31,7 @@ #include <iostream> +#include "Array-util.h" #include "f77-fcn.h" #include "lo-error.h" #include "mx-base.h"
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,21 @@ +2003-11-26 John W. Eaton <jwe@bevo.che.wisc.edu> + + * boolNDArray.cc: Define BOOL ops. Define mixed CMP ops. + * boolNDArray.h: Declare BOOL ops. Declare mixed CMP ops. + +2003-11-25 John W. Eaton <jwe@bevo.che.wisc.edu> + + * mk-ops.awk: Also emit #include "Array-util.h". + + * mx-ops: Add bool, boolMatrix, and boolNDarray types. + Add bnda x bnda, b x bnda, and bnda x b ops. + + * MArray-misc.cc: Delete. + * Makefile.in (MATRIX_SRC): Remove it from the list. + + * Array-util.h, Array-util.cc (gripe_nonconformant): Move here from + MArray.h, MArray2.h, MArrayN.h, and MArray-misc.cc. + 2003-11-24 John W. Eaton <jwe@bevo.che.wisc.edu> * dbleQR.cc (QR::init): Use separate pwork pointers.
deleted file mode 100644 --- a/liboctave/MArray-misc.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* - -Copyright (C) 1996, 1997 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 <config.h> -#endif - -#include "MArray.h" -#include "MArray2.h" -#include "dim-vector.h" -#include "lo-error.h" - -void -gripe_nonconformant (const char *op, int op1_len, int op2_len) -{ - (*current_liboctave_error_handler) - ("%s: nonconformant arguments (op1 len: %d, op2 len: %d)", - op, op1_len, op2_len); -} - -void -gripe_nonconformant (const char *op, int op1_nr, int op1_nc, - int op2_nr, int op2_nc) -{ - (*current_liboctave_error_handler) - ("%s: nonconformant arguments (op1 is %dx%d, op2 is %dx%d)", - op, op1_nr, op1_nc, op2_nr, op2_nc); -} - -void -gripe_nonconformant (const char *op, dim_vector& op1_dims, - dim_vector& op2_dims) -{ - std::string op1_dims_str = op1_dims.str (); - std::string op2_dims_str = op2_dims.str (); - - (*current_liboctave_error_handler) - ("%s: nonconformant arguments (op1 is %s, op2 is %s)", - op, op1_dims_str.c_str (), op2_dims_str.c_str ()); -} - - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
--- a/liboctave/MArray.cc +++ b/liboctave/MArray.cc @@ -29,6 +29,7 @@ #endif #include "MArray.h" +#include "Array-util.h" #include "lo-error.h" #include "MArray-defs.h"
--- a/liboctave/MArray.h +++ b/liboctave/MArray.h @@ -72,10 +72,6 @@ // MARRAY_OPS_FRIEND_DECLS (MArray) }; -// XXX FIXME XXX -- there must be a better place for this... -extern void -gripe_nonconformant (const char *op, int op1_len, int op2_len); - #endif /*
--- a/liboctave/MArray2.cc +++ b/liboctave/MArray2.cc @@ -29,6 +29,7 @@ #endif #include "MArray2.h" +#include "Array-util.h" #include "lo-error.h" #include "MArray-defs.h"
--- a/liboctave/MArray2.h +++ b/liboctave/MArray2.h @@ -80,10 +80,6 @@ // MARRAY_OPS_FRIEND_DECLS (MArray2) }; -extern void -gripe_nonconformant (const char *op, int op1_nr, int op1_nc, - int op2_nr, int op2_nc); - #endif /*
--- a/liboctave/MArrayN.cc +++ b/liboctave/MArrayN.cc @@ -29,6 +29,7 @@ #endif #include "MArrayN.h" +#include "Array-util.h" #include "ArrayN-idx.h" #include "lo-error.h"
--- a/liboctave/MArrayN.h +++ b/liboctave/MArrayN.h @@ -71,9 +71,6 @@ } }; -extern void -gripe_nonconformant (const char *op, dim_vector& op1_dims, dim_vector& op2_dims); - #endif /*
--- a/liboctave/MDiagArray2.cc +++ b/liboctave/MDiagArray2.cc @@ -29,6 +29,7 @@ #endif #include "MDiagArray2.h" +#include "Array-util.h" #include "lo-error.h" #include "MArray-defs.h"
--- a/liboctave/Makefile.in +++ b/liboctave/Makefile.in @@ -77,11 +77,11 @@ CDiagMatrix.cc CMatrix.cc CNDArray.cc CRowVector.cc \ CmplxAEPBAL.cc CmplxCHOL.cc CmplxDET.cc CmplxHESS.cc \ CmplxLU.cc CmplxQR.cc CmplxQRP.cc CmplxSCHUR.cc CmplxSVD.cc \ - EIG.cc MArray-misc.cc boolMatrix.cc \ - boolNDArray.cc chMatrix.cc chNDArray.cc dColVector.cc \ - dDiagMatrix.cc dMatrix.cc dNDArray.cc dRowVector.cc \ - dbleAEPBAL.cc dbleCHOL.cc dbleDET.cc dbleHESS.cc dbleLU.cc \ - dbleQR.cc dbleQRP.cc dbleSCHUR.cc dbleSVD.cc + EIG.cc boolMatrix.cc boolNDArray.cc chMatrix.cc \ + chNDArray.cc dColVector.cc dDiagMatrix.cc dMatrix.cc \ + dNDArray.cc dRowVector.cc dbleAEPBAL.cc dbleCHOL.cc \ + dbleDET.cc dbleHESS.cc dbleLU.cc dbleQR.cc dbleQRP.cc \ + dbleSCHUR.cc dbleSVD.cc MX_OP_SRC := $(shell $(AWK) -f $(srcdir)/mk-ops.awk prefix=mx list_cc_files=1 $(srcdir)/mx-ops)
--- a/liboctave/boolMatrix.cc +++ b/liboctave/boolMatrix.cc @@ -31,6 +31,7 @@ #include <iostream> +#include "Array-util.h" #include "lo-error.h" #include "str-vec.h" #include "mx-base.h"
--- a/liboctave/boolNDArray.cc +++ b/liboctave/boolNDArray.cc @@ -103,8 +103,15 @@ return ::compute_index (ra_idx, dimensions); } +NDND_BOOL_OPS (boolNDArray, boolNDArray, false) NDND_CMP_OPS (boolNDArray, , boolNDArray, ) +NDS_BOOL_OPS (boolNDArray, bool, false) +NDS_CMP_OPS (boolNDArray, , bool, ) + +SND_BOOL_OPS (bool, boolNDArray, false) +SND_CMP_OPS (bool, , boolNDArray, ) + /* ;;; Local Variables: *** ;;; mode: C++ ***
--- a/liboctave/boolNDArray.h +++ b/liboctave/boolNDArray.h @@ -99,8 +99,15 @@ boolNDArray (bool *d, dim_vector& dv) : ArrayN<bool> (d, dv) { } }; +NDND_BOOL_OP_DECLS (boolNDArray, boolNDArray) NDND_CMP_OP_DECLS (boolNDArray, boolNDArray) +NDS_BOOL_OP_DECLS (boolNDArray, bool) +NDS_CMP_OP_DECLS (boolNDArray, bool) + +SND_BOOL_OP_DECLS (bool, boolNDArray) +SND_CMP_OP_DECLS (bool, boolNDArray) + #endif /*
--- a/liboctave/dColVector.cc +++ b/liboctave/dColVector.cc @@ -31,6 +31,7 @@ #include <iostream> +#include "Array-util.h" #include "f77-fcn.h" #include "lo-error.h" #include "mx-base.h"
--- a/liboctave/dDiagMatrix.cc +++ b/liboctave/dDiagMatrix.cc @@ -31,6 +31,7 @@ #include <iostream> +#include "Array-util.h" #include "lo-error.h" #include "mx-base.h" #include "mx-inlines.cc"
--- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -33,6 +33,7 @@ #include <iostream> +#include "Array-util.h" #include "byte-swap.h" #include "dMatrix.h" #include "dbleAEPBAL.h"
--- a/liboctave/dRowVector.cc +++ b/liboctave/dRowVector.cc @@ -31,6 +31,7 @@ #include <iostream> +#include "Array-util.h" #include "f77-fcn.h" #include "lo-error.h" #include "mx-base.h"
--- a/liboctave/mk-ops.awk +++ b/liboctave/mk-ops.awk @@ -151,6 +151,8 @@ print "#include <config.h>" >> cc_file; print "#endif" >> cc_file; + print "#include \"Array-util.h\"" >> cc_file; + printf ("#include \"%s\"\n", h_file) >> cc_file; for (i in bool_headers)
--- a/liboctave/mx-ops +++ b/liboctave/mx-ops @@ -1,4 +1,7 @@ # types +b bool S NONE NO +bm boolMatrix ND boolMatrix.h YES +bnda boolNDArray ND boolNDArray.h YES cdm ComplexDiagMatrix DM CDiagMatrix.h YES cm ComplexMatrix M CMatrix.h YES cnda ComplexNDArray ND CNDArray.h YES @@ -8,6 +11,9 @@ nda NDArray ND dNDArray.h YES s double S NONE NO # ops +bnda bnda bnda L false +bnda b bnda L false +bnda bnda b L false cdm cdm dm B cdm dm cdm B cm cs cdm B
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2003-11-25 John W. Eaton <jwe@bevo.che.wisc.edu> + * OPERATORS/op-b-bm.cc: New file. + + * OPERATORS/op-bm-b.cc (op_el_and, op_el_or): Define and install. + * OPERATORS/op-bm-bm.cc (op_el_and, op_el_or, assign): Likewise. + * ov-str-mat.cc (CHAR_MATRIX_CONV): New macro. * ov-str-mat.h (octave_char_matrix_str::double_value, octave_char_matrix_str::matrix_value,
--- a/src/Makefile.in +++ b/src/Makefile.in @@ -95,8 +95,8 @@ TI_SRC := $(addprefix TEMPLATE-INST/, $(TI_XSRC)) -OP_XSRC := op-b-b.cc op-bm-b.cc op-bm-bm.cc op-cell.cc \ - op-chm.cc op-cm-cm.cc op-cm-cs.cc op-cm-m.cc \ +OP_XSRC := op-b-b.cc op-b-bm.cc op-bm-b.cc op-bm-bm.cc \ + op-cell.cc op-chm.cc op-cm-cm.cc op-cm-cs.cc op-cm-m.cc \ op-cm-s.cc op-cs-cm.cc op-cs-cs.cc op-cs-m.cc \ op-cs-s.cc op-fil-b.cc op-fil-bm.cc op-fil-cm.cc \ op-fil-cs.cc op-fil-m.cc op-fil-s.cc op-fil-lis.cc \
new file mode 100644 --- /dev/null +++ b/src/OPERATORS/op-b-bm.cc @@ -0,0 +1,57 @@ +/* + +Copyright (C) 2003 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. + +*/ + +#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) +#pragma implementation +#endif + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "gripes.h" +#include "oct-obj.h" +#include "ov.h" +#include "ov-bool.h" +#include "ov-bool-mat.h" +#include "ov-typeinfo.h" +#include "ops.h" +#include "xdiv.h" +#include "xpow.h" + +// bool matrix by bool ops. + +DEFNDBINOP_FN (el_and, bool, bool_matrix, bool, bool_array, mx_el_and) +DEFNDBINOP_FN (el_or, bool, bool_matrix, bool, bool_array, mx_el_or) + +void +install_b_bm_ops (void) +{ + INSTALL_BINOP (op_el_and, octave_bool, octave_bool_matrix, el_and); + INSTALL_BINOP (op_el_or, octave_bool, octave_bool_matrix, el_or); +} + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/
--- a/src/OPERATORS/op-bm-b.cc +++ b/src/OPERATORS/op-bm-b.cc @@ -40,11 +40,17 @@ // bool matrix by bool ops. +DEFNDBINOP_FN (el_and, bool_matrix, bool, bool_array, bool, mx_el_and) +DEFNDBINOP_FN (el_or, bool_matrix, bool, bool_array, bool, mx_el_or) + DEFASSIGNOP_FN (assign, bool_matrix, bool, assign) void install_bm_b_ops (void) { + INSTALL_BINOP (op_el_and, octave_bool_matrix, octave_bool, el_and); + INSTALL_BINOP (op_el_or, octave_bool_matrix, octave_bool, el_or); + INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_bool, assign); }
--- a/src/OPERATORS/op-bm-bm.cc +++ b/src/OPERATORS/op-bm-bm.cc @@ -53,6 +53,14 @@ DEFNDBINOP_FN (eq, bool_matrix, bool_matrix, bool_array, bool_array, mx_el_eq) DEFNDBINOP_FN (ne, bool_matrix, bool_matrix, bool_array, bool_array, mx_el_ne) +DEFNDBINOP_FN (el_and, bool_matrix, bool_matrix, bool_array, bool_array, + mx_el_and) + +DEFNDBINOP_FN (el_or, bool_matrix, bool_matrix, bool_array, bool_array, + mx_el_or) + +DEFASSIGNOP_FN (assign, bool_matrix, bool_matrix, assign) + void install_bm_bm_ops (void) { @@ -62,6 +70,11 @@ INSTALL_BINOP (op_eq, octave_bool_matrix, octave_bool_matrix, eq); INSTALL_BINOP (op_ne, octave_bool_matrix, octave_bool_matrix, ne); + + INSTALL_BINOP (op_el_and, octave_bool_matrix, octave_bool_matrix, el_and); + INSTALL_BINOP (op_el_or, octave_bool_matrix, octave_bool_matrix, el_or); + + INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_bool_matrix, assign); } /*
--- a/src/ops.h +++ b/src/ops.h @@ -23,6 +23,8 @@ #if !defined (octave_ops_h) #define octave_ops_h 1 +#include "Array-util.h" + extern void install_ops (void); #define INSTALL_UNOP(op, t, f) \