Mercurial > hg > octave-terminal
changeset 10329:83fa590b8a09
simplify min/max definitions in liboctave
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 17 Feb 2010 10:40:36 +0100 |
parents | 2210d3070543 |
children | e0767a0965f1 |
files | liboctave/CNDArray.cc liboctave/CNDArray.h liboctave/ChangeLog liboctave/dNDArray.cc liboctave/dNDArray.h liboctave/fCNDArray.cc liboctave/fCNDArray.h liboctave/fNDArray.cc liboctave/fNDArray.h liboctave/int16NDArray.cc liboctave/int16NDArray.h liboctave/int32NDArray.cc liboctave/int32NDArray.h liboctave/int64NDArray.cc liboctave/int64NDArray.h liboctave/int8NDArray.cc liboctave/int8NDArray.h liboctave/mx-op-decl.h liboctave/mx-op-defs.h liboctave/uint16NDArray.cc liboctave/uint16NDArray.h liboctave/uint32NDArray.cc liboctave/uint32NDArray.h liboctave/uint64NDArray.cc liboctave/uint64NDArray.h liboctave/uint8NDArray.cc liboctave/uint8NDArray.h |
diffstat | 27 files changed, 69 insertions(+), 212 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/CNDArray.cc +++ b/liboctave/CNDArray.cc @@ -914,41 +914,7 @@ return is; } -ComplexNDArray -min (const Complex& s, const ComplexNDArray& m) -{ - return do_sm_binary_op<ComplexNDArray> (s, m, mx_inline_xmin); -} - -ComplexNDArray -min (const ComplexNDArray& m, const Complex& s) -{ - return do_ms_binary_op<ComplexNDArray> (m, s, mx_inline_xmin); -} - -ComplexNDArray -min (const ComplexNDArray& a, const ComplexNDArray& b) -{ - return do_mm_binary_op<ComplexNDArray> (a, b, mx_inline_xmin, "min"); -} - -ComplexNDArray -max (const Complex& s, const ComplexNDArray& m) -{ - return do_sm_binary_op<ComplexNDArray> (s, m, mx_inline_xmax); -} - -ComplexNDArray -max (const ComplexNDArray& m, const Complex& s) -{ - return do_ms_binary_op<ComplexNDArray> (m, s, mx_inline_xmax); -} - -ComplexNDArray -max (const ComplexNDArray& a, const ComplexNDArray& b) -{ - return do_mm_binary_op<ComplexNDArray> (a, b, mx_inline_xmax, "max"); -} +MINMAX_FCNS (ComplexNDArray, Complex) NDS_CMP_OPS (ComplexNDArray, Complex) NDS_BOOL_OPS (ComplexNDArray, Complex)
--- a/liboctave/CNDArray.h +++ b/liboctave/CNDArray.h @@ -156,13 +156,7 @@ extern OCTAVE_API ComplexNDArray conj (const ComplexNDArray& a); -extern OCTAVE_API ComplexNDArray min (const Complex& c, const ComplexNDArray& m); -extern OCTAVE_API ComplexNDArray min (const ComplexNDArray& m, const Complex& c); -extern OCTAVE_API ComplexNDArray min (const ComplexNDArray& a, const ComplexNDArray& b); - -extern OCTAVE_API ComplexNDArray max (const Complex& c, const ComplexNDArray& m); -extern OCTAVE_API ComplexNDArray max (const ComplexNDArray& m, const Complex& c); -extern OCTAVE_API ComplexNDArray max (const ComplexNDArray& a, const ComplexNDArray& b); +MINMAX_DECLS (ComplexNDArray, Complex, OCTAVE_API) NDS_CMP_OP_DECLS (ComplexNDArray, Complex, OCTAVE_API) NDS_BOOL_OP_DECLS (ComplexNDArray, Complex, OCTAVE_API)
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,22 @@ +2010-02-17 Jaroslav Hajek <highegg@gmail.com> + + * mx-op-defs.h (MINMAX_FCNS): Generalize. + * mx-op-decl.h (MINMAX_DECLS): Likewise. + + * int16NDArray.h, int32NDArray.h, int64NDArray.h, int8NDArray.h, + uint16NDArray.h, uint32NDArray.h, uint64NDArray.h, uint8NDArray.h: + Update. + * int16NDArray.cc, int32NDArray.cc, int64NDArray.cc, int8NDArray.cc, + uint16NDArray.cc, uint32NDArray.cc, uint64NDArray.cc, uint8NDArray.cc: + Update. + + * CNDArray.h, dNDArray.h, fCNDArray.h, fNDArray.h: Replace explicit + decls. + + * CNDArray.cc, dNDArray.cc, fCNDArray.cc, fNDArray.cc: Replace explicit + definitions. + + 2010-02-11 John W. Eaton <jwe@octave.org> * sparse-mk-ops.awk, mk-ops.awk, filemode.c, lo-cieee.c,
--- a/liboctave/dNDArray.cc +++ b/liboctave/dNDArray.cc @@ -981,41 +981,7 @@ return is; } -NDArray -min (double s, const NDArray& m) -{ - return do_sm_binary_op<NDArray> (s, m, mx_inline_xmin); -} - -NDArray -min (const NDArray& m, double s) -{ - return do_ms_binary_op<NDArray> (m, s, mx_inline_xmin); -} - -NDArray -min (const NDArray& a, const NDArray& b) -{ - return do_mm_binary_op<NDArray> (a, b, mx_inline_xmin, "min"); -} - -NDArray -max (double s, const NDArray& m) -{ - return do_sm_binary_op<NDArray> (s, m, mx_inline_xmax); -} - -NDArray -max (const NDArray& m, double s) -{ - return do_ms_binary_op<NDArray> (m, s, mx_inline_xmax); -} - -NDArray -max (const NDArray& a, const NDArray& b) -{ - return do_mm_binary_op<NDArray> (a, b, mx_inline_xmax, "max"); -} +MINMAX_FCNS (NDArray, double) NDS_CMP_OPS (NDArray, double) NDS_BOOL_OPS (NDArray, double)
--- a/liboctave/dNDArray.h +++ b/liboctave/dNDArray.h @@ -170,13 +170,7 @@ extern OCTAVE_API NDArray real (const ComplexNDArray& a); extern OCTAVE_API NDArray imag (const ComplexNDArray& a); -extern OCTAVE_API NDArray min (double d, const NDArray& m); -extern OCTAVE_API NDArray min (const NDArray& m, double d); -extern OCTAVE_API NDArray min (const NDArray& a, const NDArray& b); - -extern OCTAVE_API NDArray max (double d, const NDArray& m); -extern OCTAVE_API NDArray max (const NDArray& m, double d); -extern OCTAVE_API NDArray max (const NDArray& a, const NDArray& b); +MINMAX_DECLS (NDArray, double, OCTAVE_API) NDS_CMP_OP_DECLS (NDArray, double, OCTAVE_API) NDS_BOOL_OP_DECLS (NDArray, double, OCTAVE_API)
--- a/liboctave/fCNDArray.cc +++ b/liboctave/fCNDArray.cc @@ -909,41 +909,7 @@ return is; } -FloatComplexNDArray -min (const FloatComplex& s, const FloatComplexNDArray& m) -{ - return do_sm_binary_op<FloatComplexNDArray> (s, m, mx_inline_xmin); -} - -FloatComplexNDArray -min (const FloatComplexNDArray& m, const FloatComplex& s) -{ - return do_ms_binary_op<FloatComplexNDArray> (m, s, mx_inline_xmin); -} - -FloatComplexNDArray -min (const FloatComplexNDArray& a, const FloatComplexNDArray& b) -{ - return do_mm_binary_op<FloatComplexNDArray> (a, b, mx_inline_xmin, "min"); -} - -FloatComplexNDArray -max (const FloatComplex& s, const FloatComplexNDArray& m) -{ - return do_sm_binary_op<FloatComplexNDArray> (s, m, mx_inline_xmax); -} - -FloatComplexNDArray -max (const FloatComplexNDArray& m, const FloatComplex& s) -{ - return do_ms_binary_op<FloatComplexNDArray> (m, s, mx_inline_xmax); -} - -FloatComplexNDArray -max (const FloatComplexNDArray& a, const FloatComplexNDArray& b) -{ - return do_mm_binary_op<FloatComplexNDArray> (a, b, mx_inline_xmax, "max"); -} +MINMAX_FCNS (FloatComplexNDArray, FloatComplex) NDS_CMP_OPS (FloatComplexNDArray, FloatComplex) NDS_BOOL_OPS (FloatComplexNDArray, FloatComplex)
--- a/liboctave/fCNDArray.h +++ b/liboctave/fCNDArray.h @@ -156,13 +156,7 @@ extern OCTAVE_API FloatComplexNDArray conj (const FloatComplexNDArray& a); -extern OCTAVE_API FloatComplexNDArray min (const FloatComplex& c, const FloatComplexNDArray& m); -extern OCTAVE_API FloatComplexNDArray min (const FloatComplexNDArray& m, const FloatComplex& c); -extern OCTAVE_API FloatComplexNDArray min (const FloatComplexNDArray& a, const FloatComplexNDArray& b); - -extern OCTAVE_API FloatComplexNDArray max (const FloatComplex& c, const FloatComplexNDArray& m); -extern OCTAVE_API FloatComplexNDArray max (const FloatComplexNDArray& m, const FloatComplex& c); -extern OCTAVE_API FloatComplexNDArray max (const FloatComplexNDArray& a, const FloatComplexNDArray& b); +MINMAX_DECLS (FloatComplexNDArray, FloatComplex, OCTAVE_API) NDS_CMP_OP_DECLS (FloatComplexNDArray, FloatComplex, OCTAVE_API) NDS_BOOL_OP_DECLS (FloatComplexNDArray, FloatComplex, OCTAVE_API)
--- a/liboctave/fNDArray.cc +++ b/liboctave/fNDArray.cc @@ -939,41 +939,7 @@ return is; } -FloatNDArray -min (float s, const FloatNDArray& m) -{ - return do_sm_binary_op<FloatNDArray> (s, m, mx_inline_xmin); -} - -FloatNDArray -min (const FloatNDArray& m, float s) -{ - return do_ms_binary_op<FloatNDArray> (m, s, mx_inline_xmin); -} - -FloatNDArray -min (const FloatNDArray& a, const FloatNDArray& b) -{ - return do_mm_binary_op<FloatNDArray> (a, b, mx_inline_xmin, "min"); -} - -FloatNDArray -max (float s, const FloatNDArray& m) -{ - return do_sm_binary_op<FloatNDArray> (s, m, mx_inline_xmax); -} - -FloatNDArray -max (const FloatNDArray& m, float s) -{ - return do_ms_binary_op<FloatNDArray> (m, s, mx_inline_xmax); -} - -FloatNDArray -max (const FloatNDArray& a, const FloatNDArray& b) -{ - return do_mm_binary_op<FloatNDArray> (a, b, mx_inline_xmax, "max"); -} +MINMAX_FCNS (FloatNDArray, float) NDS_CMP_OPS (FloatNDArray, float) NDS_BOOL_OPS (FloatNDArray, float)
--- a/liboctave/fNDArray.h +++ b/liboctave/fNDArray.h @@ -167,13 +167,7 @@ extern OCTAVE_API FloatNDArray real (const FloatComplexNDArray& a); extern OCTAVE_API FloatNDArray imag (const FloatComplexNDArray& a); -extern OCTAVE_API FloatNDArray min (float d, const FloatNDArray& m); -extern OCTAVE_API FloatNDArray min (const FloatNDArray& m, float d); -extern OCTAVE_API FloatNDArray min (const FloatNDArray& a, const FloatNDArray& b); - -extern OCTAVE_API FloatNDArray max (float d, const FloatNDArray& m); -extern OCTAVE_API FloatNDArray max (const FloatNDArray& m, float d); -extern OCTAVE_API FloatNDArray max (const FloatNDArray& a, const FloatNDArray& b); +MINMAX_DECLS (FloatNDArray, float, OCTAVE_API) NDS_CMP_OP_DECLS (FloatNDArray, float, OCTAVE_API) NDS_BOOL_OP_DECLS (FloatNDArray, float, OCTAVE_API)
--- a/liboctave/int16NDArray.cc +++ b/liboctave/int16NDArray.cc @@ -50,7 +50,7 @@ NDND_CMP_OPS (int16NDArray, int16NDArray) NDND_BOOL_OPS (int16NDArray, int16NDArray) -MINMAX_FCNS (int16) +MINMAX_FCNS (int16NDArray, octave_int16) BSXFUN_STDOP_DEFS_MXLOOP (int16NDArray) BSXFUN_STDREL_DEFS_MXLOOP (int16NDArray)
--- a/liboctave/int16NDArray.h +++ b/liboctave/int16NDArray.h @@ -41,7 +41,7 @@ MARRAY_FORWARD_DEFS (MArrayN, int16NDArray, octave_int16) -MINMAX_DECLS (int16) +MINMAX_DECLS (int16NDArray, octave_int16, OCTAVE_API) BSXFUN_STDOP_DECLS (int16NDArray, OCTAVE_API) BSXFUN_STDREL_DECLS (int16NDArray, OCTAVE_API)
--- a/liboctave/int32NDArray.cc +++ b/liboctave/int32NDArray.cc @@ -50,7 +50,7 @@ NDND_CMP_OPS (int32NDArray, int32NDArray) NDND_BOOL_OPS (int32NDArray, int32NDArray) -MINMAX_FCNS (int32) +MINMAX_FCNS (int32NDArray, octave_int32) BSXFUN_STDOP_DEFS_MXLOOP (int32NDArray) BSXFUN_STDREL_DEFS_MXLOOP (int32NDArray)
--- a/liboctave/int32NDArray.h +++ b/liboctave/int32NDArray.h @@ -41,7 +41,7 @@ MARRAY_FORWARD_DEFS (MArrayN, int32NDArray, octave_int32) -MINMAX_DECLS (int32) +MINMAX_DECLS (int32NDArray, octave_int32, OCTAVE_API) BSXFUN_STDOP_DECLS (int32NDArray, OCTAVE_API) BSXFUN_STDREL_DECLS (int32NDArray, OCTAVE_API)
--- a/liboctave/int64NDArray.cc +++ b/liboctave/int64NDArray.cc @@ -50,7 +50,7 @@ NDND_CMP_OPS (int64NDArray, int64NDArray) NDND_BOOL_OPS (int64NDArray, int64NDArray) -MINMAX_FCNS (int64) +MINMAX_FCNS (int64NDArray, octave_int64) BSXFUN_STDOP_DEFS_MXLOOP (int64NDArray) BSXFUN_STDREL_DEFS_MXLOOP (int64NDArray)
--- a/liboctave/int64NDArray.h +++ b/liboctave/int64NDArray.h @@ -41,7 +41,7 @@ MARRAY_FORWARD_DEFS (MArrayN, int64NDArray, octave_int64) -MINMAX_DECLS (int64) +MINMAX_DECLS (int64NDArray, octave_int64, OCTAVE_API) BSXFUN_STDOP_DECLS (int64NDArray, OCTAVE_API) BSXFUN_STDREL_DECLS (int64NDArray, OCTAVE_API)
--- a/liboctave/int8NDArray.cc +++ b/liboctave/int8NDArray.cc @@ -50,7 +50,7 @@ NDND_CMP_OPS (int8NDArray, int8NDArray) NDND_BOOL_OPS (int8NDArray, int8NDArray) -MINMAX_FCNS (int8) +MINMAX_FCNS (int8NDArray, octave_int8) BSXFUN_STDOP_DEFS_MXLOOP (int8NDArray) BSXFUN_STDREL_DEFS_MXLOOP (int8NDArray)
--- a/liboctave/int8NDArray.h +++ b/liboctave/int8NDArray.h @@ -41,7 +41,7 @@ MARRAY_FORWARD_DEFS (MArrayN, int8NDArray, octave_int8) -MINMAX_DECLS (int8) +MINMAX_DECLS (int8NDArray, octave_int8, OCTAVE_API) BSXFUN_STDOP_DECLS (int8NDArray, OCTAVE_API) BSXFUN_STDREL_DECLS (int8NDArray, OCTAVE_API)
--- a/liboctave/mx-op-decl.h +++ b/liboctave/mx-op-decl.h @@ -283,15 +283,13 @@ // 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); +#define MINMAX_DECLS(T, S, API) \ + extern API T min (S d, const T& m); \ + extern API T min (const T& m, S d); \ + extern API T min (const T& a, const T& b); \ + extern API T max (S d, const T& m); \ + extern API T max (const T& m, S d); \ + extern API T max (const T& a, const T& b); // permutation matrix by matrix ops and vice versa
--- a/liboctave/mx-op-defs.h +++ b/liboctave/mx-op-defs.h @@ -546,34 +546,34 @@ // scalar by N-d array min/max ops -#define SND_MINMAX_FCN(FCN, OP, T) \ -T ## NDArray \ -FCN (octave_ ## T d, const T ## NDArray& m) \ +#define SND_MINMAX_FCN(FCN, OP, T, S) \ +T \ +FCN (S d, const T& m) \ { \ - return do_sm_binary_op<T##NDArray, octave_##T, T##NDArray> (d, m, mx_inline_x##FCN); \ + return do_sm_binary_op<T, S, T> (d, m, mx_inline_x##FCN); \ } -#define NDS_MINMAX_FCN(FCN, OP, T) \ -T ## NDArray \ -FCN (const T ## NDArray& m, octave_ ## T d) \ +#define NDS_MINMAX_FCN(FCN, OP, T, S) \ +T \ +FCN (const T& m, S d) \ { \ - return do_ms_binary_op<T##NDArray, T##NDArray, octave_##T> (m, d, mx_inline_x##FCN); \ + return do_ms_binary_op<T, T, S> (m, d, mx_inline_x##FCN); \ } -#define NDND_MINMAX_FCN(FCN, OP, T) \ -T ## NDArray \ -FCN (const T ## NDArray& a, const T ## NDArray& b) \ +#define NDND_MINMAX_FCN(FCN, OP, T, S) \ +T \ +FCN (const T& a, const T& b) \ { \ - return do_mm_binary_op<T##NDArray, T##NDArray, T##NDArray> (a, b, mx_inline_x##FCN, #FCN); \ + return do_mm_binary_op<T, T, T> (a, b, mx_inline_x##FCN, #FCN); \ } -#define MINMAX_FCNS(T) \ - SND_MINMAX_FCN (min, <, T) \ - NDS_MINMAX_FCN (min, <, T) \ - NDND_MINMAX_FCN (min, <, T) \ - SND_MINMAX_FCN (max, >, T) \ - NDS_MINMAX_FCN (max, >, T) \ - NDND_MINMAX_FCN (max, >, T) +#define MINMAX_FCNS(T, S) \ + SND_MINMAX_FCN (min, <, T, S) \ + NDS_MINMAX_FCN (min, <, T, S) \ + NDND_MINMAX_FCN (min, <, T, S) \ + SND_MINMAX_FCN (max, >, T, S) \ + NDS_MINMAX_FCN (max, >, T, S) \ + NDND_MINMAX_FCN (max, >, T, S) // permutation matrix by matrix ops and vice versa
--- a/liboctave/uint16NDArray.cc +++ b/liboctave/uint16NDArray.cc @@ -50,7 +50,7 @@ NDND_CMP_OPS (uint16NDArray, uint16NDArray) NDND_BOOL_OPS (uint16NDArray, uint16NDArray) -MINMAX_FCNS (uint16) +MINMAX_FCNS (uint16NDArray, octave_uint16) BSXFUN_STDOP_DEFS_MXLOOP (uint16NDArray) BSXFUN_STDREL_DEFS_MXLOOP (uint16NDArray)
--- a/liboctave/uint16NDArray.h +++ b/liboctave/uint16NDArray.h @@ -41,7 +41,7 @@ MARRAY_FORWARD_DEFS (MArrayN, uint16NDArray, octave_uint16) -MINMAX_DECLS (uint16) +MINMAX_DECLS (uint16NDArray, octave_uint16, OCTAVE_API) BSXFUN_STDOP_DECLS (uint16NDArray, OCTAVE_API) BSXFUN_STDREL_DECLS (uint16NDArray, OCTAVE_API)
--- a/liboctave/uint32NDArray.cc +++ b/liboctave/uint32NDArray.cc @@ -50,7 +50,7 @@ NDND_CMP_OPS (uint32NDArray, uint32NDArray) NDND_BOOL_OPS (uint32NDArray, uint32NDArray) -MINMAX_FCNS (uint32) +MINMAX_FCNS (uint32NDArray, octave_uint32) BSXFUN_STDOP_DEFS_MXLOOP (uint32NDArray) BSXFUN_STDREL_DEFS_MXLOOP (uint32NDArray)
--- a/liboctave/uint32NDArray.h +++ b/liboctave/uint32NDArray.h @@ -41,7 +41,7 @@ MARRAY_FORWARD_DEFS (MArrayN, uint32NDArray, octave_uint32) -MINMAX_DECLS (uint32) +MINMAX_DECLS (uint32NDArray, octave_uint32, OCTAVE_API) BSXFUN_STDOP_DECLS (uint32NDArray, OCTAVE_API) BSXFUN_STDREL_DECLS (uint32NDArray, OCTAVE_API)
--- a/liboctave/uint64NDArray.cc +++ b/liboctave/uint64NDArray.cc @@ -50,7 +50,7 @@ NDND_CMP_OPS (uint64NDArray, uint64NDArray) NDND_BOOL_OPS (uint64NDArray, uint64NDArray) -MINMAX_FCNS (uint64) +MINMAX_FCNS (uint64NDArray, octave_uint64) BSXFUN_STDOP_DEFS_MXLOOP (uint64NDArray) BSXFUN_STDREL_DEFS_MXLOOP (uint64NDArray)
--- a/liboctave/uint64NDArray.h +++ b/liboctave/uint64NDArray.h @@ -41,7 +41,7 @@ MARRAY_FORWARD_DEFS (MArrayN, uint64NDArray, octave_uint64) -MINMAX_DECLS (uint64) +MINMAX_DECLS (uint64NDArray, octave_uint64, OCTAVE_API) BSXFUN_STDOP_DECLS (uint64NDArray, OCTAVE_API) BSXFUN_STDREL_DECLS (uint64NDArray, OCTAVE_API)
--- a/liboctave/uint8NDArray.cc +++ b/liboctave/uint8NDArray.cc @@ -50,7 +50,7 @@ NDND_CMP_OPS (uint8NDArray, uint8NDArray) NDND_BOOL_OPS (uint8NDArray, uint8NDArray) -MINMAX_FCNS (uint8) +MINMAX_FCNS (uint8NDArray, octave_uint8) BSXFUN_STDOP_DEFS_MXLOOP (uint8NDArray) BSXFUN_STDREL_DEFS_MXLOOP (uint8NDArray)
--- a/liboctave/uint8NDArray.h +++ b/liboctave/uint8NDArray.h @@ -41,7 +41,7 @@ MARRAY_FORWARD_DEFS (MArrayN, uint8NDArray, octave_uint8) -MINMAX_DECLS (uint8) +MINMAX_DECLS (uint8NDArray, octave_uint8, OCTAVE_API) BSXFUN_STDOP_DECLS (uint8NDArray, OCTAVE_API) BSXFUN_STDREL_DECLS (uint8NDArray, OCTAVE_API)