Mercurial > hg > octave-avbm
changeset 8774:b756ce0002db
split implementation and interface in mx-op-defs and MArray-defs
line wrap: on
line diff
--- a/liboctave/CMatrix.cc +++ b/liboctave/CMatrix.cc @@ -56,6 +56,7 @@ #include "mx-dm-cm.h" #include "mx-cm-s.h" #include "mx-inlines.cc" +#include "mx-op-defs.h" #include "oct-cmplx.h" #include "oct-norm.h"
--- a/liboctave/CMatrix.h +++ b/liboctave/CMatrix.h @@ -29,7 +29,7 @@ #include "MatrixType.h" #include "mx-defs.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" #include "oct-cmplx.h" #include "DET.h"
--- a/liboctave/CNDArray.cc +++ b/liboctave/CNDArray.cc @@ -37,6 +37,7 @@ #include "lo-ieee.h" #include "lo-mappers.h" #include "oct-locbuf.h" +#include "mx-op-defs.h" #if defined (HAVE_FFTW3) #include "oct-fftw.h"
--- a/liboctave/CNDArray.h +++ b/liboctave/CNDArray.h @@ -27,7 +27,7 @@ #include "CMatrix.h" #include "mx-defs.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" class OCTAVE_API
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,26 @@ +2009-02-17 Jaroslav Hajek <highegg@gmail.com> + + * MArray-defs.h: Move declarative part to MArray-decl.h + * MArray-decl.h: New source. + + * mx-op-defs.h: Move declarative part to mx-op-decl.h. + * mx-op-decl.h: New source. + + * Makefile.in: Include new sources in build. + * mk-ops.awk: Include mx-op-decl.h in headers, mx-op-defs in .cc + files. + + * CMatrix.cc, CMatrix.h, CNDArray.cc, CNDArray.h, MArray.h, MArray2.h, + MArrayN.h, MDiagArray2.h, boolMatrix.cc, boolMatrix.h, boolNDArray.cc, + boolNDArray.h, chMatrix.cc, chMatrix.h, chNDArray.cc, chNDArray.h, + dMatrix.cc, dMatrix.h, dNDArray.cc, dNDArray.h, fCMatrix.cc, + fCMatrix.h, fCNDArray.cc, fCNDArray.h, fMatrix.cc, fMatrix.h, + fNDArray.cc, fNDArray.h, int16NDArray.cc, int16NDArray.h, + int32NDArray.cc, int32NDArray.h, int64NDArray.cc, int64NDArray.h, + int8NDArray.cc, int8NDArray.h, uint16NDArray.cc, uint16NDArray.h, + uint32NDArray.cc, uint32NDArray.h, uint64NDArray.cc, uint64NDArray.h, + uint8NDArray.cc, uint8NDArray.h: Ditto. + 2009-02-16 Jaroslav Hajek <highegg@gmail.com> * Array.cc (Array<T>::assign (const idx_vector& i,
new file mode 100644 --- /dev/null +++ b/liboctave/MArray-decl.h @@ -0,0 +1,249 @@ +/* + +Copyright (C) 1996, 1999, 2000, 2003, 2005, 2006, 2007 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 3 of the License, 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, see +<http://www.gnu.org/licenses/>. + +*/ + +#if !defined (octave_MArray_decl_h) +#define octave_MArray_decl_h 1 + +// A macro that can be used to declare and instantiate OP= operators. +#define MARRAY_OP_ASSIGN_DECL(A_T, E_T, OP, PFX, API, LTGT, RHS_T) \ + PFX API A_T<E_T>& \ + operator OP LTGT (A_T<E_T>&, const RHS_T&) + +// All the OP= operators that we care about. +#define MARRAY_OP_ASSIGN_DECLS(A_T, E_T, PFX, API, LTGT, RHS_T) \ + MARRAY_OP_ASSIGN_DECL (A_T, E_T, +=, PFX, API, LTGT, RHS_T); \ + MARRAY_OP_ASSIGN_DECL (A_T, E_T, -=, PFX, API, LTGT, RHS_T); + +// Generate forward declarations for OP= operators. +#define MARRAY_OP_ASSIGN_FWD_DECLS(A_T, RHS_T, API) \ + MARRAY_OP_ASSIGN_DECLS (A_T, T, template <typename T>, API, , RHS_T) + +// Generate friend declarations for the OP= operators. +#define MARRAY_OP_ASSIGN_FRIENDS(A_T, RHS_T, API) \ + MARRAY_OP_ASSIGN_DECLS (A_T, T, friend, API, <>, RHS_T) + +// A function that can be used to forward OP= operations from derived +// classes back to us. +#define MARRAY_OP_ASSIGN_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \ + inline R \ + F (X_T& x, const Y_T& y) \ + { \ + return R (F (C_X (x), C_Y (y))); \ + } + +// All the OP= operators that we care about forwarding. +#define MARRAY_OP_ASSIGN_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \ + MARRAY_OP_ASSIGN_FWD_FCN (R, operator +=, T, C_X, X_T, C_Y, Y_T) \ + MARRAY_OP_ASSIGN_FWD_FCN (R, operator -=, T, C_X, X_T, C_Y, Y_T) + +// A macro that can be used to declare and instantiate unary operators. +#define MARRAY_UNOP(A_T, E_T, F, PFX, API, LTGT) \ + PFX API A_T<E_T> \ + F LTGT (const A_T<E_T>&) + +// All the unary operators that we care about. +#define MARRAY_UNOP_DECLS(A_T, E_T, PFX, API, LTGT) \ + MARRAY_UNOP (A_T, E_T, operator +, PFX, API, LTGT); \ + MARRAY_UNOP (A_T, E_T, operator -, PFX, API, LTGT); + +// Generate forward declarations for unary operators. +#define MARRAY_UNOP_FWD_DECLS(A_T, API) \ + MARRAY_UNOP_DECLS (A_T, T, template <typename T>, API, ) + +// Generate friend declarations for the unary operators. +#define MARRAY_UNOP_FRIENDS(A_T, API) \ + MARRAY_UNOP_DECLS (A_T, T, friend, API, <>) + +// A function that can be used to forward unary operations from derived +// classes back to us. +#define MARRAY_UNOP_FWD_FCN(R, F, T, C_X, X_T) \ + inline R \ + F (const X_T& x) \ + { \ + return R (F (C_X (x))); \ + } + +// All the unary operators that we care about forwarding. +#define MARRAY_UNOP_FWD_DEFS(R, T, C_X, X_T) \ + MARRAY_UNOP_FWD_FCN (R, operator +, T, C_X, X_T) \ + MARRAY_UNOP_FWD_FCN (R, operator -, T, C_X, X_T) + +// A macro that can be used to declare and instantiate binary operators. +#define MARRAY_BINOP_DECL(A_T, E_T, F, PFX, API, LTGT, X_T, Y_T) \ + PFX API A_T<E_T> \ + F LTGT (const X_T&, const Y_T&) + +// All the binary operators that we care about. We have two +// sets of macros since the MArray OP MArray operations use functions +// (product and quotient) instead of operators (*, /). +#define MARRAY_BINOP_DECLS(A_T, E_T, PFX, API, LTGT, X_T, Y_T) \ + MARRAY_BINOP_DECL (A_T, E_T, operator +, PFX, API, LTGT, X_T, Y_T); \ + MARRAY_BINOP_DECL (A_T, E_T, operator -, PFX, API, LTGT, X_T, Y_T); \ + MARRAY_BINOP_DECL (A_T, E_T, operator *, PFX, API, LTGT, X_T, Y_T); \ + MARRAY_BINOP_DECL (A_T, E_T, operator /, PFX, API, LTGT, X_T, Y_T); + +#define MARRAY_AA_BINOP_DECLS(A_T, E_T, PFX, API, LTGT) \ + MARRAY_BINOP_DECL (A_T, E_T, operator +, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \ + MARRAY_BINOP_DECL (A_T, E_T, operator -, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \ + MARRAY_BINOP_DECL (A_T, E_T, quotient, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \ + MARRAY_BINOP_DECL (A_T, E_T, product, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); + +#define MDIAGARRAY2_DAS_BINOP_DECLS(A_T, E_T, PFX, API, LTGT, X_T, Y_T) \ + MARRAY_BINOP_DECL (A_T, E_T, operator *, PFX, API, LTGT, X_T, Y_T); \ + MARRAY_BINOP_DECL (A_T, E_T, operator /, PFX, API, LTGT, X_T, Y_T); + +#define MDIAGARRAY2_SDA_BINOP_DECLS(A_T, E_T, PFX, API, LTGT, X_T, Y_T) \ + MARRAY_BINOP_DECL (A_T, E_T, operator *, PFX, API, LTGT, X_T, Y_T); + +#define MDIAGARRAY2_DADA_BINOP_DECLS(A_T, E_T, PFX, API, LTGT) \ + MARRAY_BINOP_DECL (A_T, E_T, operator +, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \ + MARRAY_BINOP_DECL (A_T, E_T, operator -, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \ + MARRAY_BINOP_DECL (A_T, E_T, product, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); + +// Generate forward declarations for binary operators. +#define MARRAY_BINOP_FWD_DECLS(A_T, API) \ + MARRAY_BINOP_DECLS (A_T, T, template <typename T>, API, , A_T<T>, T) \ + MARRAY_BINOP_DECLS (A_T, T, template <typename T>, API, , T, A_T<T>) \ + MARRAY_AA_BINOP_DECLS (A_T, T, template <typename T>, API, ) + +#define MDIAGARRAY2_BINOP_FWD_DECLS(A_T, API) \ + MDIAGARRAY2_DAS_BINOP_DECLS (A_T, T, template <typename T>, API, , A_T<T>, T) \ + MDIAGARRAY2_SDA_BINOP_DECLS (A_T, T, template <typename T>, API, , T, A_T<T>) \ + MDIAGARRAY2_DADA_BINOP_DECLS (A_T, T, template <typename T>, API, ) + +// Generate friend declarations for the binary operators. +#define MARRAY_BINOP_FRIENDS(A_T, API) \ + MARRAY_BINOP_DECLS (A_T, T, friend, API, <>, A_T<T>, T) \ + MARRAY_BINOP_DECLS (A_T, T, friend, API, <>, T, A_T<T>) \ + MARRAY_AA_BINOP_DECLS (A_T, T, friend, API, <>) + +#define MDIAGARRAY2_BINOP_FRIENDS(A_T, API) \ + MDIAGARRAY2_DAS_BINOP_DECLS (A_T, T, friend, API, <>, A_T<T>, T) \ + MDIAGARRAY2_SDA_BINOP_DECLS (A_T, T, friend, API, <>, T, A_T<T>) \ + MDIAGARRAY2_DADA_BINOP_DECLS (A_T, T, friend, API, <>) + +// A function that can be used to forward binary operations from derived +// classes back to us. +#define MARRAY_BINOP_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \ + inline R \ + F (const X_T& x, const Y_T& y) \ + { \ + return R (F (C_X (x), C_Y (y))); \ + } + +// The binary operators that we care about forwarding. We have two +// sets of macros since the MArray OP MArray operations use functions +// (product and quotient) instead of operators (*, /). +#define MARRAY_BINOP_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \ + MARRAY_BINOP_FWD_FCN (R, operator +, T, C_X, X_T, C_Y, Y_T) \ + MARRAY_BINOP_FWD_FCN (R, operator -, T, C_X, X_T, C_Y, Y_T) \ + MARRAY_BINOP_FWD_FCN (R, operator *, T, C_X, X_T, C_Y, Y_T) \ + MARRAY_BINOP_FWD_FCN (R, operator /, T, C_X, X_T, C_Y, Y_T) + +#define MARRAY_AA_BINOP_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \ + MARRAY_BINOP_FWD_FCN (R, operator +, T, C_X, X_T, C_Y, Y_T) \ + MARRAY_BINOP_FWD_FCN (R, operator -, T, C_X, X_T, C_Y, Y_T) \ + MARRAY_BINOP_FWD_FCN (R, product, T, C_X, X_T, C_Y, Y_T) \ + MARRAY_BINOP_FWD_FCN (R, quotient, T, C_X, X_T, C_Y, Y_T) + +#define MDIAGARRAY2_DAS_BINOP_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \ + MARRAY_BINOP_FWD_FCN (R, operator *, T, C_X, X_T, C_Y, Y_T) \ + MARRAY_BINOP_FWD_FCN (R, operator /, T, C_X, X_T, C_Y, Y_T) + +#define MDIAGARRAY2_SDA_BINOP_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \ + MARRAY_BINOP_FWD_FCN (R, operator *, T, C_X, X_T, C_Y, Y_T) + +#define MDIAGARRAY2_DADA_BINOP_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \ + MARRAY_BINOP_FWD_FCN (R, operator +, T, C_X, X_T, C_Y, Y_T) \ + MARRAY_BINOP_FWD_FCN (R, operator -, T, C_X, X_T, C_Y, Y_T) \ + MARRAY_BINOP_FWD_FCN (R, product, T, C_X, X_T, C_Y, Y_T) + +// Forward declarations for the MArray operators. +#define MARRAY_OPS_FORWARD_DECLS(A_T, API) \ + template <class T> \ + class A_T; \ + \ + MARRAY_OP_ASSIGN_FWD_DECLS (A_T, T, API) \ + MARRAY_OP_ASSIGN_FWD_DECLS (A_T, A_T<T>, API) \ + MARRAY_UNOP_FWD_DECLS (A_T, API) \ + MARRAY_BINOP_FWD_DECLS (A_T, API) + +#define MDIAGARRAY2_OPS_FORWARD_DECLS(A_T, API) \ + template <class T> \ + class A_T; \ + \ + MARRAY_OP_ASSIGN_FWD_DECLS (A_T, A_T<T>, API) \ + MARRAY_UNOP_FWD_DECLS (A_T, API) \ + MDIAGARRAY2_BINOP_FWD_DECLS (A_T, API) + +// Friend declarations for the MArray operators. +#define MARRAY_OPS_FRIEND_DECLS(A_T, API) \ + MARRAY_OP_ASSIGN_FRIENDS (A_T, T, API) \ + MARRAY_OP_ASSIGN_FRIENDS (A_T, A_T<T>, API) \ + MARRAY_UNOP_FRIENDS (A_T, API) \ + MARRAY_BINOP_FRIENDS (A_T, API) + +#define MDIAGARRAY2_OPS_FRIEND_DECLS(A_T, API) \ + MARRAY_OP_ASSIGN_FRIENDS (A_T, A_T<T>, API) \ + MARRAY_UNOP_FRIENDS (A_T, API) \ + MDIAGARRAY2_BINOP_FRIENDS (A_T, API) + +// Define all the MArray forwarding functions for return type R and +// MArray element type T +#define MARRAY_FORWARD_DEFS(B, R, T) \ + MARRAY_OP_ASSIGN_FWD_DEFS \ + (R, T, dynamic_cast<B<T>&>, R, , T) \ + \ + MARRAY_OP_ASSIGN_FWD_DEFS \ + (R, T, \ + dynamic_cast<B<T>&>, R, dynamic_cast<const B<T>&>, R) \ + \ + MARRAY_UNOP_FWD_DEFS \ + (R, T, dynamic_cast<const B<T>&>, R) \ + \ + MARRAY_BINOP_FWD_DEFS \ + (R, T, dynamic_cast<const B<T>&>, R, , T) \ + \ + MARRAY_BINOP_FWD_DEFS \ + (R, T, , T, dynamic_cast<const B<T>&>, R) \ + \ + MARRAY_AA_BINOP_FWD_DEFS \ + (R, T, dynamic_cast<const B<T>&>, R, dynamic_cast<const B<T>&>, R) + +#define MDIAGARRAY2_FORWARD_DEFS(B, R, T) \ + MARRAY_OP_ASSIGN_FWD_DEFS \ + (R, T, \ + dynamic_cast<B<T>&>, R, dynamic_cast<const B<T>&>, R) \ + \ + MARRAY_UNOP_FWD_DEFS \ + (R, T, dynamic_cast<const B<T>&>, R) \ + \ + MDIAGARRAY2_DAS_BINOP_FWD_DEFS \ + (R, T, dynamic_cast<const B<T>&>, R, , T) \ + \ + MDIAGARRAY2_SDA_BINOP_FWD_DEFS \ + (R, T, , T, dynamic_cast<const B<T>&>, R) \ + \ + MDIAGARRAY2_DADA_BINOP_FWD_DEFS \ + (R, T, dynamic_cast<const B<T>&>, R, dynamic_cast<const B<T>&>, R) + +#endif
--- a/liboctave/MArray-defs.h +++ b/liboctave/MArray-defs.h @@ -72,132 +72,14 @@ } \ while (0) -// A macro that can be used to declare and instantiate OP= operators. -#define MARRAY_OP_ASSIGN_DECL(A_T, E_T, OP, PFX, API, LTGT, RHS_T) \ - PFX API A_T<E_T>& \ - operator OP LTGT (A_T<E_T>&, const RHS_T&) - -// All the OP= operators that we care about. -#define MARRAY_OP_ASSIGN_DECLS(A_T, E_T, PFX, API, LTGT, RHS_T) \ - MARRAY_OP_ASSIGN_DECL (A_T, E_T, +=, PFX, API, LTGT, RHS_T); \ - MARRAY_OP_ASSIGN_DECL (A_T, E_T, -=, PFX, API, LTGT, RHS_T); - -// Generate forward declarations for OP= operators. -#define MARRAY_OP_ASSIGN_FWD_DECLS(A_T, RHS_T, API) \ - MARRAY_OP_ASSIGN_DECLS (A_T, T, template <typename T>, API, , RHS_T) - -// Generate friend declarations for the OP= operators. -#define MARRAY_OP_ASSIGN_FRIENDS(A_T, RHS_T, API) \ - MARRAY_OP_ASSIGN_DECLS (A_T, T, friend, API, <>, RHS_T) - // Instantiate the OP= operators. #define MARRAY_OP_ASSIGN_DEFS(A_T, E_T, RHS_T, API) \ MARRAY_OP_ASSIGN_DECLS (A_T, E_T, template, API, , RHS_T) -// A function that can be used to forward OP= operations from derived -// classes back to us. -#define MARRAY_OP_ASSIGN_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \ - inline R \ - F (X_T& x, const Y_T& y) \ - { \ - return R (F (C_X (x), C_Y (y))); \ - } - -// All the OP= operators that we care about forwarding. -#define MARRAY_OP_ASSIGN_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \ - MARRAY_OP_ASSIGN_FWD_FCN (R, operator +=, T, C_X, X_T, C_Y, Y_T) \ - MARRAY_OP_ASSIGN_FWD_FCN (R, operator -=, T, C_X, X_T, C_Y, Y_T) - -// A macro that can be used to declare and instantiate unary operators. -#define MARRAY_UNOP(A_T, E_T, F, PFX, API, LTGT) \ - PFX API A_T<E_T> \ - F LTGT (const A_T<E_T>&) - -// All the unary operators that we care about. -#define MARRAY_UNOP_DECLS(A_T, E_T, PFX, API, LTGT) \ - MARRAY_UNOP (A_T, E_T, operator +, PFX, API, LTGT); \ - MARRAY_UNOP (A_T, E_T, operator -, PFX, API, LTGT); - -// Generate forward declarations for unary operators. -#define MARRAY_UNOP_FWD_DECLS(A_T, API) \ - MARRAY_UNOP_DECLS (A_T, T, template <typename T>, API, ) - -// Generate friend declarations for the unary operators. -#define MARRAY_UNOP_FRIENDS(A_T, API) \ - MARRAY_UNOP_DECLS (A_T, T, friend, API, <>) - // Instantiate the unary operators. #define MARRAY_UNOP_DEFS(A_T, E_T, API) \ MARRAY_UNOP_DECLS (A_T, E_T, template, API, ) -// A function that can be used to forward unary operations from derived -// classes back to us. -#define MARRAY_UNOP_FWD_FCN(R, F, T, C_X, X_T) \ - inline R \ - F (const X_T& x) \ - { \ - return R (F (C_X (x))); \ - } - -// All the unary operators that we care about forwarding. -#define MARRAY_UNOP_FWD_DEFS(R, T, C_X, X_T) \ - MARRAY_UNOP_FWD_FCN (R, operator +, T, C_X, X_T) \ - MARRAY_UNOP_FWD_FCN (R, operator -, T, C_X, X_T) - -// A macro that can be used to declare and instantiate binary operators. -#define MARRAY_BINOP_DECL(A_T, E_T, F, PFX, API, LTGT, X_T, Y_T) \ - PFX API A_T<E_T> \ - F LTGT (const X_T&, const Y_T&) - -// All the binary operators that we care about. We have two -// sets of macros since the MArray OP MArray operations use functions -// (product and quotient) instead of operators (*, /). -#define MARRAY_BINOP_DECLS(A_T, E_T, PFX, API, LTGT, X_T, Y_T) \ - MARRAY_BINOP_DECL (A_T, E_T, operator +, PFX, API, LTGT, X_T, Y_T); \ - MARRAY_BINOP_DECL (A_T, E_T, operator -, PFX, API, LTGT, X_T, Y_T); \ - MARRAY_BINOP_DECL (A_T, E_T, operator *, PFX, API, LTGT, X_T, Y_T); \ - MARRAY_BINOP_DECL (A_T, E_T, operator /, PFX, API, LTGT, X_T, Y_T); - -#define MARRAY_AA_BINOP_DECLS(A_T, E_T, PFX, API, LTGT) \ - MARRAY_BINOP_DECL (A_T, E_T, operator +, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \ - MARRAY_BINOP_DECL (A_T, E_T, operator -, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \ - MARRAY_BINOP_DECL (A_T, E_T, quotient, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \ - MARRAY_BINOP_DECL (A_T, E_T, product, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); - -#define MDIAGARRAY2_DAS_BINOP_DECLS(A_T, E_T, PFX, API, LTGT, X_T, Y_T) \ - MARRAY_BINOP_DECL (A_T, E_T, operator *, PFX, API, LTGT, X_T, Y_T); \ - MARRAY_BINOP_DECL (A_T, E_T, operator /, PFX, API, LTGT, X_T, Y_T); - -#define MDIAGARRAY2_SDA_BINOP_DECLS(A_T, E_T, PFX, API, LTGT, X_T, Y_T) \ - MARRAY_BINOP_DECL (A_T, E_T, operator *, PFX, API, LTGT, X_T, Y_T); - -#define MDIAGARRAY2_DADA_BINOP_DECLS(A_T, E_T, PFX, API, LTGT) \ - MARRAY_BINOP_DECL (A_T, E_T, operator +, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \ - MARRAY_BINOP_DECL (A_T, E_T, operator -, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \ - MARRAY_BINOP_DECL (A_T, E_T, product, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); - -// Generate forward declarations for binary operators. -#define MARRAY_BINOP_FWD_DECLS(A_T, API) \ - MARRAY_BINOP_DECLS (A_T, T, template <typename T>, API, , A_T<T>, T) \ - MARRAY_BINOP_DECLS (A_T, T, template <typename T>, API, , T, A_T<T>) \ - MARRAY_AA_BINOP_DECLS (A_T, T, template <typename T>, API, ) - -#define MDIAGARRAY2_BINOP_FWD_DECLS(A_T, API) \ - MDIAGARRAY2_DAS_BINOP_DECLS (A_T, T, template <typename T>, API, , A_T<T>, T) \ - MDIAGARRAY2_SDA_BINOP_DECLS (A_T, T, template <typename T>, API, , T, A_T<T>) \ - MDIAGARRAY2_DADA_BINOP_DECLS (A_T, T, template <typename T>, API, ) - -// Generate friend declarations for the binary operators. -#define MARRAY_BINOP_FRIENDS(A_T, API) \ - MARRAY_BINOP_DECLS (A_T, T, friend, API, <>, A_T<T>, T) \ - MARRAY_BINOP_DECLS (A_T, T, friend, API, <>, T, A_T<T>) \ - MARRAY_AA_BINOP_DECLS (A_T, T, friend, API, <>) - -#define MDIAGARRAY2_BINOP_FRIENDS(A_T, API) \ - MDIAGARRAY2_DAS_BINOP_DECLS (A_T, T, friend, API, <>, A_T<T>, T) \ - MDIAGARRAY2_SDA_BINOP_DECLS (A_T, T, friend, API, <>, T, A_T<T>) \ - MDIAGARRAY2_DADA_BINOP_DECLS (A_T, T, friend, API, <>) - // Instantiate the binary operators. #define MARRAY_BINOP_DEFS(A_T, E_T, API) \ MARRAY_BINOP_DECLS (A_T, E_T, template, API, , A_T<E_T>, E_T) \ @@ -209,72 +91,6 @@ MDIAGARRAY2_SDA_BINOP_DECLS (A_T, E_T, template, API, , E_T, A_T<E_T>) \ MDIAGARRAY2_DADA_BINOP_DECLS (A_T, E_T, template, API, ) -// A function that can be used to forward binary operations from derived -// classes back to us. -#define MARRAY_BINOP_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \ - inline R \ - F (const X_T& x, const Y_T& y) \ - { \ - return R (F (C_X (x), C_Y (y))); \ - } - -// The binary operators that we care about forwarding. We have two -// sets of macros since the MArray OP MArray operations use functions -// (product and quotient) instead of operators (*, /). -#define MARRAY_BINOP_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \ - MARRAY_BINOP_FWD_FCN (R, operator +, T, C_X, X_T, C_Y, Y_T) \ - MARRAY_BINOP_FWD_FCN (R, operator -, T, C_X, X_T, C_Y, Y_T) \ - MARRAY_BINOP_FWD_FCN (R, operator *, T, C_X, X_T, C_Y, Y_T) \ - MARRAY_BINOP_FWD_FCN (R, operator /, T, C_X, X_T, C_Y, Y_T) - -#define MARRAY_AA_BINOP_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \ - MARRAY_BINOP_FWD_FCN (R, operator +, T, C_X, X_T, C_Y, Y_T) \ - MARRAY_BINOP_FWD_FCN (R, operator -, T, C_X, X_T, C_Y, Y_T) \ - MARRAY_BINOP_FWD_FCN (R, product, T, C_X, X_T, C_Y, Y_T) \ - MARRAY_BINOP_FWD_FCN (R, quotient, T, C_X, X_T, C_Y, Y_T) - -#define MDIAGARRAY2_DAS_BINOP_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \ - MARRAY_BINOP_FWD_FCN (R, operator *, T, C_X, X_T, C_Y, Y_T) \ - MARRAY_BINOP_FWD_FCN (R, operator /, T, C_X, X_T, C_Y, Y_T) - -#define MDIAGARRAY2_SDA_BINOP_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \ - MARRAY_BINOP_FWD_FCN (R, operator *, T, C_X, X_T, C_Y, Y_T) - -#define MDIAGARRAY2_DADA_BINOP_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \ - MARRAY_BINOP_FWD_FCN (R, operator +, T, C_X, X_T, C_Y, Y_T) \ - MARRAY_BINOP_FWD_FCN (R, operator -, T, C_X, X_T, C_Y, Y_T) \ - MARRAY_BINOP_FWD_FCN (R, product, T, C_X, X_T, C_Y, Y_T) - -// Forward declarations for the MArray operators. -#define MARRAY_OPS_FORWARD_DECLS(A_T, API) \ - template <class T> \ - class A_T; \ - \ - MARRAY_OP_ASSIGN_FWD_DECLS (A_T, T, API) \ - MARRAY_OP_ASSIGN_FWD_DECLS (A_T, A_T<T>, API) \ - MARRAY_UNOP_FWD_DECLS (A_T, API) \ - MARRAY_BINOP_FWD_DECLS (A_T, API) - -#define MDIAGARRAY2_OPS_FORWARD_DECLS(A_T, API) \ - template <class T> \ - class A_T; \ - \ - MARRAY_OP_ASSIGN_FWD_DECLS (A_T, A_T<T>, API) \ - MARRAY_UNOP_FWD_DECLS (A_T, API) \ - MDIAGARRAY2_BINOP_FWD_DECLS (A_T, API) - -// Friend declarations for the MArray operators. -#define MARRAY_OPS_FRIEND_DECLS(A_T, API) \ - MARRAY_OP_ASSIGN_FRIENDS (A_T, T, API) \ - MARRAY_OP_ASSIGN_FRIENDS (A_T, A_T<T>, API) \ - MARRAY_UNOP_FRIENDS (A_T, API) \ - MARRAY_BINOP_FRIENDS (A_T, API) - -#define MDIAGARRAY2_OPS_FRIEND_DECLS(A_T, API) \ - MARRAY_OP_ASSIGN_FRIENDS (A_T, A_T<T>, API) \ - MARRAY_UNOP_FRIENDS (A_T, API) \ - MDIAGARRAY2_BINOP_FRIENDS (A_T, API) - // The following macros are for external use. // Instantiate all the MArray friends for MArray element type T. @@ -304,45 +120,6 @@ MARRAY_UNOP_DEFS (MDiagArray2, T, API) \ MDIAGARRAY2_BINOP_DEFS (MDiagArray2, T, API) -// Define all the MArray forwarding functions for return type R and -// MArray element type T -#define MARRAY_FORWARD_DEFS(B, R, T) \ - MARRAY_OP_ASSIGN_FWD_DEFS \ - (R, T, dynamic_cast<B<T>&>, R, , T) \ - \ - MARRAY_OP_ASSIGN_FWD_DEFS \ - (R, T, \ - dynamic_cast<B<T>&>, R, dynamic_cast<const B<T>&>, R) \ - \ - MARRAY_UNOP_FWD_DEFS \ - (R, T, dynamic_cast<const B<T>&>, R) \ - \ - MARRAY_BINOP_FWD_DEFS \ - (R, T, dynamic_cast<const B<T>&>, R, , T) \ - \ - MARRAY_BINOP_FWD_DEFS \ - (R, T, , T, dynamic_cast<const B<T>&>, R) \ - \ - MARRAY_AA_BINOP_FWD_DEFS \ - (R, T, dynamic_cast<const B<T>&>, R, dynamic_cast<const B<T>&>, R) - -#define MDIAGARRAY2_FORWARD_DEFS(B, R, T) \ - MARRAY_OP_ASSIGN_FWD_DEFS \ - (R, T, \ - dynamic_cast<B<T>&>, R, dynamic_cast<const B<T>&>, R) \ - \ - MARRAY_UNOP_FWD_DEFS \ - (R, T, dynamic_cast<const B<T>&>, R) \ - \ - MDIAGARRAY2_DAS_BINOP_FWD_DEFS \ - (R, T, dynamic_cast<const B<T>&>, R, , T) \ - \ - MDIAGARRAY2_SDA_BINOP_FWD_DEFS \ - (R, T, , T, dynamic_cast<const B<T>&>, R) \ - \ - MDIAGARRAY2_DADA_BINOP_FWD_DEFS \ - (R, T, dynamic_cast<const B<T>&>, R, dynamic_cast<const B<T>&>, R) - // Now we have all the definitions we need. #endif
--- a/liboctave/MArray.h +++ b/liboctave/MArray.h @@ -31,7 +31,7 @@ // But first, some preprocessor abuse... -#include "MArray-defs.h" +#include "MArray-decl.h" MARRAY_OPS_FORWARD_DECLS (MArray, )
--- a/liboctave/MArray2.h +++ b/liboctave/MArray2.h @@ -31,7 +31,7 @@ // But first, some preprocessor abuse... -#include "MArray-defs.h" +#include "MArray-decl.h" MARRAY_OPS_FORWARD_DECLS (MArray2, )
--- a/liboctave/MArrayN.h +++ b/liboctave/MArrayN.h @@ -32,7 +32,7 @@ // But first, some preprocessor abuse... -#include "MArray-defs.h" +#include "MArray-decl.h" MARRAY_OPS_FORWARD_DECLS (MArrayN, )
--- a/liboctave/MDiagArray2.h +++ b/liboctave/MDiagArray2.h @@ -33,7 +33,7 @@ // But first, some preprocessor abuse... -#include "MArray-defs.h" +#include "MArray-decl.h" MDIAGARRAY2_OPS_FORWARD_DECLS (MDiagArray2, )
--- a/liboctave/Makefile.in +++ b/liboctave/Makefile.in @@ -41,11 +41,11 @@ $(ARPACK_LIBS) $(QRUPDATE_LIBS) $(BLAS_LIBS) $(FFTW_LIBS) $(LIBREADLINE) $(LIBGLOB) $(REGEX_LIBS) $(LIBS) $(FLIBS) MATRIX_INC := Array.h Array2.h Array3.h ArrayN.h DiagArray2.h \ - Array-util.h ArrayN-idx.h MArray-defs.h \ + Array-util.h ArrayN-idx.h MArray-decl.h MArray-defs.h \ MArray.h MArray2.h MDiagArray2.h Matrix.h MArrayN.h \ - base-lu.h base-aepbal.h dim-vector.h mx-base.h mx-op-defs.h \ - mx-defs.h mx-ext.h CColVector.h CDiagMatrix.h CMatrix.h \ - CNDArray.h CRowVector.h CmplxAEPBAL.h CmplxCHOL.h \ + base-lu.h base-aepbal.h dim-vector.h mx-base.h mx-op-decl.h \ + mx-op-defs.h mx-defs.h mx-ext.h CColVector.h CDiagMatrix.h \ + CMatrix.h CNDArray.h CRowVector.h CmplxAEPBAL.h CmplxCHOL.h \ CmplxGEPBAL.h CmplxHESS.h CmplxLU.h CmplxQR.h CmplxQRP.h \ CmplxSCHUR.h CmplxSVD.h EIG.h fEIG.h boolMatrix.h boolNDArray.h \ chMatrix.h chNDArray.h dColVector.h dDiagMatrix.h dMatrix.h \
--- a/liboctave/boolMatrix.cc +++ b/liboctave/boolMatrix.cc @@ -33,6 +33,7 @@ #include "str-vec.h" #include "mx-base.h" #include "mx-inlines.cc" +#include "mx-op-defs.h" // boolMatrix class.
--- a/liboctave/boolMatrix.h +++ b/liboctave/boolMatrix.h @@ -27,7 +27,7 @@ #include "Array2.h" #include "mx-defs.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" class OCTAVE_API
--- a/liboctave/boolNDArray.cc +++ b/liboctave/boolNDArray.cc @@ -29,6 +29,7 @@ #include "CNDArray.h" #include "mx-base.h" #include "lo-ieee.h" +#include "mx-op-defs.h" // unary operations
--- a/liboctave/boolNDArray.h +++ b/liboctave/boolNDArray.h @@ -26,7 +26,7 @@ #include "ArrayN.h" #include "mx-defs.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" #include "boolMatrix.h"
--- a/liboctave/chMatrix.cc +++ b/liboctave/chMatrix.cc @@ -35,6 +35,7 @@ #include "str-vec.h" #include "mx-base.h" #include "mx-inlines.cc" +#include "mx-op-defs.h" // charMatrix class.
--- a/liboctave/chMatrix.h +++ b/liboctave/chMatrix.h @@ -29,7 +29,7 @@ #include "MArray2.h" #include "mx-defs.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" #include "str-vec.h" class
--- a/liboctave/chNDArray.cc +++ b/liboctave/chNDArray.cc @@ -30,6 +30,7 @@ #include "mx-base.h" #include "lo-ieee.h" #include "lo-mappers.h" +#include "mx-op-defs.h" // FIXME -- this is not quite the right thing.
--- a/liboctave/chNDArray.h +++ b/liboctave/chNDArray.h @@ -27,7 +27,7 @@ #include "chMatrix.h" #include "mx-defs.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" class OCTAVE_API
--- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -51,6 +51,7 @@ #include "mx-m-dm.h" #include "mx-dm-m.h" #include "mx-inlines.cc" +#include "mx-op-defs.h" #include "oct-cmplx.h" #include "oct-norm.h" #include "quit.h"
--- a/liboctave/dMatrix.h +++ b/liboctave/dMatrix.h @@ -29,7 +29,7 @@ #include "MatrixType.h" #include "mx-defs.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" #include "DET.h" class
--- a/liboctave/dNDArray.cc +++ b/liboctave/dNDArray.cc @@ -38,6 +38,7 @@ #include "lo-ieee.h" #include "lo-mappers.h" #include "oct-locbuf.h" +#include "mx-op-defs.h" #if defined (HAVE_FFTW3) #include "oct-fftw.h"
--- a/liboctave/dNDArray.h +++ b/liboctave/dNDArray.h @@ -28,7 +28,7 @@ #include "intNDArray.h" #include "mx-defs.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" class OCTAVE_API
--- a/liboctave/fCMatrix.cc +++ b/liboctave/fCMatrix.cc @@ -55,6 +55,7 @@ #include "mx-fdm-fcm.h" #include "mx-fcm-fs.h" #include "mx-inlines.cc" +#include "mx-op-defs.h" #include "oct-cmplx.h" #include "oct-norm.h"
--- a/liboctave/fCMatrix.h +++ b/liboctave/fCMatrix.h @@ -29,7 +29,7 @@ #include "MatrixType.h" #include "mx-defs.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" #include "oct-cmplx.h" #include "DET.h"
--- a/liboctave/fCNDArray.cc +++ b/liboctave/fCNDArray.cc @@ -37,6 +37,7 @@ #include "lo-ieee.h" #include "lo-mappers.h" #include "oct-locbuf.h" +#include "mx-op-defs.h" #if defined (HAVE_FFTW3) #include "oct-fftw.h"
--- a/liboctave/fCNDArray.h +++ b/liboctave/fCNDArray.h @@ -27,7 +27,7 @@ #include "fCMatrix.h" #include "mx-defs.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" class OCTAVE_API
--- a/liboctave/fMatrix.cc +++ b/liboctave/fMatrix.cc @@ -50,6 +50,7 @@ #include "mx-fm-fdm.h" #include "mx-fdm-fm.h" #include "mx-inlines.cc" +#include "mx-op-defs.h" #include "oct-cmplx.h" #include "oct-norm.h" #include "quit.h"
--- a/liboctave/fMatrix.h +++ b/liboctave/fMatrix.h @@ -29,7 +29,7 @@ #include "MatrixType.h" #include "mx-defs.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" #include "DET.h" class
--- a/liboctave/fNDArray.cc +++ b/liboctave/fNDArray.cc @@ -38,6 +38,7 @@ #include "lo-ieee.h" #include "lo-mappers.h" #include "oct-locbuf.h" +#include "mx-op-defs.h" #if defined (HAVE_FFTW3) #include "oct-fftw.h"
--- a/liboctave/fNDArray.h +++ b/liboctave/fNDArray.h @@ -28,7 +28,7 @@ #include "intNDArray.h" #include "mx-defs.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" class OCTAVE_API
--- a/liboctave/int16NDArray.cc +++ b/liboctave/int16NDArray.cc @@ -26,7 +26,7 @@ #endif #include "int16NDArray.h" - +#include "mx-op-defs.h" #include "intNDArray.cc" template class OCTAVE_API intNDArray<octave_int16>;
--- a/liboctave/int16NDArray.h +++ b/liboctave/int16NDArray.h @@ -24,7 +24,7 @@ #define octave_int16NDArray_h 1 #include "intNDArray.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" #include "oct-inttypes.h" typedef intNDArray<octave_int16> int16NDArray;
--- a/liboctave/int32NDArray.cc +++ b/liboctave/int32NDArray.cc @@ -26,7 +26,7 @@ #endif #include "int32NDArray.h" - +#include "mx-op-defs.h" #include "intNDArray.cc" template class OCTAVE_API intNDArray<octave_int32>;
--- a/liboctave/int32NDArray.h +++ b/liboctave/int32NDArray.h @@ -24,7 +24,7 @@ #define octave_int32NDArray_h 1 #include "intNDArray.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" #include "oct-inttypes.h" typedef intNDArray<octave_int32> int32NDArray;
--- a/liboctave/int64NDArray.cc +++ b/liboctave/int64NDArray.cc @@ -26,7 +26,7 @@ #endif #include "int64NDArray.h" - +#include "mx-op-defs.h" #include "intNDArray.cc" template class OCTAVE_API intNDArray<octave_int64>;
--- a/liboctave/int64NDArray.h +++ b/liboctave/int64NDArray.h @@ -24,7 +24,7 @@ #define octave_int64NDArray_h 1 #include "intNDArray.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" #include "oct-inttypes.h" typedef intNDArray<octave_int64> int64NDArray;
--- a/liboctave/int8NDArray.cc +++ b/liboctave/int8NDArray.cc @@ -26,7 +26,7 @@ #endif #include "int8NDArray.h" - +#include "mx-op-defs.h" #include "intNDArray.cc" template class OCTAVE_API intNDArray<octave_int8>;
--- a/liboctave/int8NDArray.h +++ b/liboctave/int8NDArray.h @@ -24,7 +24,7 @@ #define octave_int8NDArray_h 1 #include "intNDArray.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" #include "oct-inttypes.h" typedef intNDArray<octave_int8> int8NDArray;
--- a/liboctave/mk-ops.awk +++ b/liboctave/mk-ops.awk @@ -162,7 +162,7 @@ printf ("#include \"%s\"\n", rhs_header) >> h_file; } - printf ("#include \"mx-op-defs.h\"\n") >> h_file; + printf ("#include \"mx-op-decl.h\"\n") >> h_file; if (bin_ops) printf ("%s%s_BIN_OP_DECLS (%s, %s, %s, OCTAVE_API)\n", lhs_class, @@ -192,6 +192,8 @@ printf ("#include \"%s\"\n", h_file) >> cc_file; + printf ("#include \"mx-op-defs.h\"\n") >> cc_file; + for (i in bool_headers) { printf ("#include \"%s\"\n", bool_headers[i]) >> cc_file;
new file mode 100644 --- /dev/null +++ b/liboctave/mx-op-decl.h @@ -0,0 +1,300 @@ +/* + +Copyright (C) 1996, 1997, 1998, 2000, 2001, 2003, 2004, 2005, 2006, + 2007 John W. Eaton +Copyright (C) 2008, 2009 Jaroslav Hajek + +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 3 of the License, 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, see +<http://www.gnu.org/licenses/>. + +*/ + +#if !defined (octave_mx_op_decl_h) +#define octave_mx_op_decl_h 1 + +#include "oct-types.h" + +#define BIN_OP_DECL(R, OP, X, Y, API) \ + extern API R OP (const X&, const Y&) + +class boolMatrix; +class boolNDArray; + +#define CMP_OP_DECL(OP, X, Y, API) \ + extern API boolMatrix OP (const X&, const Y&) + +#define NDCMP_OP_DECL(OP, X, Y, API) \ + extern API boolNDArray OP (const X&, const Y&) + +#define BOOL_OP_DECL(OP, X, Y, API) \ + extern API boolMatrix OP (const X&, const Y&) + +#define NDBOOL_OP_DECL(OP, X, Y, API) \ + extern API boolNDArray OP (const X&, const Y&) + +// vector by scalar operations. + +#define VS_BIN_OP_DECLS(R, V, S, API) \ + BIN_OP_DECL (R, operator +, V, S, API); \ + BIN_OP_DECL (R, operator -, V, S, API); \ + BIN_OP_DECL (R, operator *, V, S, API); \ + BIN_OP_DECL (R, operator /, V, S, API); + +#define VS_OP_DECLS(R, V, S, API) \ + VS_BIN_OP_DECLS(R, V, S, API) + +// scalar by vector by operations. + +#define SV_BIN_OP_DECLS(R, S, V, API) \ + BIN_OP_DECL (R, operator +, S, V, API); \ + BIN_OP_DECL (R, operator -, S, V, API); \ + BIN_OP_DECL (R, operator *, S, V, API); \ + BIN_OP_DECL (R, operator /, S, V, API); + +#define SV_OP_DECLS(R, S, V, API) \ + SV_BIN_OP_DECLS(R, S, V, API) + +// vector by vector operations. + +#define VV_BIN_OP_DECLS(R, V1, V2, API) \ + BIN_OP_DECL (R, operator +, V1, V2, API); \ + BIN_OP_DECL (R, operator -, V1, V2, API); \ + BIN_OP_DECL (R, product, V1, V2, API); \ + BIN_OP_DECL (R, quotient, V1, V2, API); + +#define VV_OP_DECLS(R, V1, V2, API) \ + VV_BIN_OP_DECLS(R, V1, V2, API) + +// matrix by scalar operations. + +#define MS_BIN_OP_DECLS(R, M, S, API) \ + BIN_OP_DECL (R, operator +, M, S, API); \ + BIN_OP_DECL (R, operator -, M, S, API); \ + BIN_OP_DECL (R, operator *, M, S, API); \ + BIN_OP_DECL (R, operator /, M, S, API); + +#define MS_CMP_OP_DECLS(M, S, API) \ + CMP_OP_DECL (mx_el_lt, M, S, API); \ + CMP_OP_DECL (mx_el_le, M, S, API); \ + CMP_OP_DECL (mx_el_ge, M, S, API); \ + CMP_OP_DECL (mx_el_gt, M, S, API); \ + CMP_OP_DECL (mx_el_eq, M, S, API); \ + CMP_OP_DECL (mx_el_ne, M, S, API); + +#define MS_BOOL_OP_DECLS(M, S, API) \ + BOOL_OP_DECL (mx_el_and, M, S, API); \ + BOOL_OP_DECL (mx_el_or, M, S, API); \ + +#define MS_OP_DECLS(R, M, S, API) \ + MS_BIN_OP_DECLS (R, M, S, API) \ + MS_CMP_OP_DECLS (M, S, API) \ + MS_BOOL_OP_DECLS (M, S, API) \ + +// scalar by matrix operations. + +#define SM_BIN_OP_DECLS(R, S, M, API) \ + BIN_OP_DECL (R, operator +, S, M, API); \ + BIN_OP_DECL (R, operator -, S, M, API); \ + BIN_OP_DECL (R, operator *, S, M, API); \ + BIN_OP_DECL (R, operator /, S, M, API); + +#define SM_CMP_OP_DECLS(S, M, API) \ + CMP_OP_DECL (mx_el_lt, S, M, API); \ + CMP_OP_DECL (mx_el_le, S, M, API); \ + CMP_OP_DECL (mx_el_ge, S, M, API); \ + CMP_OP_DECL (mx_el_gt, S, M, API); \ + CMP_OP_DECL (mx_el_eq, S, M, API); \ + CMP_OP_DECL (mx_el_ne, S, M, API); + +#define SM_BOOL_OP_DECLS(S, M, API) \ + BOOL_OP_DECL (mx_el_and, S, M, API); \ + BOOL_OP_DECL (mx_el_or, S, M, API); \ + +#define SM_OP_DECLS(R, S, M, API) \ + SM_BIN_OP_DECLS (R, S, M, API) \ + SM_CMP_OP_DECLS (S, M, API) \ + SM_BOOL_OP_DECLS (S, M, API) \ + +// matrix by matrix operations. + +#define MM_BIN_OP_DECLS(R, M1, M2, API) \ + BIN_OP_DECL (R, operator +, M1, M2, API); \ + BIN_OP_DECL (R, operator -, M1, M2, API); \ + BIN_OP_DECL (R, product, M1, M2, API); \ + BIN_OP_DECL (R, quotient, M1, M2, API); + +#define MM_CMP_OP_DECLS(M1, M2, API) \ + CMP_OP_DECL (mx_el_lt, M1, M2, API); \ + CMP_OP_DECL (mx_el_le, M1, M2, API); \ + CMP_OP_DECL (mx_el_ge, M1, M2, API); \ + CMP_OP_DECL (mx_el_gt, M1, M2, API); \ + CMP_OP_DECL (mx_el_eq, M1, M2, API); \ + CMP_OP_DECL (mx_el_ne, M1, M2, API); + +#define MM_BOOL_OP_DECLS(M1, M2, API) \ + BOOL_OP_DECL (mx_el_and, M1, M2, API); \ + BOOL_OP_DECL (mx_el_or, M1, M2, API); + +#define MM_OP_DECLS(R, M1, M2, API) \ + MM_BIN_OP_DECLS (R, M1, M2, API) \ + MM_CMP_OP_DECLS (M1, M2, API) \ + MM_BOOL_OP_DECLS (M1, M2, API) + +// N-d matrix by scalar operations. + +#define NDS_BIN_OP_DECLS(R, ND, S, API) \ + BIN_OP_DECL (R, operator +, ND, S, API); \ + BIN_OP_DECL (R, operator -, ND, S, API); \ + BIN_OP_DECL (R, operator *, ND, S, API); \ + BIN_OP_DECL (R, operator /, ND, S, API); + +#define NDS_CMP_OP_DECLS(ND, S, API) \ + NDCMP_OP_DECL (mx_el_lt, ND, S, API); \ + NDCMP_OP_DECL (mx_el_le, ND, S, API); \ + NDCMP_OP_DECL (mx_el_ge, ND, S, API); \ + NDCMP_OP_DECL (mx_el_gt, ND, S, API); \ + NDCMP_OP_DECL (mx_el_eq, ND, S, API); \ + NDCMP_OP_DECL (mx_el_ne, ND, S, API); + +#define NDS_BOOL_OP_DECLS(ND, S, API) \ + NDBOOL_OP_DECL (mx_el_and, ND, S, API); \ + NDBOOL_OP_DECL (mx_el_or, ND, S, API); + +#define NDS_OP_DECLS(R, ND, S, API) \ + NDS_BIN_OP_DECLS (R, ND, S, API) \ + NDS_CMP_OP_DECLS (ND, S, API) \ + NDS_BOOL_OP_DECLS (ND, S, API) + +// scalar by N-d matrix operations. + +#define SND_BIN_OP_DECLS(R, S, ND, API) \ + BIN_OP_DECL (R, operator +, S, ND, API); \ + BIN_OP_DECL (R, operator -, S, ND, API); \ + BIN_OP_DECL (R, operator *, S, ND, API); \ + BIN_OP_DECL (R, operator /, S, ND, API); + +#define SND_CMP_OP_DECLS(S, ND, API) \ + NDCMP_OP_DECL (mx_el_lt, S, ND, API); \ + NDCMP_OP_DECL (mx_el_le, S, ND, API); \ + NDCMP_OP_DECL (mx_el_ge, S, ND, API); \ + NDCMP_OP_DECL (mx_el_gt, S, ND, API); \ + NDCMP_OP_DECL (mx_el_eq, S, ND, API); \ + NDCMP_OP_DECL (mx_el_ne, S, ND, API); + +#define SND_BOOL_OP_DECLS(S, ND, API) \ + NDBOOL_OP_DECL (mx_el_and, S, ND, API); \ + NDBOOL_OP_DECL (mx_el_or, S, ND, API); + +#define SND_OP_DECLS(R, S, ND, API) \ + SND_BIN_OP_DECLS (R, S, ND, API) \ + SND_CMP_OP_DECLS (S, ND, API) \ + SND_BOOL_OP_DECLS (S, ND, API) + +// N-d matrix by N-d matrix operations. + +#define NDND_BIN_OP_DECLS(R, ND1, ND2, API) \ + BIN_OP_DECL (R, operator +, ND1, ND2, API); \ + BIN_OP_DECL (R, operator -, ND1, ND2, API); \ + BIN_OP_DECL (R, product, ND1, ND2, API); \ + BIN_OP_DECL (R, quotient, ND1, ND2, API); + +#define NDND_CMP_OP_DECLS(ND1, ND2, API) \ + NDCMP_OP_DECL (mx_el_lt, ND1, ND2, API); \ + NDCMP_OP_DECL (mx_el_le, ND1, ND2, API); \ + NDCMP_OP_DECL (mx_el_ge, ND1, ND2, API); \ + NDCMP_OP_DECL (mx_el_gt, ND1, ND2, API); \ + NDCMP_OP_DECL (mx_el_eq, ND1, ND2, API); \ + NDCMP_OP_DECL (mx_el_ne, ND1, ND2, API); + +#define NDND_BOOL_OP_DECLS(ND1, ND2, API) \ + NDBOOL_OP_DECL (mx_el_and, ND1, ND2, API); \ + NDBOOL_OP_DECL (mx_el_or, ND1, ND2, API); + +#define NDND_OP_DECLS(R, ND1, ND2, API) \ + NDND_BIN_OP_DECLS (R, ND1, ND2, API) \ + NDND_CMP_OP_DECLS (ND1, ND2, API) \ + NDND_BOOL_OP_DECLS (ND1, ND2, API) + +// scalar by diagonal matrix operations. + +#define SDM_BIN_OP_DECLS(R, S, DM, API) \ + BIN_OP_DECL (R, operator +, S, DM, API); \ + BIN_OP_DECL (R, operator -, S, DM, API); + +#define SDM_OP_DECLS(R, S, DM, API) \ + SDM_BIN_OP_DECLS(R, S, DM, API) + +// diagonal matrix by scalar operations. + +#define DMS_BIN_OP_DECLS(R, DM, S, API) \ + BIN_OP_DECL (R, operator +, DM, S, API); \ + BIN_OP_DECL (R, operator -, DM, S, API); + +#define DMS_OP_DECLS(R, DM, S, API) \ + DMS_BIN_OP_DECLS(R, DM, S, API) + +// matrix by diagonal matrix operations. + +#define MDM_BIN_OP_DECLS(R, M, DM, API) \ + BIN_OP_DECL (R, operator +, M, DM, API); \ + BIN_OP_DECL (R, operator -, M, DM, API); \ + BIN_OP_DECL (R, operator *, M, DM, API); + +#define MDM_OP_DECLS(R, M, DM, API) \ + MDM_BIN_OP_DECLS(R, M, DM, API) + +// diagonal matrix by matrix operations. + +#define DMM_BIN_OP_DECLS(R, DM, M, API) \ + BIN_OP_DECL (R, operator +, DM, M, API); \ + BIN_OP_DECL (R, operator -, DM, M, API); \ + BIN_OP_DECL (R, operator *, DM, M, API); + +#define DMM_OP_DECLS(R, DM, M, API) \ + DMM_BIN_OP_DECLS(R, DM, M, API) + +// diagonal matrix by diagonal matrix operations. + +#define DMDM_BIN_OP_DECLS(R, DM1, DM2, API) \ + BIN_OP_DECL (R, operator +, DM1, DM2, API); \ + BIN_OP_DECL (R, operator -, DM1, DM2, API); \ + BIN_OP_DECL (R, product, DM1, DM2, API); + +#define DMDM_OP_DECLS(R, DM1, DM2, API) \ + DMDM_BIN_OP_DECLS (R, DM1, DM2, API) + +// scalar by N-d array min/max ops + +#define MINMAX_DECLS(T) \ + extern OCTAVE_API T ## NDArray min (octave_ ## T d, const T ## NDArray& m); \ + extern OCTAVE_API T ## NDArray min (const T ## NDArray& m, octave_ ## T d); \ + extern OCTAVE_API T ## NDArray min (const T ## NDArray& a, \ + const T ## NDArray& b); \ + extern OCTAVE_API T ## NDArray max (octave_ ## T d, const T ## NDArray& m); \ + extern OCTAVE_API T ## NDArray max (const T ## NDArray& m, octave_ ## T d); \ + extern OCTAVE_API T ## NDArray max (const T ## NDArray& a, \ + const T ## NDArray& b); + +// permutation matrix by matrix ops and vice versa + +#define PMM_BIN_OP_DECLS(R, PM, M, API) \ + BIN_OP_DECL (R, operator *, PM, M, API); + +#define MPM_BIN_OP_DECLS(R, M, PM, API) \ + BIN_OP_DECL (R, operator *, M, PM, API); + +#endif +
--- a/liboctave/mx-op-defs.h +++ b/liboctave/mx-op-defs.h @@ -25,35 +25,11 @@ #if !defined (octave_mx_op_defs_h) #define octave_mx_op_defs_h 1 -#include "oct-types.h" +#include "mx-op-decl.h" #include "mx-inlines.cc" -#define BIN_OP_DECL(R, OP, X, Y, API) \ - extern API R OP (const X&, const Y&) - -class boolMatrix; -class boolNDArray; - -#define CMP_OP_DECL(OP, X, Y, API) \ - extern API boolMatrix OP (const X&, const Y&) - -#define NDCMP_OP_DECL(OP, X, Y, API) \ - extern API boolNDArray OP (const X&, const Y&) - -#define BOOL_OP_DECL(OP, X, Y, API) \ - extern API boolMatrix OP (const X&, const Y&) - -#define NDBOOL_OP_DECL(OP, X, Y, API) \ - extern API boolNDArray OP (const X&, const Y&) - // vector by scalar operations. -#define VS_BIN_OP_DECLS(R, V, S, API) \ - BIN_OP_DECL (R, operator +, V, S, API); \ - BIN_OP_DECL (R, operator -, V, S, API); \ - BIN_OP_DECL (R, operator *, V, S, API); \ - BIN_OP_DECL (R, operator /, V, S, API); - #define VS_BIN_OP(R, F, OP, V, S) \ R \ F (const V& v, const S& s) \ @@ -74,17 +50,8 @@ VS_BIN_OP (R, operator *, *, V, S) \ VS_BIN_OP (R, operator /, /, V, S) -#define VS_OP_DECLS(R, V, S, API) \ - VS_BIN_OP_DECLS(R, V, S, API) - // scalar by vector by operations. -#define SV_BIN_OP_DECLS(R, S, V, API) \ - BIN_OP_DECL (R, operator +, S, V, API); \ - BIN_OP_DECL (R, operator -, S, V, API); \ - BIN_OP_DECL (R, operator *, S, V, API); \ - BIN_OP_DECL (R, operator /, S, V, API); - #define SV_BIN_OP(R, F, OP, S, V) \ R \ F (const S& s, const V& v) \ @@ -105,17 +72,8 @@ SV_BIN_OP (R, operator *, *, S, V) \ SV_BIN_OP (R, operator /, /, S, V) -#define SV_OP_DECLS(R, S, V, API) \ - SV_BIN_OP_DECLS(R, S, V, API) - // vector by vector operations. -#define VV_BIN_OP_DECLS(R, V1, V2, API) \ - BIN_OP_DECL (R, operator +, V1, V2, API); \ - BIN_OP_DECL (R, operator -, V1, V2, API); \ - BIN_OP_DECL (R, product, V1, V2, API); \ - BIN_OP_DECL (R, quotient, V1, V2, API); - #define VV_BIN_OP(R, F, OP, V1, V2) \ R \ F (const V1& v1, const V2& v2) \ @@ -144,17 +102,8 @@ VV_BIN_OP (R, product, *, V1, V2) \ VV_BIN_OP (R, quotient, /, V1, V2) -#define VV_OP_DECLS(R, V1, V2, API) \ - VV_BIN_OP_DECLS(R, V1, V2, API) - // matrix by scalar operations. -#define MS_BIN_OP_DECLS(R, M, S, API) \ - BIN_OP_DECL (R, operator +, M, S, API); \ - BIN_OP_DECL (R, operator -, M, S, API); \ - BIN_OP_DECL (R, operator *, M, S, API); \ - BIN_OP_DECL (R, operator /, M, S, API); - #define MS_BIN_OP(R, OP, M, S, F) \ R \ OP (const M& m, const S& s) \ @@ -176,14 +125,6 @@ MS_BIN_OP (R, operator *, M, S, mx_inline_multiply) \ MS_BIN_OP (R, operator /, M, S, mx_inline_divide) -#define MS_CMP_OP_DECLS(M, S, API) \ - CMP_OP_DECL (mx_el_lt, M, S, API); \ - CMP_OP_DECL (mx_el_le, M, S, API); \ - CMP_OP_DECL (mx_el_ge, M, S, API); \ - CMP_OP_DECL (mx_el_gt, M, S, API); \ - CMP_OP_DECL (mx_el_eq, M, S, API); \ - CMP_OP_DECL (mx_el_ne, M, S, API); - #define MS_CMP_OP(F, OP, M, MC, S, SC) \ boolMatrix \ F (const M& m, const S& s) \ @@ -213,10 +154,6 @@ MS_CMP_OP (mx_el_eq, ==, M, , S, ) \ MS_CMP_OP (mx_el_ne, !=, M, , S, ) -#define MS_BOOL_OP_DECLS(M, S, API) \ - BOOL_OP_DECL (mx_el_and, M, S, API); \ - BOOL_OP_DECL (mx_el_or, M, S, API); \ - #define MS_BOOL_OP(F, OP, M, S, LHS_ZERO, RHS_ZERO) \ boolMatrix \ F (const M& m, const S& s) \ @@ -257,19 +194,8 @@ #define MS_BOOL_OPS(M, S, ZERO) \ MS_BOOL_OPS2(M, S, ZERO, ZERO) -#define MS_OP_DECLS(R, M, S, API) \ - MS_BIN_OP_DECLS (R, M, S, API) \ - MS_CMP_OP_DECLS (M, S, API) \ - MS_BOOL_OP_DECLS (M, S, API) \ - // scalar by matrix operations. -#define SM_BIN_OP_DECLS(R, S, M, API) \ - BIN_OP_DECL (R, operator +, S, M, API); \ - BIN_OP_DECL (R, operator -, S, M, API); \ - BIN_OP_DECL (R, operator *, S, M, API); \ - BIN_OP_DECL (R, operator /, S, M, API); - #define SM_BIN_OP(R, OP, S, M, F) \ R \ OP (const S& s, const M& m) \ @@ -291,14 +217,6 @@ SM_BIN_OP (R, operator *, S, M, mx_inline_multiply) \ SM_BIN_OP (R, operator /, S, M, mx_inline_divide) -#define SM_CMP_OP_DECLS(S, M, API) \ - CMP_OP_DECL (mx_el_lt, S, M, API); \ - CMP_OP_DECL (mx_el_le, S, M, API); \ - CMP_OP_DECL (mx_el_ge, S, M, API); \ - CMP_OP_DECL (mx_el_gt, S, M, API); \ - CMP_OP_DECL (mx_el_eq, S, M, API); \ - CMP_OP_DECL (mx_el_ne, S, M, API); - #define SM_CMP_OP(F, OP, S, SC, M, MC) \ boolMatrix \ F (const S& s, const M& m) \ @@ -328,10 +246,6 @@ SM_CMP_OP (mx_el_eq, ==, S, , M, ) \ SM_CMP_OP (mx_el_ne, !=, S, , M, ) -#define SM_BOOL_OP_DECLS(S, M, API) \ - BOOL_OP_DECL (mx_el_and, S, M, API); \ - BOOL_OP_DECL (mx_el_or, S, M, API); \ - #define SM_BOOL_OP(F, OP, S, M, LHS_ZERO, RHS_ZERO) \ boolMatrix \ F (const S& s, const M& m) \ @@ -371,19 +285,8 @@ #define SM_BOOL_OPS(S, M, ZERO) \ SM_BOOL_OPS2(S, M, ZERO, ZERO) -#define SM_OP_DECLS(R, S, M, API) \ - SM_BIN_OP_DECLS (R, S, M, API) \ - SM_CMP_OP_DECLS (S, M, API) \ - SM_BOOL_OP_DECLS (S, M, API) \ - // matrix by matrix operations. -#define MM_BIN_OP_DECLS(R, M1, M2, API) \ - BIN_OP_DECL (R, operator +, M1, M2, API); \ - BIN_OP_DECL (R, operator -, M1, M2, API); \ - BIN_OP_DECL (R, product, M1, M2, API); \ - BIN_OP_DECL (R, quotient, M1, M2, API); - #define MM_BIN_OP(R, OP, M1, M2, F) \ R \ OP (const M1& m1, const M2& m2) \ @@ -415,14 +318,6 @@ MM_BIN_OP (R, product, M1, M2, mx_inline_multiply) \ MM_BIN_OP (R, quotient, M1, M2, mx_inline_divide) -#define MM_CMP_OP_DECLS(M1, M2, API) \ - CMP_OP_DECL (mx_el_lt, M1, M2, API); \ - CMP_OP_DECL (mx_el_le, M1, M2, API); \ - CMP_OP_DECL (mx_el_ge, M1, M2, API); \ - CMP_OP_DECL (mx_el_gt, M1, M2, API); \ - CMP_OP_DECL (mx_el_eq, M1, M2, API); \ - CMP_OP_DECL (mx_el_ne, M1, M2, API); - #define MM_CMP_OP(F, OP, M1, C1, M2, C2) \ boolMatrix \ F (const M1& m1, const M2& m2) \ @@ -457,10 +352,6 @@ MM_CMP_OP (mx_el_eq, ==, M1, , M2, ) \ MM_CMP_OP (mx_el_ne, !=, M1, , M2, ) -#define MM_BOOL_OP_DECLS(M1, M2, API) \ - BOOL_OP_DECL (mx_el_and, M1, M2, API); \ - BOOL_OP_DECL (mx_el_or, M1, M2, API); - #define MM_BOOL_OP(F, OP, M1, M2, LHS_ZERO, RHS_ZERO) \ boolMatrix \ F (const M1& m1, const M2& m2) \ @@ -507,19 +398,8 @@ #define MM_BOOL_OPS(M1, M2, ZERO) \ MM_BOOL_OPS2(M1, M2, ZERO, ZERO) -#define MM_OP_DECLS(R, M1, M2, API) \ - MM_BIN_OP_DECLS (R, M1, M2, API) \ - MM_CMP_OP_DECLS (M1, M2, API) \ - MM_BOOL_OP_DECLS (M1, M2, API) - // N-d matrix by scalar operations. -#define NDS_BIN_OP_DECLS(R, ND, S, API) \ - BIN_OP_DECL (R, operator +, ND, S, API); \ - BIN_OP_DECL (R, operator -, ND, S, API); \ - BIN_OP_DECL (R, operator *, ND, S, API); \ - BIN_OP_DECL (R, operator /, ND, S, API); - #define NDS_BIN_OP(R, OP, ND, S, F) \ R \ OP (const ND& m, const S& s) \ @@ -540,14 +420,6 @@ NDS_BIN_OP (R, operator *, ND, S, mx_inline_multiply) \ NDS_BIN_OP (R, operator /, ND, S, mx_inline_divide) -#define NDS_CMP_OP_DECLS(ND, S, API) \ - NDCMP_OP_DECL (mx_el_lt, ND, S, API); \ - NDCMP_OP_DECL (mx_el_le, ND, S, API); \ - NDCMP_OP_DECL (mx_el_ge, ND, S, API); \ - NDCMP_OP_DECL (mx_el_gt, ND, S, API); \ - NDCMP_OP_DECL (mx_el_eq, ND, S, API); \ - NDCMP_OP_DECL (mx_el_ne, ND, S, API); - #define NDS_CMP_OP(F, OP, ND, NDC, S, SC) \ boolNDArray \ F (const ND& m, const S& s) \ @@ -620,10 +492,6 @@ NDS_CMP_OP2 (mx_el_eq, ==, ND, , S, , SPEC1, SPEC2) \ NDS_CMP_OP2 (mx_el_ne, !=, ND, , S, , SPEC1, SPEC2) -#define NDS_BOOL_OP_DECLS(ND, S, API) \ - NDBOOL_OP_DECL (mx_el_and, ND, S, API); \ - NDBOOL_OP_DECL (mx_el_or, ND, S, API); - #define NDS_BOOL_OP(F, OP, ND, S, LHS_ZERO, RHS_ZERO) \ boolNDArray \ F (const ND& m, const S& s) \ @@ -661,19 +529,8 @@ #define NDS_BOOL_OPS(ND, S, ZERO) \ NDS_BOOL_OPS2(ND, S, ZERO, ZERO) -#define NDS_OP_DECLS(R, ND, S, API) \ - NDS_BIN_OP_DECLS (R, ND, S, API) \ - NDS_CMP_OP_DECLS (ND, S, API) \ - NDS_BOOL_OP_DECLS (ND, S, API) - // scalar by N-d matrix operations. -#define SND_BIN_OP_DECLS(R, S, ND, API) \ - BIN_OP_DECL (R, operator +, S, ND, API); \ - BIN_OP_DECL (R, operator -, S, ND, API); \ - BIN_OP_DECL (R, operator *, S, ND, API); \ - BIN_OP_DECL (R, operator /, S, ND, API); - #define SND_BIN_OP(R, OP, S, ND, F) \ R \ OP (const S& s, const ND& m) \ @@ -694,14 +551,6 @@ SND_BIN_OP (R, operator *, S, ND, mx_inline_multiply) \ SND_BIN_OP (R, operator /, S, ND, mx_inline_divide) -#define SND_CMP_OP_DECLS(S, ND, API) \ - NDCMP_OP_DECL (mx_el_lt, S, ND, API); \ - NDCMP_OP_DECL (mx_el_le, S, ND, API); \ - NDCMP_OP_DECL (mx_el_ge, S, ND, API); \ - NDCMP_OP_DECL (mx_el_gt, S, ND, API); \ - NDCMP_OP_DECL (mx_el_eq, S, ND, API); \ - NDCMP_OP_DECL (mx_el_ne, S, ND, API); - #define SND_CMP_OP(F, OP, S, SC, ND, NDC) \ boolNDArray \ F (const S& s, const ND& m) \ @@ -774,10 +623,6 @@ SND_CMP_OP2 (mx_el_eq, ==, S, , ND, , SPEC1, SPEC2) \ SND_CMP_OP2 (mx_el_ne, !=, S, , ND, , SPEC1, SPEC2) -#define SND_BOOL_OP_DECLS(S, ND, API) \ - NDBOOL_OP_DECL (mx_el_and, S, ND, API); \ - NDBOOL_OP_DECL (mx_el_or, S, ND, API); - #define SND_BOOL_OP(F, OP, S, ND, LHS_ZERO, RHS_ZERO) \ boolNDArray \ F (const S& s, const ND& m) \ @@ -815,19 +660,8 @@ #define SND_BOOL_OPS(S, ND, ZERO) \ SND_BOOL_OPS2(S, ND, ZERO, ZERO) -#define SND_OP_DECLS(R, S, ND, API) \ - SND_BIN_OP_DECLS (R, S, ND, API) \ - SND_CMP_OP_DECLS (S, ND, API) \ - SND_BOOL_OP_DECLS (S, ND, API) - // N-d matrix by N-d matrix operations. -#define NDND_BIN_OP_DECLS(R, ND1, ND2, API) \ - BIN_OP_DECL (R, operator +, ND1, ND2, API); \ - BIN_OP_DECL (R, operator -, ND1, ND2, API); \ - BIN_OP_DECL (R, product, ND1, ND2, API); \ - BIN_OP_DECL (R, quotient, ND1, ND2, API); - #define NDND_BIN_OP(R, OP, ND1, ND2, F) \ R \ OP (const ND1& m1, const ND2& m2) \ @@ -858,14 +692,6 @@ NDND_BIN_OP (R, product, ND1, ND2, mx_inline_multiply) \ NDND_BIN_OP (R, quotient, ND1, ND2, mx_inline_divide) -#define NDND_CMP_OP_DECLS(ND1, ND2, API) \ - NDCMP_OP_DECL (mx_el_lt, ND1, ND2, API); \ - NDCMP_OP_DECL (mx_el_le, ND1, ND2, API); \ - NDCMP_OP_DECL (mx_el_ge, ND1, ND2, API); \ - NDCMP_OP_DECL (mx_el_gt, ND1, ND2, API); \ - NDCMP_OP_DECL (mx_el_eq, ND1, ND2, API); \ - NDCMP_OP_DECL (mx_el_ne, ND1, ND2, API); - #define NDND_CMP_OP(F, OP, ND1, C1, ND2, C2) \ boolNDArray \ F (const ND1& m1, const ND2& m2) \ @@ -896,10 +722,6 @@ NDND_CMP_OP (mx_el_eq, ==, ND1, , ND2, ) \ NDND_CMP_OP (mx_el_ne, !=, ND1, , ND2, ) -#define NDND_BOOL_OP_DECLS(ND1, ND2, API) \ - NDBOOL_OP_DECL (mx_el_and, ND1, ND2, API); \ - NDBOOL_OP_DECL (mx_el_or, ND1, ND2, API); - #define NDND_BOOL_OP(F, OP, ND1, ND2, LHS_ZERO, RHS_ZERO) \ boolNDArray \ F (const ND1& m1, const ND2& m2) \ @@ -938,17 +760,8 @@ #define NDND_BOOL_OPS(ND1, ND2, ZERO) \ NDND_BOOL_OPS2(ND1, ND2, ZERO, ZERO) -#define NDND_OP_DECLS(R, ND1, ND2, API) \ - NDND_BIN_OP_DECLS (R, ND1, ND2, API) \ - NDND_CMP_OP_DECLS (ND1, ND2, API) \ - NDND_BOOL_OP_DECLS (ND1, ND2, API) - // scalar by diagonal matrix operations. -#define SDM_BIN_OP_DECLS(R, S, DM, API) \ - BIN_OP_DECL (R, operator +, S, DM, API); \ - BIN_OP_DECL (R, operator -, S, DM, API); - #define SDM_BIN_OP(R, OP, S, DM, OPEQ) \ R \ OP (const S& s, const DM& dm) \ @@ -968,15 +781,8 @@ SDM_BIN_OP (R, operator +, S, DM, +=) \ SDM_BIN_OP (R, operator -, S, DM, -=) -#define SDM_OP_DECLS(R, S, DM, API) \ - SDM_BIN_OP_DECLS(R, S, DM, API) - // diagonal matrix by scalar operations. -#define DMS_BIN_OP_DECLS(R, DM, S, API) \ - BIN_OP_DECL (R, operator +, DM, S, API); \ - BIN_OP_DECL (R, operator -, DM, S, API); - #define DMS_BIN_OP(R, OP, DM, S, SGN) \ R \ OP (const DM& dm, const S& s) \ @@ -996,16 +802,8 @@ DMS_BIN_OP (R, operator +, DM, S, ) \ DMS_BIN_OP (R, operator -, DM, S, -) -#define DMS_OP_DECLS(R, DM, S, API) \ - DMS_BIN_OP_DECLS(R, DM, S, API) - // matrix by diagonal matrix operations. -#define MDM_BIN_OP_DECLS(R, M, DM, API) \ - BIN_OP_DECL (R, operator +, M, DM, API); \ - BIN_OP_DECL (R, operator -, M, DM, API); \ - BIN_OP_DECL (R, operator *, M, DM, API); - #define MDM_BIN_OP(R, OP, M, DM, OPEQ) \ R \ OP (const M& m, const DM& dm) \ @@ -1076,16 +874,8 @@ MDM_BIN_OP (R, operator -, M, DM, -=) \ MDM_MULTIPLY_OP (R, M, DM, R_ZERO) -#define MDM_OP_DECLS(R, M, DM, API) \ - MDM_BIN_OP_DECLS(R, M, DM, API) - // diagonal matrix by matrix operations. -#define DMM_BIN_OP_DECLS(R, DM, M, API) \ - BIN_OP_DECL (R, operator +, DM, M, API); \ - BIN_OP_DECL (R, operator -, DM, M, API); \ - BIN_OP_DECL (R, operator *, DM, M, API); - #define DMM_BIN_OP(R, OP, DM, M, OPEQ, PREOP) \ R \ OP (const DM& dm, const M& m) \ @@ -1157,16 +947,8 @@ DMM_BIN_OP (R, operator -, DM, M, +=, -) \ DMM_MULTIPLY_OP (R, DM, M, R_ZERO) -#define DMM_OP_DECLS(R, DM, M, API) \ - DMM_BIN_OP_DECLS(R, DM, M, API) - // diagonal matrix by diagonal matrix operations. -#define DMDM_BIN_OP_DECLS(R, DM1, DM2, API) \ - BIN_OP_DECL (R, operator +, DM1, DM2, API); \ - BIN_OP_DECL (R, operator -, DM1, DM2, API); \ - BIN_OP_DECL (R, product, DM1, DM2, API); - #define DMDM_BIN_OP(R, OP, DM1, DM2, F) \ R \ OP (const DM1& dm1, const DM2& dm2) \ @@ -1198,10 +980,7 @@ DMDM_BIN_OP (R, operator -, DM1, DM2, mx_inline_subtract) \ DMDM_BIN_OP (R, product, DM1, DM2, mx_inline_multiply) -#define DMDM_OP_DECLS(R, DM1, DM2, API) \ - DMDM_BIN_OP_DECLS (R, DM1, DM2, API) - -#endif +// scalar by N-d array min/max ops #define SND_MINMAX_FCN(FCN, OP, T) \ T ## NDArray \ @@ -1281,15 +1060,7 @@ NDS_MINMAX_FCN (max, >, T) \ NDND_MINMAX_FCN (max, >, T) -#define MINMAX_DECLS(T) \ - extern OCTAVE_API T ## NDArray min (octave_ ## T d, const T ## NDArray& m); \ - extern OCTAVE_API T ## NDArray min (const T ## NDArray& m, octave_ ## T d); \ - extern OCTAVE_API T ## NDArray min (const T ## NDArray& a, \ - const T ## NDArray& b); \ - extern OCTAVE_API T ## NDArray max (octave_ ## T d, const T ## NDArray& m); \ - extern OCTAVE_API T ## NDArray max (const T ## NDArray& m, octave_ ## T d); \ - extern OCTAVE_API T ## NDArray max (const T ## NDArray& a, \ - const T ## NDArray& b); +// permutation matrix by matrix ops and vice versa #define PMM_MULTIPLY_OP(PM, M) \ M operator * (const PM& p, const M& x) \ @@ -1333,18 +1104,14 @@ return result; \ } -#define PMM_BIN_OP_DECLS(R, PM, M, API) \ - BIN_OP_DECL (R, operator *, PM, M, API); - #define PMM_BIN_OPS(R, PM, M) \ PMM_MULTIPLY_OP(PM, M); -#define MPM_BIN_OP_DECLS(R, M, PM, API) \ - BIN_OP_DECL (R, operator *, M, PM, API); - #define MPM_BIN_OPS(R, M, PM) \ MPM_MULTIPLY_OP(M, PM); +#endif + /* ;;; Local Variables: ***
--- a/liboctave/uint16NDArray.cc +++ b/liboctave/uint16NDArray.cc @@ -26,7 +26,7 @@ #endif #include "uint16NDArray.h" - +#include "mx-op-defs.h" #include "intNDArray.cc" template class OCTAVE_API intNDArray<octave_uint16>;
--- a/liboctave/uint16NDArray.h +++ b/liboctave/uint16NDArray.h @@ -24,7 +24,7 @@ #define octave_uint16NDArray_h 1 #include "intNDArray.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" #include "oct-inttypes.h" typedef intNDArray<octave_uint16> uint16NDArray;
--- a/liboctave/uint32NDArray.cc +++ b/liboctave/uint32NDArray.cc @@ -26,7 +26,7 @@ #endif #include "uint32NDArray.h" - +#include "mx-op-defs.h" #include "intNDArray.cc" template class OCTAVE_API intNDArray<octave_uint32>;
--- a/liboctave/uint32NDArray.h +++ b/liboctave/uint32NDArray.h @@ -24,7 +24,7 @@ #define octave_uint32NDArray_h 1 #include "intNDArray.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" #include "oct-inttypes.h" typedef intNDArray<octave_uint32> uint32NDArray;
--- a/liboctave/uint64NDArray.cc +++ b/liboctave/uint64NDArray.cc @@ -26,7 +26,7 @@ #endif #include "uint64NDArray.h" - +#include "mx-op-defs.h" #include "intNDArray.cc" template class OCTAVE_API intNDArray<octave_uint64>;
--- a/liboctave/uint64NDArray.h +++ b/liboctave/uint64NDArray.h @@ -24,7 +24,7 @@ #define octave_uint64NDArray_h 1 #include "intNDArray.h" -#include "mx-op-defs.h" +#include "mx-op-decl.h" #include "oct-inttypes.h" typedef intNDArray<octave_uint64> uint64NDArray;