annotate liboctave/operators/mx-inlines.cc @ 18084:8e056300994b

Follow coding convention of defining and initializing only 1 variable per line in liboctave. * liboctave/array/Array-b.cc, liboctave/array/Array-util.cc, liboctave/array/Array.cc, liboctave/array/CDiagMatrix.cc, liboctave/array/CMatrix.cc, liboctave/array/CSparse.cc, liboctave/array/MDiagArray2.cc, liboctave/array/MatrixType.cc, liboctave/array/PermMatrix.cc, liboctave/array/Sparse.cc, liboctave/array/Sparse.h, liboctave/array/boolSparse.cc, liboctave/array/dDiagMatrix.cc, liboctave/array/dMatrix.cc, liboctave/array/dSparse.cc, liboctave/array/dim-vector.cc, liboctave/array/fCDiagMatrix.cc, liboctave/array/fCMatrix.cc, liboctave/array/fDiagMatrix.cc, liboctave/array/fMatrix.cc, liboctave/array/idx-vector.cc, liboctave/array/idx-vector.h, liboctave/numeric/CmplxLU.cc, liboctave/numeric/CmplxQR.cc, liboctave/numeric/base-qr.cc, liboctave/numeric/bsxfun-defs.cc, liboctave/numeric/bsxfun.h, liboctave/numeric/dbleLU.cc, liboctave/numeric/dbleQR.cc, liboctave/numeric/fCmplxLU.cc, liboctave/numeric/fCmplxQR.cc, liboctave/numeric/floatLU.cc, liboctave/numeric/floatQR.cc, liboctave/numeric/lo-specfun.cc, liboctave/numeric/oct-convn.cc, liboctave/numeric/oct-norm.cc, liboctave/numeric/sparse-dmsolve.cc, liboctave/operators/mx-inlines.cc, liboctave/operators/mx-op-defs.h, liboctave/util/caseless-str.h, liboctave/util/kpse.cc, liboctave/util/lo-utils.cc, liboctave/util/oct-binmap.h, liboctave/util/oct-cmplx.h, liboctave/util/oct-inttypes.cc, liboctave/util/oct-inttypes.h, liboctave/util/oct-sort.cc: Follow coding convention of defining and initializing only 1 variable per line in liboctave.
author Rik <rik@octave.org>
date Wed, 04 Dec 2013 22:13:18 -0800
parents 49a5a4be04a1
children 6c706a83070f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
1 /*
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
2
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 15285
diff changeset
3 Copyright (C) 1993-2013 John W. Eaton
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
4 Copyright (C) 2009 Jaroslav Hajek
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
5 Copyright (C) 2009 VZLU Prague
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
6
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
7 This file is part of Octave.
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
8
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
9 Octave is free software; you can redistribute it and/or modify it
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5972
diff changeset
11 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5972
diff changeset
12 option) any later version.
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
13
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
14 Octave is distributed in the hope that it will be useful, but WITHOUT
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
17 for more details.
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
18
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5972
diff changeset
20 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5972
diff changeset
21 <http://www.gnu.org/licenses/>.
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
22
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
23 */
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
24
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents: 2811
diff changeset
25 #if !defined (octave_mx_inlines_h)
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents: 2811
diff changeset
26 #define octave_mx_inlines_h 1
2804
eedc2f3f61f7 [project @ 1997-03-11 04:34:50 by jwe]
jwe
parents: 2386
diff changeset
27
eedc2f3f61f7 [project @ 1997-03-11 04:34:50 by jwe]
jwe
parents: 2386
diff changeset
28 #include <cstddef>
8650
a1ae2aae903e abs,real,imag,conj: use code from mx-inlines rather than the generic map
Jaroslav Hajek <highegg@gmail.com>
parents: 8380
diff changeset
29 #include <cmath>
10146
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
30 #include <memory>
2804
eedc2f3f61f7 [project @ 1997-03-11 04:34:50 by jwe]
jwe
parents: 2386
diff changeset
31
5525
558c69736dc0 [project @ 2005-11-01 00:49:50 by jwe]
jwe
parents: 5524
diff changeset
32 #include "quit.h"
558c69736dc0 [project @ 2005-11-01 00:49:50 by jwe]
jwe
parents: 5524
diff changeset
33
1650
23aa282707e8 [project @ 1995-12-20 06:53:12 by jwe]
jwe
parents: 1574
diff changeset
34 #include "oct-cmplx.h"
8758
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
35 #include "oct-locbuf.h"
8897
fd83cc87f55e add missing include
Jaroslav Hajek <highegg@gmail.com>
parents: 8780
diff changeset
36 #include "oct-inttypes.h"
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
37 #include "Array.h"
10146
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
38 #include "Array-util.h"
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
39
13004
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
40 #include "bsxfun.h"
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
41
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
42 // Provides some commonly repeated, basic loop templates.
461
00f8b2242a18 [project @ 1994-06-06 00:45:57 by jwe]
jwe
parents: 238
diff changeset
43
8380
dbe67764e628 fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
44 template <class R, class S>
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
45 inline void mx_inline_fill (size_t n, R *r, S s) throw ()
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
46 { for (size_t i = 0; i < n; i++) r[i] = s; }
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
47
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
48 #define DEFMXUNOP(F, OP) \
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
49 template <class R, class X> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
50 inline void F (size_t n, R *r, const X *x) throw () \
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
51 { for (size_t i = 0; i < n; i++) r[i] = OP x[i]; }
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
52
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
53 DEFMXUNOP (mx_inline_uminus, -)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
54
9607
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9578
diff changeset
55 #define DEFMXUNOPEQ(F, OP) \
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9578
diff changeset
56 template <class R> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
57 inline void F (size_t n, R *r) throw () \
9607
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9578
diff changeset
58 { for (size_t i = 0; i < n; i++) r[i] = OP r[i]; }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9578
diff changeset
59
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9578
diff changeset
60 DEFMXUNOPEQ (mx_inline_uminus2, -)
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9578
diff changeset
61
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
62 #define DEFMXUNBOOLOP(F, OP) \
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
63 template <class X> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
64 inline void F (size_t n, bool *r, const X *x) throw () \
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
65 { const X zero = X (); for (size_t i = 0; i < n; i++) r[i] = x[i] OP zero; }
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
66
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
67 DEFMXUNBOOLOP (mx_inline_iszero, ==)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
68 DEFMXUNBOOLOP (mx_inline_notzero, !=)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
69
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
70 #define DEFMXBINOP(F, OP) \
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
71 template <class R, class X, class Y> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
72 inline void F (size_t n, R *r, const X *x, const Y *y) throw () \
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
73 { for (size_t i = 0; i < n; i++) r[i] = x[i] OP y[i]; } \
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
74 template <class R, class X, class Y> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
75 inline void F (size_t n, R *r, const X *x, Y y) throw () \
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
76 { for (size_t i = 0; i < n; i++) r[i] = x[i] OP y; } \
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
77 template <class R, class X, class Y> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
78 inline void F (size_t n, R *r, X x, const Y *y) throw () \
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
79 { for (size_t i = 0; i < n; i++) r[i] = x OP y[i]; }
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
80
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
81 DEFMXBINOP (mx_inline_add, +)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
82 DEFMXBINOP (mx_inline_sub, -)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
83 DEFMXBINOP (mx_inline_mul, *)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
84 DEFMXBINOP (mx_inline_div, /)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
85
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
86 #define DEFMXBINOPEQ(F, OP) \
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
87 template <class R, class X> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
88 inline void F (size_t n, R *r, const X *x) throw () \
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
89 { for (size_t i = 0; i < n; i++) r[i] OP x[i]; } \
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
90 template <class R, class X> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
91 inline void F (size_t n, R *r, X x) throw () \
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
92 { for (size_t i = 0; i < n; i++) r[i] OP x; }
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
93
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
94 DEFMXBINOPEQ (mx_inline_add2, +=)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
95 DEFMXBINOPEQ (mx_inline_sub2, -=)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
96 DEFMXBINOPEQ (mx_inline_mul2, *=)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
97 DEFMXBINOPEQ (mx_inline_div2, /=)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
98
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
99 #define DEFMXCMPOP(F, OP) \
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
100 template <class X, class Y> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
101 inline void F (size_t n, bool *r, const X *x, const Y *y) throw () \
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
102 { for (size_t i = 0; i < n; i++) r[i] = x[i] OP y[i]; } \
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
103 template <class X, class Y> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
104 inline void F (size_t n, bool *r, const X *x, Y y) throw () \
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
105 { for (size_t i = 0; i < n; i++) r[i] = x[i] OP y; } \
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
106 template <class X, class Y> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
107 inline void F (size_t n, bool *r, X x, const Y *y) throw () \
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
108 { for (size_t i = 0; i < n; i++) r[i] = x OP y[i]; }
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
109
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
110 DEFMXCMPOP (mx_inline_lt, <)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
111 DEFMXCMPOP (mx_inline_le, <=)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
112 DEFMXCMPOP (mx_inline_gt, >)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
113 DEFMXCMPOP (mx_inline_ge, >=)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
114 DEFMXCMPOP (mx_inline_eq, ==)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
115 DEFMXCMPOP (mx_inline_ne, !=)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
116
9553
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
117 // Convert to logical value, for logical op purposes.
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
118 template <class T> inline bool logical_value (T x) { return x; }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
119 template <class T> inline bool logical_value (const std::complex<T>& x)
10482
2645a6b1027b fix typo in last patch
Jaroslav Hajek <highegg@gmail.com>
parents: 10481
diff changeset
120 { return x.real () != 0 || x.imag () != 0; }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
121 template <class T> inline bool logical_value (const octave_int<T>& x)
9553
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
122 { return x.value (); }
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
123
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
124 template <class X>
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
125 void mx_inline_not (size_t n, bool *r, const X* x) throw ()
9553
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
126 {
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
127 for (size_t i = 0; i < n; i++)
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
128 r[i] = ! logical_value (x[i]);
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
129 }
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
130
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
131 inline void mx_inline_not2 (size_t n, bool *r) throw ()
9607
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9578
diff changeset
132 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9578
diff changeset
133 for (size_t i = 0; i < n; i++) r[i] = ! r[i];
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9578
diff changeset
134 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9578
diff changeset
135
9553
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
136 #define DEFMXBOOLOP(F, NOT1, OP, NOT2) \
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
137 template <class X, class Y> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
138 inline void F (size_t n, bool *r, const X *x, const Y *y) throw () \
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
139 { \
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
140 for (size_t i = 0; i < n; i++) \
9553
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
141 r[i] = (NOT1 logical_value (x[i])) OP (NOT2 logical_value (y[i])); \
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
142 } \
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
143 template <class X, class Y> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
144 inline void F (size_t n, bool *r, const X *x, Y y) throw () \
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
145 { \
9553
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
146 const bool yy = (NOT2 logical_value (y)); \
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
147 for (size_t i = 0; i < n; i++) \
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
148 r[i] = (NOT1 logical_value (x[i])) OP yy; \
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
149 } \
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
150 template <class X, class Y> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
151 inline void F (size_t n, bool *r, X x, const Y *y) throw () \
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
152 { \
9553
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
153 const bool xx = (NOT1 logical_value (x)); \
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
154 for (size_t i = 0; i < n; i++) \
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
155 r[i] = xx OP (NOT2 logical_value (y[i])); \
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
156 }
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
157
9553
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
158 DEFMXBOOLOP (mx_inline_and, , &, )
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
159 DEFMXBOOLOP (mx_inline_or, , |, )
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
160 DEFMXBOOLOP (mx_inline_not_and, !, &, )
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
161 DEFMXBOOLOP (mx_inline_not_or, !, |, )
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
162 DEFMXBOOLOP (mx_inline_and_not, , &, !)
0c72d9284087 further bool ops tweaks
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
163 DEFMXBOOLOP (mx_inline_or_not, , |, !)
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
164
9612
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
165 #define DEFMXBOOLOPEQ(F, OP) \
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
166 template <class X> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
167 inline void F (size_t n, bool *r, const X *x) throw () \
9612
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
168 { \
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
169 for (size_t i = 0; i < n; i++) \
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
170 r[i] OP logical_value (x[i]); \
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
171 } \
13139
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13005
diff changeset
172 template <class X> \
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13005
diff changeset
173 inline void F (size_t n, bool *r, X x) throw () \
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13005
diff changeset
174 { for (size_t i = 0; i < n; i++) r[i] OP x; }
9612
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
175
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
176 DEFMXBOOLOPEQ (mx_inline_and2, &=)
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
177 DEFMXBOOLOPEQ (mx_inline_or2, |=)
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
178
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
179 template <class T>
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
180 inline bool
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
181 mx_inline_any_nan (size_t n, const T* x) throw ()
9814
2b29f3472e20 add a couple of useful loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9800
diff changeset
182 {
2b29f3472e20 add a couple of useful loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9800
diff changeset
183 for (size_t i = 0; i < n; i++)
2b29f3472e20 add a couple of useful loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9800
diff changeset
184 {
2b29f3472e20 add a couple of useful loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9800
diff changeset
185 if (xisnan (x[i]))
2b29f3472e20 add a couple of useful loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9800
diff changeset
186 return true;
2b29f3472e20 add a couple of useful loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9800
diff changeset
187 }
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
188
9814
2b29f3472e20 add a couple of useful loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9800
diff changeset
189 return false;
8380
dbe67764e628 fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
190 }
dbe67764e628 fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
191
10900
b64803a8be4e optimize element-wise sparse-dense multiplication and division
Jaroslav Hajek <highegg@gmail.com>
parents: 10643
diff changeset
192 template <class T>
b64803a8be4e optimize element-wise sparse-dense multiplication and division
Jaroslav Hajek <highegg@gmail.com>
parents: 10643
diff changeset
193 inline bool
b64803a8be4e optimize element-wise sparse-dense multiplication and division
Jaroslav Hajek <highegg@gmail.com>
parents: 10643
diff changeset
194 mx_inline_all_finite (size_t n, const T* x) throw ()
b64803a8be4e optimize element-wise sparse-dense multiplication and division
Jaroslav Hajek <highegg@gmail.com>
parents: 10643
diff changeset
195 {
b64803a8be4e optimize element-wise sparse-dense multiplication and division
Jaroslav Hajek <highegg@gmail.com>
parents: 10643
diff changeset
196 for (size_t i = 0; i < n; i++)
b64803a8be4e optimize element-wise sparse-dense multiplication and division
Jaroslav Hajek <highegg@gmail.com>
parents: 10643
diff changeset
197 {
b64803a8be4e optimize element-wise sparse-dense multiplication and division
Jaroslav Hajek <highegg@gmail.com>
parents: 10643
diff changeset
198 if (! xfinite (x[i]))
b64803a8be4e optimize element-wise sparse-dense multiplication and division
Jaroslav Hajek <highegg@gmail.com>
parents: 10643
diff changeset
199 return false;
b64803a8be4e optimize element-wise sparse-dense multiplication and division
Jaroslav Hajek <highegg@gmail.com>
parents: 10643
diff changeset
200 }
b64803a8be4e optimize element-wise sparse-dense multiplication and division
Jaroslav Hajek <highegg@gmail.com>
parents: 10643
diff changeset
201
b64803a8be4e optimize element-wise sparse-dense multiplication and division
Jaroslav Hajek <highegg@gmail.com>
parents: 10643
diff changeset
202 return true;
b64803a8be4e optimize element-wise sparse-dense multiplication and division
Jaroslav Hajek <highegg@gmail.com>
parents: 10643
diff changeset
203 }
b64803a8be4e optimize element-wise sparse-dense multiplication and division
Jaroslav Hajek <highegg@gmail.com>
parents: 10643
diff changeset
204
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
205 template <class T>
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
206 inline bool
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
207 mx_inline_any_negative (size_t n, const T* x) throw ()
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
208 {
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
209 for (size_t i = 0; i < n; i++)
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
210 {
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
211 if (x[i] < 0)
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
212 return true;
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
213 }
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
214
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
215 return false;
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
216 }
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
217
13756
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
218 template <class T>
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
219 inline bool
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
220 mx_inline_any_positive (size_t n, const T* x) throw ()
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
221 {
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
222 for (size_t i = 0; i < n; i++)
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
223 {
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
224 if (x[i] > 0)
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
225 return true;
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
226 }
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
227
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
228 return false;
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
229 }
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13139
diff changeset
230
9814
2b29f3472e20 add a couple of useful loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9800
diff changeset
231 template<class T>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
232 inline bool
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
233 mx_inline_all_real (size_t n, const std::complex<T>* x) throw ()
9814
2b29f3472e20 add a couple of useful loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9800
diff changeset
234 {
2b29f3472e20 add a couple of useful loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9800
diff changeset
235 for (size_t i = 0; i < n; i++)
2b29f3472e20 add a couple of useful loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9800
diff changeset
236 {
2b29f3472e20 add a couple of useful loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9800
diff changeset
237 if (x[i].imag () != 0)
2b29f3472e20 add a couple of useful loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9800
diff changeset
238 return false;
2b29f3472e20 add a couple of useful loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9800
diff changeset
239 }
2b29f3472e20 add a couple of useful loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9800
diff changeset
240
2b29f3472e20 add a couple of useful loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9800
diff changeset
241 return true;
2b29f3472e20 add a couple of useful loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9800
diff changeset
242 }
2811
1dd37f97364a [project @ 1997-03-12 23:06:13 by jwe]
jwe
parents: 2804
diff changeset
243
9800
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
244 #define DEFMXMAPPER(F, FUN) \
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
245 template <class T> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
246 inline void F (size_t n, T *r, const T *x) throw () \
9800
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
247 { for (size_t i = 0; i < n; i++) r[i] = FUN (x[i]); }
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
248
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
249 template<class T>
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
250 inline void mx_inline_real (size_t n, T *r, const std::complex<T>* x) throw ()
9800
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
251 { for (size_t i = 0; i < n; i++) r[i] = x[i].real (); }
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
252 template<class T>
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
253 inline void mx_inline_imag (size_t n, T *r, const std::complex<T>* x) throw ()
9800
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
254 { for (size_t i = 0; i < n; i++) r[i] = x[i].imag (); }
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
255
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9721
diff changeset
256 // Pairwise minimums/maximums
9800
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
257 #define DEFMXMAPPER2(F, FUN) \
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9721
diff changeset
258 template <class T> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
259 inline void F (size_t n, T *r, const T *x, const T *y) throw () \
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9721
diff changeset
260 { for (size_t i = 0; i < n; i++) r[i] = FUN (x[i], y[i]); } \
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9721
diff changeset
261 template <class T> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
262 inline void F (size_t n, T *r, const T *x, T y) throw () \
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9721
diff changeset
263 { for (size_t i = 0; i < n; i++) r[i] = FUN (x[i], y); } \
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9721
diff changeset
264 template <class T> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
265 inline void F (size_t n, T *r, T x, const T *y) throw () \
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9721
diff changeset
266 { for (size_t i = 0; i < n; i++) r[i] = FUN (x, y[i]); }
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
267
9800
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
268 DEFMXMAPPER2 (mx_inline_xmin, xmin)
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
269 DEFMXMAPPER2 (mx_inline_xmax, xmax)
2811
1dd37f97364a [project @ 1997-03-12 23:06:13 by jwe]
jwe
parents: 2804
diff changeset
270
10146
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
271 // Specialize array-scalar max/min
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
272 #define DEFMINMAXSPEC(T, F, OP) \
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
273 template <> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
274 inline void F<T> (size_t n, T *r, const T *x, T y) throw () \
10146
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
275 { \
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
276 if (xisnan (y)) \
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
277 std::memcpy (r, x, n * sizeof (T)); \
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
278 else \
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
279 for (size_t i = 0; i < n; i++) r[i] = (x[i] OP y) ? x[i] : y; \
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
280 } \
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
281 template <> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
282 inline void F<T> (size_t n, T *r, T x, const T *y) throw () \
10146
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
283 { \
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
284 if (xisnan (x)) \
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
285 std::memcpy (r, y, n * sizeof (T)); \
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
286 else \
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
287 for (size_t i = 0; i < n; i++) r[i] = (y[i] OP x) ? y[i] : x; \
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
288 }
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
289
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
290 DEFMINMAXSPEC (double, mx_inline_xmin, <=)
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
291 DEFMINMAXSPEC (double, mx_inline_xmax, >=)
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
292 DEFMINMAXSPEC (float, mx_inline_xmin, <=)
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
293 DEFMINMAXSPEC (float, mx_inline_xmax, >=)
10146
9597eea7fa36 inline xmin/xmax & optimize special cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
294
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
295 // Pairwise power
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
296 #define DEFMXMAPPER2X(F, FUN) \
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
297 template <class R, class X, class Y> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
298 inline void F (size_t n, R *r, const X *x, const Y *y) throw () \
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
299 { for (size_t i = 0; i < n; i++) r[i] = FUN (x[i], y[i]); } \
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
300 template <class R, class X, class Y> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
301 inline void F (size_t n, R *r, const X *x, Y y) throw () \
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
302 { for (size_t i = 0; i < n; i++) r[i] = FUN (x[i], y); } \
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
303 template <class R, class X, class Y> \
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
304 inline void F (size_t n, R *r, X x, const Y *y) throw () \
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
305 { for (size_t i = 0; i < n; i++) r[i] = FUN (x, y[i]); }
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
306
13005
4061106b1c4b Enable automatic bsxfun for power operators
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 13004
diff changeset
307 // Let the compiler decide which pow to use, whichever best matches the
4061106b1c4b Enable automatic bsxfun for power operators
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 13004
diff changeset
308 // arguments provided.
4061106b1c4b Enable automatic bsxfun for power operators
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 13004
diff changeset
309 using std::pow;
4061106b1c4b Enable automatic bsxfun for power operators
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 13004
diff changeset
310 DEFMXMAPPER2X (mx_inline_pow, pow)
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9814
diff changeset
311
9800
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
312 // Arbitrary function appliers. The function is a template parameter to enable
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
313 // inlining.
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
314 template <class R, class X, R fun (X x)>
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
315 inline void mx_inline_map (size_t n, R *r, const X *x) throw ()
9800
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
316 { for (size_t i = 0; i < n; i++) r[i] = fun (x[i]); }
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
317
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
318 template <class R, class X, R fun (const X& x)>
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
319 inline void mx_inline_map (size_t n, R *r, const X *x) throw ()
9800
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
320 { for (size_t i = 0; i < n; i++) r[i] = fun (x[i]); }
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
321
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
322 // Appliers. Since these call the operation just once, we pass it as
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
323 // a pointer, to allow the compiler reduce number of instances.
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
324
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
325 template <class R, class X>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
326 inline Array<R>
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
327 do_mx_unary_op (const Array<X>& x,
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
328 void (*op) (size_t, R *, const X *) throw ())
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
329 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
330 Array<R> r (x.dims ());
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
331 op (r.numel (), r.fortran_vec (), x.data ());
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
332 return r;
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
333 }
2811
1dd37f97364a [project @ 1997-03-12 23:06:13 by jwe]
jwe
parents: 2804
diff changeset
334
9800
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
335 // Shortcuts for applying mx_inline_map.
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
336
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
337 template <class R, class X, R fun (X)>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
338 inline Array<R>
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
339 do_mx_unary_map (const Array<X>& x)
9800
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
340 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
341 return do_mx_unary_op<R, X> (x, mx_inline_map<R, X, fun>);
9800
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
342 }
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
343
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
344 template <class R, class X, R fun (const X&)>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
345 inline Array<R>
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
346 do_mx_unary_map (const Array<X>& x)
9800
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
347 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
348 return do_mx_unary_op<R, X> (x, mx_inline_map<R, X, fun>);
9800
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
349 }
ef4c4186cb47 improve some mx_inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 9766
diff changeset
350
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
351 template <class R>
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
352 inline Array<R>&
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
353 do_mx_inplace_op (Array<R>& r,
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
354 void (*op) (size_t, R *) throw ())
9607
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9578
diff changeset
355 {
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9578
diff changeset
356 op (r.numel (), r.fortran_vec ());
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9578
diff changeset
357 return r;
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9578
diff changeset
358 }
1be3c73ed7b5 reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents: 9578
diff changeset
359
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
360 template <class R, class X, class Y>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
361 inline Array<R>
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
362 do_mm_binary_op (const Array<X>& x, const Array<Y>& y,
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
363 void (*op) (size_t, R *, const X *, const Y *) throw (),
13004
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
364 void (*op1) (size_t, R *, X, const Y *) throw (),
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
365 void (*op2) (size_t, R *, const X *, Y) throw (),
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
366 const char *opname)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
367 {
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
368 dim_vector dx = x.dims ();
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
369 dim_vector dy = y.dims ();
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
370 if (dx == dy)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
371 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
372 Array<R> r (dx);
9612
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
373 op (r.length (), r.fortran_vec (), x.data (), y.data ());
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
374 return r;
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
375 }
14056
c3d401562410 allow warning (or error) for automatic bsxfun
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
376 else if (is_valid_bsxfun (opname, dx, dy))
13004
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
377 {
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
378 return do_bsxfun_op (x, y, op, op1, op2);
d9d65c3017c3 Make bsxfun automatic for most binary operators.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
379 }
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
380 else
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
381 {
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
382 gripe_nonconformant (opname, dx, dy);
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
383 return Array<R> ();
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
384 }
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
385 }
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
386
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
387 template <class R, class X, class Y>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
388 inline Array<R>
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
389 do_ms_binary_op (const Array<X>& x, const Y& y,
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
390 void (*op) (size_t, R *, const X *, Y) throw ())
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
391 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
392 Array<R> r (x.dims ());
9612
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
393 op (r.length (), r.fortran_vec (), x.data (), y);
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
394 return r;
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
395 }
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
396
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
397 template <class R, class X, class Y>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
398 inline Array<R>
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
399 do_sm_binary_op (const X& x, const Array<Y>& y,
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
400 void (*op) (size_t, R *, X, const Y *) throw ())
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
401 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
402 Array<R> r (y.dims ());
9612
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
403 op (r.length (), r.fortran_vec (), x, y.data ());
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
404 return r;
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
405 }
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
406
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
407 template <class R, class X>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
408 inline Array<R>&
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
409 do_mm_inplace_op (Array<R>& r, const Array<X>& x,
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
410 void (*op) (size_t, R *, const X *) throw (),
13139
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13005
diff changeset
411 void (*op1) (size_t, R *, X) throw (),
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
412 const char *opname)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
413 {
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
414 dim_vector dr = r.dims ();
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
415 dim_vector dx = x.dims ();
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
416 if (dr == dx)
13139
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13005
diff changeset
417 {
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13005
diff changeset
418 op (r.length (), r.fortran_vec (), x.data ());
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13005
diff changeset
419 }
14056
c3d401562410 allow warning (or error) for automatic bsxfun
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
420 else if (is_valid_inplace_bsxfun (opname, dr, dx))
13139
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13005
diff changeset
421 {
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13005
diff changeset
422 do_inplace_bsxfun_op (r, x, op, op1);
aa4a23337a0f Enable BSX in-place for missing assignment operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 13005
diff changeset
423 }
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
424 else
9612
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
425 gripe_nonconformant (opname, dr, dx);
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
426 return r;
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
427 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
428
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
429 template <class R, class X>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
430 inline Array<R>&
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
431 do_ms_inplace_op (Array<R>& r, const X& x,
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
432 void (*op) (size_t, R *, X) throw ())
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
433 {
9612
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9607
diff changeset
434 op (r.length (), r.fortran_vec (), x);
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
435 return r;
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
436 }
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
437
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
438 template <class T1, class T2>
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
439 inline bool
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
440 mx_inline_equal (size_t n, const T1 *x, const T2 *y) throw ()
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
441 {
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
442 for (size_t i = 0; i < n; i++)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
443 if (x[i] != y[i])
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
444 return false;
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
445 return true;
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
446 }
3
9a4c07481e61 [project @ 1993-08-08 01:20:23 by jwe]
jwe
parents:
diff changeset
447
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
448 template <class T>
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
449 inline bool
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
450 do_mx_check (const Array<T>& a,
10481
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
451 bool (*op) (size_t, const T *) throw ())
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
452 {
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
453 return op (a.numel (), a.data ());
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
454 }
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
455
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
456 // NOTE: we don't use std::norm because it typically does some heavyweight
e8811e5dd699 avoid exception throwing in mx-inline loops
Jaroslav Hajek <highegg@gmail.com>
parents: 10365
diff changeset
457 // magic to avoid underflows, which we don't need here.
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
458 template <class T>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
459 inline T cabsq (const std::complex<T>& c)
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
460 { return c.real () * c.real () + c.imag () * c.imag (); }
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
461
8743
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
462 // default. works for integers and bool.
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
463 template <class T>
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
464 inline bool xis_true (T x) { return x; }
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
465 template <class T>
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
466 inline bool xis_false (T x) { return ! x; }
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
467 // for octave_ints
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
468 template <class T>
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
469 inline bool xis_true (const octave_int<T>& x) { return x.value (); }
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
470 template <class T>
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
471 inline bool xis_false (const octave_int<T>& x) { return ! x.value (); }
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
472 // for reals, we want to ignore NaNs.
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
473 inline bool xis_true (double x) { return ! xisnan (x) && x != 0.0; }
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
474 inline bool xis_false (double x) { return x == 0.0; }
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
475 inline bool xis_true (float x) { return ! xisnan (x) && x != 0.0f; }
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
476 inline bool xis_false (float x) { return x == 0.0f; }
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
477 // Ditto for complex.
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
478 inline bool xis_true (const Complex& x) { return ! xisnan (x) && x != 0.0; }
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
479 inline bool xis_false (const Complex& x) { return x == 0.0; }
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
480 inline bool xis_true (const FloatComplex& x) { return ! xisnan (x) && x != 0.0f; }
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
481 inline bool xis_false (const FloatComplex& x) { return x == 0.0f; }
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
482
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
483 #define OP_RED_SUM(ac, el) ac += el
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
484 #define OP_RED_PROD(ac, el) ac *= el
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
485 #define OP_RED_SUMSQ(ac, el) ac += el*el
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
486 #define OP_RED_SUMSQC(ac, el) ac += cabsq (el)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9513
diff changeset
487
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
488 inline void op_dble_sum (double& ac, float el)
9721
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
489 { ac += el; }
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
490 inline void op_dble_sum (Complex& ac, const FloatComplex& el)
9721
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
491 { ac += el; } // FIXME: guaranteed?
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
492 template <class T>
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
493 inline void op_dble_sum (double& ac, const octave_int<T>& el)
9721
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
494 { ac += el.double_value (); }
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
495
8743
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
496 // The following two implement a simple short-circuiting.
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
497 #define OP_RED_ANYC(ac, el) if (xis_true (el)) { ac = true; break; } else continue
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
498 #define OP_RED_ALLC(ac, el) if (xis_false (el)) { ac = false; break; } else continue
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
499
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
500 #define OP_RED_FCN(F, TSRC, TRES, OP, ZERO) \
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
501 template <class T> \
8743
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
502 inline TRES \
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
503 F (const TSRC* v, octave_idx_type n) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
504 { \
8743
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
505 TRES ac = ZERO; \
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
506 for (octave_idx_type i = 0; i < n; i++) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
507 OP(ac, v[i]); \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
508 return ac; \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
509 }
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
510
9721
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
511 #define PROMOTE_DOUBLE(T) typename subst_template_param<std::complex, T, double>::type
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
512
8743
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
513 OP_RED_FCN (mx_inline_sum, T, T, OP_RED_SUM, 0)
9721
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
514 OP_RED_FCN (mx_inline_dsum, T, PROMOTE_DOUBLE(T), op_dble_sum, 0.0)
8756
d0755c9db5ed implement fast logical sum (counting)
Jaroslav Hajek <highegg@gmail.com>
parents: 8751
diff changeset
515 OP_RED_FCN (mx_inline_count, bool, T, OP_RED_SUM, 0)
8743
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
516 OP_RED_FCN (mx_inline_prod, T, T, OP_RED_PROD, 1)
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
517 OP_RED_FCN (mx_inline_sumsq, T, T, OP_RED_SUMSQ, 0)
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
518 OP_RED_FCN (mx_inline_sumsq, std::complex<T>, T, OP_RED_SUMSQC, 0)
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
519 OP_RED_FCN (mx_inline_any, T, bool, OP_RED_ANYC, false)
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
520 OP_RED_FCN (mx_inline_all, T, bool, OP_RED_ALLC, true)
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
521
8743
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
522
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
523 #define OP_RED_FCN2(F, TSRC, TRES, OP, ZERO) \
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
524 template <class T> \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
525 inline void \
8743
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
526 F (const TSRC* v, TRES *r, octave_idx_type m, octave_idx_type n) \
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
527 { \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
528 for (octave_idx_type i = 0; i < m; i++) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
529 r[i] = ZERO; \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
530 for (octave_idx_type j = 0; j < n; j++) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
531 { \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
532 for (octave_idx_type i = 0; i < m; i++) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
533 OP(r[i], v[i]); \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
534 v += m; \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
535 } \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
536 }
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
537
8743
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
538 OP_RED_FCN2 (mx_inline_sum, T, T, OP_RED_SUM, 0)
9721
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
539 OP_RED_FCN2 (mx_inline_dsum, T, PROMOTE_DOUBLE(T), op_dble_sum, 0.0)
8756
d0755c9db5ed implement fast logical sum (counting)
Jaroslav Hajek <highegg@gmail.com>
parents: 8751
diff changeset
540 OP_RED_FCN2 (mx_inline_count, bool, T, OP_RED_SUM, 0)
8743
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
541 OP_RED_FCN2 (mx_inline_prod, T, T, OP_RED_PROD, 1)
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
542 OP_RED_FCN2 (mx_inline_sumsq, T, T, OP_RED_SUMSQ, 0)
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
543 OP_RED_FCN2 (mx_inline_sumsq, std::complex<T>, T, OP_RED_SUMSQC, 0)
8758
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
544
10147
adc0143e9419 optimize any/all (x, 2) with small number of rows
Jaroslav Hajek <highegg@gmail.com>
parents: 10146
diff changeset
545 #define OP_RED_ANYR(ac, el) ac |= xis_true (el)
adc0143e9419 optimize any/all (x, 2) with small number of rows
Jaroslav Hajek <highegg@gmail.com>
parents: 10146
diff changeset
546 #define OP_RED_ALLR(ac, el) ac &= xis_true (el)
adc0143e9419 optimize any/all (x, 2) with small number of rows
Jaroslav Hajek <highegg@gmail.com>
parents: 10146
diff changeset
547
adc0143e9419 optimize any/all (x, 2) with small number of rows
Jaroslav Hajek <highegg@gmail.com>
parents: 10146
diff changeset
548 OP_RED_FCN2 (mx_inline_any_r, T, bool, OP_RED_ANYR, false)
adc0143e9419 optimize any/all (x, 2) with small number of rows
Jaroslav Hajek <highegg@gmail.com>
parents: 10146
diff changeset
549 OP_RED_FCN2 (mx_inline_all_r, T, bool, OP_RED_ALLR, true)
adc0143e9419 optimize any/all (x, 2) with small number of rows
Jaroslav Hajek <highegg@gmail.com>
parents: 10146
diff changeset
550
8758
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
551 // Using the general code for any/all would sacrifice short-circuiting.
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
552 // OTOH, going by rows would sacrifice cache-coherence. The following algorithm
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
553 // will achieve both, at the cost of a temporary octave_idx_type array.
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
554
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
555 #define OP_ROW_SHORT_CIRCUIT(F, PRED, ZERO) \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
556 template <class T> \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
557 inline void \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
558 F (const T* v, bool *r, octave_idx_type m, octave_idx_type n) \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
559 { \
10147
adc0143e9419 optimize any/all (x, 2) with small number of rows
Jaroslav Hajek <highegg@gmail.com>
parents: 10146
diff changeset
560 if (n <= 8) \
adc0143e9419 optimize any/all (x, 2) with small number of rows
Jaroslav Hajek <highegg@gmail.com>
parents: 10146
diff changeset
561 return F ## _r (v, r, m, n); \
adc0143e9419 optimize any/all (x, 2) with small number of rows
Jaroslav Hajek <highegg@gmail.com>
parents: 10146
diff changeset
562 \
8758
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
563 /* FIXME: it may be sub-optimal to allocate the buffer here. */ \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
564 OCTAVE_LOCAL_BUFFER (octave_idx_type, iact, m); \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
565 for (octave_idx_type i = 0; i < m; i++) iact[i] = i; \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
566 octave_idx_type nact = m; \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
567 for (octave_idx_type j = 0; j < n; j++) \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
568 { \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
569 octave_idx_type k = 0; \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
570 for (octave_idx_type i = 0; i < nact; i++) \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
571 { \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
572 octave_idx_type ia = iact[i]; \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
573 if (! PRED (v[ia])) \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
574 iact[k++] = ia; \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
575 } \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
576 nact = k; \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
577 v += m; \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
578 } \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
579 for (octave_idx_type i = 0; i < m; i++) r[i] = ! ZERO; \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
580 for (octave_idx_type i = 0; i < nact; i++) r[iact[i]] = ZERO; \
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
581 }
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
582
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
583 OP_ROW_SHORT_CIRCUIT (mx_inline_any, xis_true, false)
83c9d60c3c47 implement short-circuiting row-reduction any/all algorithm
Jaroslav Hajek <highegg@gmail.com>
parents: 8756
diff changeset
584 OP_ROW_SHORT_CIRCUIT (mx_inline_all, xis_false, true)
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
585
8743
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
586 #define OP_RED_FCNN(F, TSRC, TRES) \
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
587 template <class T> \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
588 inline void \
8743
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
589 F (const TSRC *v, TRES *r, octave_idx_type l, \
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
590 octave_idx_type n, octave_idx_type u) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
591 { \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
592 if (l == 1) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
593 { \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
594 for (octave_idx_type i = 0; i < u; i++) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
595 { \
8756
d0755c9db5ed implement fast logical sum (counting)
Jaroslav Hajek <highegg@gmail.com>
parents: 8751
diff changeset
596 r[i] = F<T> (v, n); \
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
597 v += n; \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
598 } \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
599 } \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
600 else \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
601 { \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
602 for (octave_idx_type i = 0; i < u; i++) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
603 { \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
604 F (v, r, l, n); \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
605 v += l*n; \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
606 r += l; \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
607 } \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
608 } \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
609 }
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
610
8743
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
611 OP_RED_FCNN (mx_inline_sum, T, T)
9721
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
612 OP_RED_FCNN (mx_inline_dsum, T, PROMOTE_DOUBLE(T))
8756
d0755c9db5ed implement fast logical sum (counting)
Jaroslav Hajek <highegg@gmail.com>
parents: 8751
diff changeset
613 OP_RED_FCNN (mx_inline_count, bool, T)
8743
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
614 OP_RED_FCNN (mx_inline_prod, T, T)
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
615 OP_RED_FCNN (mx_inline_sumsq, T, T)
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
616 OP_RED_FCNN (mx_inline_sumsq, std::complex<T>, T)
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
617 OP_RED_FCNN (mx_inline_any, T, bool)
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
618 OP_RED_FCNN (mx_inline_all, T, bool)
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
619
8780
ea76466605ba support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
620 #define OP_CUM_FCN(F, TSRC, TRES, OP) \
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
621 template <class T> \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
622 inline void \
8780
ea76466605ba support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
623 F (const TSRC *v, TRES *r, octave_idx_type n) \
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
624 { \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
625 if (n) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
626 { \
8780
ea76466605ba support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
627 TRES t = r[0] = v[0]; \
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
628 for (octave_idx_type i = 1; i < n; i++) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
629 r[i] = t = t OP v[i]; \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
630 } \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
631 }
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
632
8780
ea76466605ba support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
633 OP_CUM_FCN (mx_inline_cumsum, T, T, +)
ea76466605ba support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
634 OP_CUM_FCN (mx_inline_cumprod, T, T, *)
ea76466605ba support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
635 OP_CUM_FCN (mx_inline_cumcount, bool, T, +)
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
636
8780
ea76466605ba support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
637 #define OP_CUM_FCN2(F, TSRC, TRES, OP) \
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
638 template <class T> \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
639 inline void \
8780
ea76466605ba support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
640 F (const TSRC *v, TRES *r, octave_idx_type m, octave_idx_type n) \
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
641 { \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
642 if (n) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
643 { \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
644 for (octave_idx_type i = 0; i < m; i++) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
645 r[i] = v[i]; \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
646 const T *r0 = r; \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
647 for (octave_idx_type j = 1; j < n; j++) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
648 { \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
649 r += m; v += m; \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
650 for (octave_idx_type i = 0; i < m; i++) \
8780
ea76466605ba support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
651 r[i] = r0[i] OP v[i]; \
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
652 r0 += m; \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
653 } \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
654 } \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
655 }
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
656
8780
ea76466605ba support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
657 OP_CUM_FCN2 (mx_inline_cumsum, T, T, +)
ea76466605ba support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
658 OP_CUM_FCN2 (mx_inline_cumprod, T, T, *)
10643
9852264314d1 fix cumulative logical sum
Jaroslav Hajek <highegg@gmail.com>
parents: 10482
diff changeset
659 OP_CUM_FCN2 (mx_inline_cumcount, bool, T, +)
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
660
8780
ea76466605ba support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
661 #define OP_CUM_FCNN(F, TSRC, TRES) \
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
662 template <class T> \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
663 inline void \
8780
ea76466605ba support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
664 F (const TSRC *v, TRES *r, octave_idx_type l, \
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
665 octave_idx_type n, octave_idx_type u) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
666 { \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
667 if (l == 1) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
668 { \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
669 for (octave_idx_type i = 0; i < u; i++) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
670 { \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
671 F (v, r, n); \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
672 v += n; r += n; \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
673 } \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
674 } \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
675 else \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
676 { \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
677 for (octave_idx_type i = 0; i < u; i++) \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
678 { \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
679 F (v, r, l, n); \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
680 v += l*n; \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
681 r += l*n; \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
682 } \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
683 } \
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
684 }
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
685
8780
ea76466605ba support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
686 OP_CUM_FCNN (mx_inline_cumsum, T, T)
ea76466605ba support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
687 OP_CUM_FCNN (mx_inline_cumprod, T, T)
ea76466605ba support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
688 OP_CUM_FCNN (mx_inline_cumcount, bool, T)
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
689
8751
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
690 #define OP_MINMAX_FCN(F, OP) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
691 template <class T> \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
692 void F (const T *v, T *r, octave_idx_type n) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
693 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
694 if (! n) return; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
695 T tmp = v[0]; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
696 octave_idx_type i = 1; \
8776
d23c33ec6bd3 fix min/max behaviour with NaNs
Jaroslav Hajek <highegg@gmail.com>
parents: 8759
diff changeset
697 if (xisnan (tmp)) \
d23c33ec6bd3 fix min/max behaviour with NaNs
Jaroslav Hajek <highegg@gmail.com>
parents: 8759
diff changeset
698 { \
d23c33ec6bd3 fix min/max behaviour with NaNs
Jaroslav Hajek <highegg@gmail.com>
parents: 8759
diff changeset
699 for (; i < n && xisnan (v[i]); i++) ; \
d23c33ec6bd3 fix min/max behaviour with NaNs
Jaroslav Hajek <highegg@gmail.com>
parents: 8759
diff changeset
700 if (i < n) tmp = v[i]; \
d23c33ec6bd3 fix min/max behaviour with NaNs
Jaroslav Hajek <highegg@gmail.com>
parents: 8759
diff changeset
701 } \
d23c33ec6bd3 fix min/max behaviour with NaNs
Jaroslav Hajek <highegg@gmail.com>
parents: 8759
diff changeset
702 for (; i < n; i++) \
8751
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
703 if (v[i] OP tmp) tmp = v[i]; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
704 *r = tmp; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
705 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
706 template <class T> \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
707 void F (const T *v, T *r, octave_idx_type *ri, octave_idx_type n) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
708 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
709 if (! n) return; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
710 T tmp = v[0]; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
711 octave_idx_type tmpi = 0; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
712 octave_idx_type i = 1; \
8776
d23c33ec6bd3 fix min/max behaviour with NaNs
Jaroslav Hajek <highegg@gmail.com>
parents: 8759
diff changeset
713 if (xisnan (tmp)) \
d23c33ec6bd3 fix min/max behaviour with NaNs
Jaroslav Hajek <highegg@gmail.com>
parents: 8759
diff changeset
714 { \
d23c33ec6bd3 fix min/max behaviour with NaNs
Jaroslav Hajek <highegg@gmail.com>
parents: 8759
diff changeset
715 for (; i < n && xisnan (v[i]); i++) ; \
d23c33ec6bd3 fix min/max behaviour with NaNs
Jaroslav Hajek <highegg@gmail.com>
parents: 8759
diff changeset
716 if (i < n) { tmp = v[i]; tmpi = i; } \
d23c33ec6bd3 fix min/max behaviour with NaNs
Jaroslav Hajek <highegg@gmail.com>
parents: 8759
diff changeset
717 } \
d23c33ec6bd3 fix min/max behaviour with NaNs
Jaroslav Hajek <highegg@gmail.com>
parents: 8759
diff changeset
718 for (; i < n; i++) \
8751
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
719 if (v[i] OP tmp) { tmp = v[i]; tmpi = i; }\
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
720 *r = tmp; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
721 *ri = tmpi; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
722 }
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
723
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
724 OP_MINMAX_FCN (mx_inline_min, <)
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
725 OP_MINMAX_FCN (mx_inline_max, >)
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
726
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
727 // Row reductions will be slightly complicated. We will proceed with checks
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
728 // for NaNs until we detect that no row will yield a NaN, in which case we
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
729 // proceed to a faster code.
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
730
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
731 #define OP_MINMAX_FCN2(F, OP) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
732 template <class T> \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
733 inline void \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
734 F (const T *v, T *r, octave_idx_type m, octave_idx_type n) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
735 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
736 if (! n) return; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
737 bool nan = false; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
738 octave_idx_type j = 0; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
739 for (octave_idx_type i = 0; i < m; i++) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
740 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
741 r[i] = v[i]; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
742 if (xisnan (v[i])) nan = true; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
743 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
744 j++; v += m; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
745 while (nan && j < n) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
746 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
747 nan = false; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
748 for (octave_idx_type i = 0; i < m; i++) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
749 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
750 if (xisnan (v[i])) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
751 nan = true; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
752 else if (xisnan (r[i]) || v[i] OP r[i]) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
753 r[i] = v[i]; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
754 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
755 j++; v += m; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
756 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
757 while (j < n) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
758 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
759 for (octave_idx_type i = 0; i < m; i++) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
760 if (v[i] OP r[i]) r[i] = v[i]; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
761 j++; v += m; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
762 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
763 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
764 template <class T> \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
765 inline void \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
766 F (const T *v, T *r, octave_idx_type *ri, \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
767 octave_idx_type m, octave_idx_type n) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
768 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
769 if (! n) return; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
770 bool nan = false; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
771 octave_idx_type j = 0; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
772 for (octave_idx_type i = 0; i < m; i++) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
773 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
774 r[i] = v[i]; ri[i] = j; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
775 if (xisnan (v[i])) nan = true; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
776 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
777 j++; v += m; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
778 while (nan && j < n) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
779 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
780 nan = false; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
781 for (octave_idx_type i = 0; i < m; i++) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
782 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
783 if (xisnan (v[i])) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
784 nan = true; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
785 else if (xisnan (r[i]) || v[i] OP r[i]) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
786 { r[i] = v[i]; ri[i] = j; } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
787 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
788 j++; v += m; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
789 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
790 while (j < n) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
791 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
792 for (octave_idx_type i = 0; i < m; i++) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
793 if (v[i] OP r[i]) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
794 { r[i] = v[i]; ri[i] = j; } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
795 j++; v += m; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
796 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
797 }
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
798
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
799 OP_MINMAX_FCN2 (mx_inline_min, <)
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
800 OP_MINMAX_FCN2 (mx_inline_max, >)
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
801
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
802 #define OP_MINMAX_FCNN(F) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
803 template <class T> \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
804 inline void \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
805 F (const T *v, T *r, octave_idx_type l, \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
806 octave_idx_type n, octave_idx_type u) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
807 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
808 if (! n) return; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
809 if (l == 1) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
810 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
811 for (octave_idx_type i = 0; i < u; i++) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
812 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
813 F (v, r, n); \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
814 v += n; r++; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
815 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
816 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
817 else \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
818 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
819 for (octave_idx_type i = 0; i < u; i++) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
820 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
821 F (v, r, l, n); \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
822 v += l*n; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
823 r += l; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
824 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
825 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
826 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
827 template <class T> \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
828 inline void \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
829 F (const T *v, T *r, octave_idx_type *ri, \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
830 octave_idx_type l, octave_idx_type n, octave_idx_type u) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
831 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
832 if (! n) return; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
833 if (l == 1) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
834 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
835 for (octave_idx_type i = 0; i < u; i++) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
836 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
837 F (v, r, ri, n); \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
838 v += n; r++; ri++; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
839 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
840 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
841 else \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
842 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
843 for (octave_idx_type i = 0; i < u; i++) \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
844 { \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
845 F (v, r, ri, l, n); \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
846 v += l*n; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
847 r += l; ri += l; \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
848 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
849 } \
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
850 }
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
851
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
852 OP_MINMAX_FCNN (mx_inline_min)
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
853 OP_MINMAX_FCNN (mx_inline_max)
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
854
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
855 #define OP_CUMMINMAX_FCN(F, OP) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
856 template <class T> \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
857 void F (const T *v, T *r, octave_idx_type n) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
858 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
859 if (! n) return; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
860 T tmp = v[0]; \
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
861 octave_idx_type i = 1; \
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
862 octave_idx_type j = 0; \
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
863 if (xisnan (tmp)) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
864 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
865 for (; i < n && xisnan (v[i]); i++) ; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
866 for (; j < i; j++) r[j] = tmp; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
867 if (i < n) tmp = v[i]; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
868 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
869 for (; i < n; i++) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
870 if (v[i] OP tmp) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
871 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
872 for (; j < i; j++) r[j] = tmp; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
873 tmp = v[i]; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
874 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
875 for (; j < i; j++) r[j] = tmp; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
876 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
877 template <class T> \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
878 void F (const T *v, T *r, octave_idx_type *ri, octave_idx_type n) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
879 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
880 if (! n) return; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
881 T tmp = v[0]; octave_idx_type tmpi = 0; \
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
882 octave_idx_type i = 1; \
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
883 octave_idx_type j = 0; \
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
884 if (xisnan (tmp)) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
885 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
886 for (; i < n && xisnan (v[i]); i++) ; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
887 for (; j < i; j++) { r[j] = tmp; ri[j] = tmpi; } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
888 if (i < n) { tmp = v[i]; tmpi = i; } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
889 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
890 for (; i < n; i++) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
891 if (v[i] OP tmp) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
892 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
893 for (; j < i; j++) { r[j] = tmp; ri[j] = tmpi; } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
894 tmp = v[i]; tmpi = i; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
895 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
896 for (; j < i; j++) { r[j] = tmp; ri[j] = tmpi; } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
897 }
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
898
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
899 OP_CUMMINMAX_FCN (mx_inline_cummin, <)
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
900 OP_CUMMINMAX_FCN (mx_inline_cummax, >)
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
901
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
902 // Row reductions will be slightly complicated. We will proceed with checks
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
903 // for NaNs until we detect that no row will yield a NaN, in which case we
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
904 // proceed to a faster code.
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
905
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
906 #define OP_CUMMINMAX_FCN2(F, OP) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
907 template <class T> \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
908 inline void \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
909 F (const T *v, T *r, octave_idx_type m, octave_idx_type n) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
910 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
911 if (! n) return; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
912 bool nan = false; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
913 const T *r0; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
914 octave_idx_type j = 0; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
915 for (octave_idx_type i = 0; i < m; i++) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
916 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
917 r[i] = v[i]; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
918 if (xisnan (v[i])) nan = true; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
919 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
920 j++; v += m; r0 = r; r += m; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
921 while (nan && j < n) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
922 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
923 nan = false; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
924 for (octave_idx_type i = 0; i < m; i++) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
925 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
926 if (xisnan (v[i])) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
927 { r[i] = r0[i]; nan = true; } \
8949
e31d47f2c9bb fixes to row-reducing cummin/cummax
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
928 else if (xisnan (r0[i]) || v[i] OP r0[i]) \
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
929 r[i] = v[i]; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
930 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
931 j++; v += m; r0 = r; r += m; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
932 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
933 while (j < n) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
934 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
935 for (octave_idx_type i = 0; i < m; i++) \
8949
e31d47f2c9bb fixes to row-reducing cummin/cummax
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
936 if (v[i] OP r0[i]) \
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
937 r[i] = v[i]; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
938 else \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
939 r[i] = r0[i]; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
940 j++; v += m; r0 = r; r += m; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
941 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
942 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
943 template <class T> \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
944 inline void \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
945 F (const T *v, T *r, octave_idx_type *ri, \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
946 octave_idx_type m, octave_idx_type n) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
947 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
948 if (! n) return; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
949 bool nan = false; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
950 const T *r0; const octave_idx_type *r0i; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
951 octave_idx_type j = 0; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
952 for (octave_idx_type i = 0; i < m; i++) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
953 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
954 r[i] = v[i]; ri[i] = 0; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
955 if (xisnan (v[i])) nan = true; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
956 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
957 j++; v += m; r0 = r; r += m; r0i = ri; ri += m; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
958 while (nan && j < n) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
959 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
960 nan = false; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
961 for (octave_idx_type i = 0; i < m; i++) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
962 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
963 if (xisnan (v[i])) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
964 { r[i] = r0[i]; ri[i] = r0i[i]; nan = true; } \
8949
e31d47f2c9bb fixes to row-reducing cummin/cummax
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
965 else if (xisnan (r0[i]) || v[i] OP r0[i]) \
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
966 { r[i] = v[i]; ri[i] = j; }\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
967 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
968 j++; v += m; r0 = r; r += m; r0i = ri; ri += m; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
969 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
970 while (j < n) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
971 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
972 for (octave_idx_type i = 0; i < m; i++) \
8949
e31d47f2c9bb fixes to row-reducing cummin/cummax
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
973 if (v[i] OP r0[i]) \
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
974 { r[i] = v[i]; ri[i] = j; } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
975 else \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
976 { r[i] = r0[i]; ri[i] = r0i[i]; } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
977 j++; v += m; r0 = r; r += m; r0i = ri; ri += m; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
978 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
979 }
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
980
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
981 OP_CUMMINMAX_FCN2 (mx_inline_cummin, <)
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
982 OP_CUMMINMAX_FCN2 (mx_inline_cummax, >)
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
983
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
984 #define OP_CUMMINMAX_FCNN(F) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
985 template <class T> \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
986 inline void \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
987 F (const T *v, T *r, octave_idx_type l, \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
988 octave_idx_type n, octave_idx_type u) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
989 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
990 if (! n) return; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
991 if (l == 1) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
992 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
993 for (octave_idx_type i = 0; i < u; i++) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
994 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
995 F (v, r, n); \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
996 v += n; r += n; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
997 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
998 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
999 else \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1000 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1001 for (octave_idx_type i = 0; i < u; i++) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1002 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1003 F (v, r, l, n); \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1004 v += l*n; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1005 r += l*n; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1006 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1007 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1008 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1009 template <class T> \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1010 inline void \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1011 F (const T *v, T *r, octave_idx_type *ri, \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1012 octave_idx_type l, octave_idx_type n, octave_idx_type u) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1013 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1014 if (! n) return; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1015 if (l == 1) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1016 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1017 for (octave_idx_type i = 0; i < u; i++) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1018 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1019 F (v, r, ri, n); \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1020 v += n; r += n; ri += n; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1021 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1022 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1023 else \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1024 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1025 for (octave_idx_type i = 0; i < u; i++) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1026 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1027 F (v, r, ri, l, n); \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1028 v += l*n; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1029 r += l*n; ri += l*n; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1030 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1031 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1032 }
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1033
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1034 OP_CUMMINMAX_FCNN (mx_inline_cummin)
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1035 OP_CUMMINMAX_FCNN (mx_inline_cummax)
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1036
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1037 template <class T>
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1038 void mx_inline_diff (const T *v, T *r, octave_idx_type n,
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1039 octave_idx_type order)
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1040 {
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1041 switch (order)
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1042 {
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1043 case 1:
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1044 for (octave_idx_type i = 0; i < n-1; i++)
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1045 r[i] = v[i+1] - v[i];
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1046 break;
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1047 case 2:
9702
9ecd35a606e3 avoid some warnings from g++
John W. Eaton <jwe@octave.org>
parents: 9612
diff changeset
1048 if (n > 1)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1049 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1050 T lst = v[1] - v[0];
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1051 for (octave_idx_type i = 0; i < n-2; i++)
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1052 {
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1053 T dif = v[i+2] - v[i+1];
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1054 r[i] = dif - lst;
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1055 lst = dif;
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1056 }
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1057 }
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1058 break;
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1059 default:
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1060 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1061 OCTAVE_LOCAL_BUFFER (T, buf, n-1);
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1062
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1063 for (octave_idx_type i = 0; i < n-1; i++)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1064 buf[i] = v[i+1] - v[i];
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1065
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1066 for (octave_idx_type o = 2; o <= order; o++)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1067 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1068 for (octave_idx_type i = 0; i < n-o; i++)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1069 buf[i] = buf[i+1] - buf[i];
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1070 }
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1071
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1072 for (octave_idx_type i = 0; i < n-order; i++)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1073 r[i] = buf[i];
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1074 }
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1075 }
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1076 }
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1077
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1078 template <class T>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1079 void mx_inline_diff (const T *v, T *r,
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1080 octave_idx_type m, octave_idx_type n,
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1081 octave_idx_type order)
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1082 {
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1083 switch (order)
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1084 {
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1085 case 1:
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1086 for (octave_idx_type i = 0; i < m*(n-1); i++)
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1087 r[i] = v[i+m] - v[i];
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1088 break;
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1089 case 2:
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1090 for (octave_idx_type i = 0; i < n-2; i++)
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1091 {
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1092 for (octave_idx_type j = i*m; j < i*m+m; j++)
15118
a4e94933fed3 Fix bug #37033 in diff ()
Carlo de Falco <cdf@users.sourceforge.net>
parents: 14138
diff changeset
1093 r[j] = (v[j+m+m] - v[j+m]) - (v[j+m] - v[j]);
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1094 }
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1095 break;
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1096 default:
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1097 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1098 OCTAVE_LOCAL_BUFFER (T, buf, n-1);
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1099
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1100 for (octave_idx_type j = 0; j < m; j++)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1101 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1102 for (octave_idx_type i = 0; i < n-1; i++)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1103 buf[i] = v[i*m+j+m] - v[i*m+j];
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1104
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1105 for (octave_idx_type o = 2; o <= order; o++)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1106 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1107 for (octave_idx_type i = 0; i < n-o; i++)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1108 buf[i] = buf[i+1] - buf[i];
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1109 }
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1110
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1111 for (octave_idx_type i = 0; i < n-order; i++)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1112 r[i*m+j] = buf[i];
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1113 }
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1114 }
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1115 }
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1116 }
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1117
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1118 template <class T>
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1119 inline void
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1120 mx_inline_diff (const T *v, T *r,
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1121 octave_idx_type l, octave_idx_type n, octave_idx_type u,
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1122 octave_idx_type order)
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1123 {
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1124 if (! n) return;
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1125 if (l == 1)
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1126 {
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1127 for (octave_idx_type i = 0; i < u; i++)
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1128 {
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1129 mx_inline_diff (v, r, n, order);
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1130 v += n; r += n-order;
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1131 }
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1132 }
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1133 else
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1134 {
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1135 for (octave_idx_type i = 0; i < u; i++)
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1136 {
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1137 mx_inline_diff (v, r, l, n, order);
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1138 v += l*n;
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1139 r += l*(n-order);
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1140 }
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1141 }
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1142 }
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1143
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1144 // Assistant function
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1145
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1146 inline void
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1147 get_extent_triplet (const dim_vector& dims, int& dim,
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1148 octave_idx_type& l, octave_idx_type& n,
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1149 octave_idx_type& u)
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1150 {
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1151 octave_idx_type ndims = dims.length ();
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1152 if (dim >= ndims)
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1153 {
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1154 l = dims.numel ();
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1155 n = 1;
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1156 u = 1;
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1157 }
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1158 else
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1159 {
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1160 if (dim < 0)
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1161 dim = dims.first_non_singleton ();
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1162
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1163 // calculate extent triplet.
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1164 l = 1, n = dims(dim), u = 1;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1165 for (octave_idx_type i = 0; i < dim; i++)
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1166 l *= dims (i);
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1167 for (octave_idx_type i = dim + 1; i < ndims; i++)
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1168 u *= dims (i);
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1169 }
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1170 }
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1171
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1172 // Appliers.
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1173 // FIXME: is this the best design? C++ gives a lot of options here...
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1174 // maybe it can be done without an explicit parameter?
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1175
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1176 template <class R, class T>
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1177 inline Array<R>
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1178 do_mx_red_op (const Array<T>& src, int dim,
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1179 void (*mx_red_op) (const T *, R *, octave_idx_type,
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1180 octave_idx_type, octave_idx_type))
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1181 {
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1182 octave_idx_type l, n, u;
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1183 dim_vector dims = src.dims ();
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
1184 // M*b inconsistency: sum ([]) = 0 etc.
8743
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
1185 if (dims.length () == 2 && dims(0) == 0 && dims(1) == 0)
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
1186 dims (1) = 1;
1bd918cfb6e2 reimplement any & all using the new reduction code
Jaroslav Hajek <highegg@gmail.com>
parents: 8736
diff changeset
1187
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1188 get_extent_triplet (dims, dim, l, n, u);
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1189
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1190 // Reduction operation reduces the array size.
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1191 if (dim < dims.length ()) dims(dim) = 1;
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1192 dims.chop_trailing_singletons ();
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1193
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1194 Array<R> ret (dims);
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1195 mx_red_op (src.data (), ret.fortran_vec (), l, n, u);
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1196
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1197 return ret;
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1198 }
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1199
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1200 template <class R, class T>
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1201 inline Array<R>
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1202 do_mx_cum_op (const Array<T>& src, int dim,
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1203 void (*mx_cum_op) (const T *, R *, octave_idx_type,
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1204 octave_idx_type, octave_idx_type))
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1205 {
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1206 octave_idx_type l, n, u;
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1207 dim_vector dims = src.dims ();
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1208 get_extent_triplet (dims, dim, l, n, u);
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1209
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1210 // Cumulative operation doesn't reduce the array size.
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1211 Array<R> ret (dims);
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1212 mx_cum_op (src.data (), ret.fortran_vec (), l, n, u);
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1213
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1214 return ret;
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1215 }
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
1216
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1217 template <class R>
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1218 inline Array<R>
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1219 do_mx_minmax_op (const Array<R>& src, int dim,
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1220 void (*mx_minmax_op) (const R *, R *, octave_idx_type,
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1221 octave_idx_type, octave_idx_type))
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1222 {
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1223 octave_idx_type l, n, u;
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1224 dim_vector dims = src.dims ();
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1225 get_extent_triplet (dims, dim, l, n, u);
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1226
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1227 // If the dimension is zero, we don't do anything.
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1228 if (dim < dims.length () && dims(dim) != 0) dims(dim) = 1;
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1229 dims.chop_trailing_singletons ();
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1230
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1231 Array<R> ret (dims);
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1232 mx_minmax_op (src.data (), ret.fortran_vec (), l, n, u);
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1233
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1234 return ret;
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1235 }
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1236
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1237 template <class R>
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1238 inline Array<R>
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1239 do_mx_minmax_op (const Array<R>& src, Array<octave_idx_type>& idx, int dim,
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1240 void (*mx_minmax_op) (const R *, R *, octave_idx_type *,
8751
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1241 octave_idx_type, octave_idx_type, octave_idx_type))
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1242 {
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1243 octave_idx_type l, n, u;
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1244 dim_vector dims = src.dims ();
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1245 get_extent_triplet (dims, dim, l, n, u);
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1246
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1247 // If the dimension is zero, we don't do anything.
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1248 if (dim < dims.length () && dims(dim) != 0) dims(dim) = 1;
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1249 dims.chop_trailing_singletons ();
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1250
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1251 Array<R> ret (dims);
8751
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1252 if (idx.dims () != dims) idx = Array<octave_idx_type> (dims);
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1253
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1254 mx_minmax_op (src.data (), ret.fortran_vec (), idx.fortran_vec (),
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1255 l, n, u);
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1256
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1257 return ret;
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1258 }
9f7ce4bf7650 optimize min/max functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
1259
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1260 template <class R>
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1261 inline Array<R>
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1262 do_mx_cumminmax_op (const Array<R>& src, int dim,
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1263 void (*mx_cumminmax_op) (const R *, R *, octave_idx_type,
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1264 octave_idx_type, octave_idx_type))
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1265 {
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1266 octave_idx_type l, n, u;
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1267 dim_vector dims = src.dims ();
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1268 get_extent_triplet (dims, dim, l, n, u);
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1269
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1270 Array<R> ret (dims);
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1271 mx_cumminmax_op (src.data (), ret.fortran_vec (), l, n, u);
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1272
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1273 return ret;
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1274 }
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1275
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1276 template <class R>
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1277 inline Array<R>
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1278 do_mx_cumminmax_op (const Array<R>& src, Array<octave_idx_type>& idx, int dim,
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1279 void (*mx_cumminmax_op) (const R *, R *, octave_idx_type *,
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1280 octave_idx_type, octave_idx_type, octave_idx_type))
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1281 {
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1282 octave_idx_type l, n, u;
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1283 dim_vector dims = src.dims ();
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1284 get_extent_triplet (dims, dim, l, n, u);
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1285
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1286 Array<R> ret (dims);
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1287 if (idx.dims () != dims) idx = Array<octave_idx_type> (dims);
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1288
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1289 mx_cumminmax_op (src.data (), ret.fortran_vec (), idx.fortran_vec (),
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1290 l, n, u);
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1291
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1292 return ret;
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1293 }
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8776
diff changeset
1294
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1295 template <class R>
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1296 inline Array<R>
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1297 do_mx_diff_op (const Array<R>& src, int dim, octave_idx_type order,
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1298 void (*mx_diff_op) (const R *, R *,
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1299 octave_idx_type, octave_idx_type, octave_idx_type,
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1300 octave_idx_type))
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1301 {
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1302 octave_idx_type l, n, u;
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1303 if (order <= 0)
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1304 return src;
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1305
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1306 dim_vector dims = src.dims ();
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1307
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1308 get_extent_triplet (dims, dim, l, n, u);
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1309 if (dim >= dims.length ())
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1310 dims.resize (dim+1, 1);
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1311
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1312 if (dims(dim) <= order)
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1313 {
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1314 dims (dim) = 0;
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1315 return Array<R> (dims);
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1316 }
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1317 else
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1318 {
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1319 dims(dim) -= order;
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1320 }
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1321
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
1322 Array<R> ret (dims);
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1323 mx_diff_op (src.data (), ret.fortran_vec (), l, n, u, order);
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1324
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1325 return ret;
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1326 }
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8949
diff changeset
1327
9721
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1328 // Fast extra-precise summation. According to
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1329 // T. Ogita, S. M. Rump, S. Oishi:
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1330 // Accurate Sum And Dot Product,
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1331 // SIAM J. Sci. Computing, Vol. 26, 2005
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1332
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1333 template <class T>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1334 inline void twosum_accum (T& s, T& e,
9721
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1335 const T& x)
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1336 {
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
1337 T s1 = s + x;
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
1338 T t = s1 - s;
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
1339 T e1 = (s - (s1 - t)) + (x - t);
9721
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1340 s = s1;
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1341 e += e1;
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1342 }
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1343
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1344 template <class T>
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1345 inline T
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1346 mx_inline_xsum (const T *v, octave_idx_type n)
9721
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1347 {
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
1348 T s = 0;
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
1349 T e = 0;
9721
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1350 for (octave_idx_type i = 0; i < n; i++)
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1351 twosum_accum (s, e, v[i]);
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1352
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1353 return s + e;
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1354 }
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1355
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1356 template <class T>
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1357 inline void
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1358 mx_inline_xsum (const T *v, T *r,
9721
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1359 octave_idx_type m, octave_idx_type n)
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1360 {
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1361 OCTAVE_LOCAL_BUFFER (T, e, m);
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1362 for (octave_idx_type i = 0; i < m; i++)
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1363 e[i] = r[i] = T ();
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1364
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1365 for (octave_idx_type j = 0; j < n; j++)
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1366 {
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1367 for (octave_idx_type i = 0; i < m; i++)
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1368 twosum_accum (r[i], e[i], v[i]);
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1369
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1370 v += m;
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1371 }
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1372
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1373 for (octave_idx_type i = 0; i < m; i++)
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1374 r[i] += e[i];
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1375 }
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1376
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1377 OP_RED_FCNN (mx_inline_xsum, T, T)
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9702
diff changeset
1378
2804
eedc2f3f61f7 [project @ 1997-03-11 04:34:50 by jwe]
jwe
parents: 2386
diff changeset
1379 #endif