Mercurial > hg > octave-nkf
annotate liboctave/array/intNDArray.cc @ 20442:a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
* liboctave/array/Array.h (Array::length): deprecate for ::numel.
* liboctave/array/Sparse.h (Sparse::length): deprecate for ::numel.
* libgui/graphics/QtHandlesUtils.cc, libgui/src/octave-qt-link.cc,
libinterp/corefcn/Cell.cc, libinterp/corefcn/__contourc__.cc,
libinterp/corefcn/__pchip_deriv__.cc, libinterp/corefcn/__qp__.cc,
libinterp/corefcn/cellfun.cc, libinterp/corefcn/daspk.cc,
libinterp/corefcn/dasrt.cc, libinterp/corefcn/dassl.cc,
libinterp/corefcn/data.cc, libinterp/corefcn/filter.cc,
libinterp/corefcn/find.cc, libinterp/corefcn/gl-render.cc,
libinterp/corefcn/gl-render.h, libinterp/corefcn/graphics.cc,
libinterp/corefcn/graphics.in.h, libinterp/corefcn/help.cc,
libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc,
libinterp/corefcn/load-path.cc, libinterp/corefcn/load-save.cc,
libinterp/corefcn/ls-oct-ascii.h, libinterp/corefcn/lsode.cc,
libinterp/corefcn/matrix_type.cc, libinterp/corefcn/oct-hist.cc,
libinterp/corefcn/oct-map.cc, libinterp/corefcn/oct-map.h,
libinterp/corefcn/oct-obj.h, libinterp/corefcn/oct-stream.cc,
libinterp/corefcn/oct-stream.h, libinterp/corefcn/pr-output.cc,
libinterp/corefcn/quadcc.cc, libinterp/corefcn/rand.cc,
libinterp/corefcn/regexp.cc, libinterp/corefcn/strfns.cc,
libinterp/corefcn/sub2ind.cc, libinterp/corefcn/symtab.h,
libinterp/corefcn/syscalls.cc, libinterp/corefcn/tsearch.cc,
libinterp/corefcn/urlwrite.cc, libinterp/corefcn/utils.cc,
libinterp/corefcn/variables.cc, libinterp/corefcn/xdiv.cc,
libinterp/corefcn/xpow.cc, libinterp/dldfcn/__glpk__.cc,
libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/__magick_read__.cc,
libinterp/dldfcn/audiodevinfo.cc, libinterp/dldfcn/ccolamd.cc,
libinterp/dldfcn/colamd.cc, libinterp/octave-value/ov-cell.cc,
libinterp/octave-value/ov-class.cc, libinterp/octave-value/ov-class.h,
libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-java.cc,
libinterp/octave-value/ov-perm.cc, libinterp/octave-value/ov-struct.cc,
libinterp/octave-value/ov-typeinfo.cc, libinterp/octave-value/ov.cc,
libinterp/operators/op-int.h, libinterp/parse-tree/pt-pr-code.cc,
liboctave/array/Array-util.cc, liboctave/array/Array.cc,
liboctave/array/CColVector.cc, liboctave/array/CDiagMatrix.cc,
liboctave/array/CMatrix.cc, liboctave/array/CRowVector.cc,
liboctave/array/DiagArray2.cc, liboctave/array/DiagArray2.h,
liboctave/array/MArray.cc, liboctave/array/PermMatrix.cc,
liboctave/array/PermMatrix.h, liboctave/array/Sparse.cc,
liboctave/array/boolMatrix.cc, liboctave/array/chMatrix.cc,
liboctave/array/chNDArray.cc, liboctave/array/dColVector.cc,
liboctave/array/dDiagMatrix.cc, liboctave/array/dMatrix.cc,
liboctave/array/dRowVector.cc, liboctave/array/fCColVector.cc,
liboctave/array/fCDiagMatrix.cc, liboctave/array/fCMatrix.cc,
liboctave/array/fCRowVector.cc, liboctave/array/fColVector.cc,
liboctave/array/fDiagMatrix.cc, liboctave/array/fMatrix.cc,
liboctave/array/fRowVector.cc, liboctave/array/idx-vector.cc,
liboctave/array/intNDArray.cc, liboctave/numeric/CmplxCHOL.cc,
liboctave/numeric/CmplxLU.cc, liboctave/numeric/CmplxQR.cc,
liboctave/numeric/DASPK.cc, liboctave/numeric/DASRT.cc,
liboctave/numeric/DASSL.cc, liboctave/numeric/LSODE.cc,
liboctave/numeric/ODES.cc, liboctave/numeric/ODES.h,
liboctave/numeric/base-dae.h, liboctave/numeric/base-lu.cc,
liboctave/numeric/dbleCHOL.cc, liboctave/numeric/dbleLU.cc,
liboctave/numeric/dbleQR.cc, liboctave/numeric/eigs-base.cc,
liboctave/numeric/fCmplxCHOL.cc, liboctave/numeric/fCmplxLU.cc,
liboctave/numeric/fCmplxQR.cc, liboctave/numeric/floatCHOL.cc,
liboctave/numeric/floatLU.cc, liboctave/numeric/floatQR.cc,
liboctave/numeric/lo-specfun.cc, liboctave/numeric/oct-rand.cc,
liboctave/numeric/oct-spparms.cc, liboctave/numeric/sparse-base-chol.cc,
liboctave/operators/mx-inlines.cc, liboctave/system/file-ops.cc,
liboctave/util/glob-match.h, liboctave/util/kpse.cc,
liboctave/util/lo-regexp.cc, liboctave/util/oct-glob.cc,
liboctave/util/pathsearch.cc, liboctave/util/str-vec.cc,
liboctave/util/str-vec.h, liboctave/util/url-transfer.cc: replace all usage
of Array::length() and Sparse::length() with ::numel().
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Sat, 30 May 2015 03:14:07 +0100 |
parents | 00cf2847355d |
children |
rev | line source |
---|---|
4902 | 1 // N-D Array manipulations. |
2 /* | |
3 | |
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18890
diff
changeset
|
4 Copyright (C) 2004-2015 John W. Eaton |
9601
a9b37bae1802
add a couple of missing copyright statements
Jaroslav Hajek <highegg@gmail.com>
parents:
9513
diff
changeset
|
5 Copyright (C) 2009 VZLU Prague, a.s. |
4902 | 6 |
7 This file is part of Octave. | |
8 | |
9 Octave is free software; you can redistribute it and/or modify it | |
10 under the terms of the GNU General Public License as published by the | |
7016 | 11 Free Software Foundation; either version 3 of the License, or (at your |
12 option) any later version. | |
4902 | 13 |
14 Octave is distributed in the hope that it will be useful, but WITHOUT | |
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
7016 | 20 along with Octave; see the file COPYING. If not, see |
21 <http://www.gnu.org/licenses/>. | |
4902 | 22 |
23 */ | |
24 | |
25 #ifdef HAVE_CONFIG_H | |
26 #include <config.h> | |
27 #endif | |
28 | |
29 #include "Array-util.h" | |
30 #include "mx-base.h" | |
31 #include "lo-ieee.h" | |
8741
008f3985c8c0
use new summation code for native integer summation
Jaroslav Hajek <highegg@gmail.com>
parents:
7620
diff
changeset
|
32 #include "mx-inlines.cc" |
4902 | 33 |
34 // unary operations | |
35 | |
36 template <class T> | |
37 boolNDArray | |
38 intNDArray<T>::operator ! (void) const | |
39 { | |
4932 | 40 boolNDArray b (this->dims ()); |
4902 | 41 |
20442
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20438
diff
changeset
|
42 for (octave_idx_type i = 0; i < this->numel (); i++) |
4932 | 43 b.elem (i) = ! this->elem (i); |
4902 | 44 |
45 return b; | |
46 } | |
47 | |
5943 | 48 template <class T> |
49 bool | |
50 intNDArray<T>::any_element_not_one_or_zero (void) const | |
51 { | |
20438
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
52 octave_idx_type nel = this->numel (); |
5943 | 53 |
54 for (octave_idx_type i = 0; i < nel; i++) | |
55 { | |
56 T val = this->elem (i); | |
57 | |
58 if (val != 0.0 && val != 1.0) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
59 return true; |
5943 | 60 } |
61 | |
62 return false; | |
63 } | |
64 | |
6979 | 65 template <class T> |
66 intNDArray<T> | |
67 intNDArray<T>::diag (octave_idx_type k) const | |
68 { | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10314
diff
changeset
|
69 return MArray<T>::diag (k); |
6979 | 70 } |
71 | |
14557
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
72 template <class T> |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
73 intNDArray<T> |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
74 intNDArray<T>::diag (octave_idx_type m, octave_idx_type n) const |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
75 { |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
76 return MArray<T>::diag (m, n); |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
77 } |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
78 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
79 // FIXME: this is not quite the right thing. |
4902 | 80 |
81 template <class T> | |
82 boolNDArray | |
83 intNDArray<T>::all (int dim) const | |
84 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
85 return do_mx_red_op<bool, T > (*this, dim, mx_inline_all); |
4902 | 86 } |
87 | |
88 template <class T> | |
89 boolNDArray | |
90 intNDArray<T>::any (int dim) const | |
91 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
92 return do_mx_red_op<bool, T > (*this, dim, mx_inline_any); |
4902 | 93 } |
94 | |
95 template <class T> | |
96 void | |
5275 | 97 intNDArray<T>::increment_index (Array<octave_idx_type>& ra_idx, |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
98 const dim_vector& dimensions, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
99 int start_dimension) |
4902 | 100 { |
101 ::increment_index (ra_idx, dimensions, start_dimension); | |
102 } | |
103 | |
104 template <class T> | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
105 octave_idx_type |
5275 | 106 intNDArray<T>::compute_index (Array<octave_idx_type>& ra_idx, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
107 const dim_vector& dimensions) |
4902 | 108 { |
109 return ::compute_index (ra_idx, dimensions); | |
110 } | |
111 | |
4915 | 112 template <class T> |
5073 | 113 intNDArray<T> |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
114 intNDArray<T>::concat (const intNDArray<T>& rb, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
115 const Array<octave_idx_type>& ra_idx) |
5073 | 116 { |
6482 | 117 if (rb.numel () > 0) |
5073 | 118 insert (rb, ra_idx); |
119 return *this; | |
120 } | |
121 | |
122 template <class T> | |
4915 | 123 intNDArray<T>& |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
124 intNDArray<T>::insert (const intNDArray<T>& a, octave_idx_type r, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
125 octave_idx_type c) |
4915 | 126 { |
127 Array<T>::insert (a, r, c); | |
128 return *this; | |
129 } | |
130 | |
131 template <class T> | |
132 intNDArray<T>& | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
133 intNDArray<T>::insert (const intNDArray<T>& a, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
134 const Array<octave_idx_type>& ra_idx) |
4915 | 135 { |
136 Array<T>::insert (a, ra_idx); | |
137 return *this; | |
138 } | |
139 | |
4902 | 140 // This contains no information on the array structure !!! |
141 | |
142 template <class T> | |
143 std::ostream& | |
144 operator << (std::ostream& os, const intNDArray<T>& a) | |
145 { | |
20438
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
146 octave_idx_type nel = a.numel (); |
4902 | 147 |
5275 | 148 for (octave_idx_type i = 0; i < nel; i++) |
4902 | 149 os << " " << a.elem (i) << "\n"; |
150 | |
151 return os; | |
152 } | |
153 | |
154 template <class T> | |
155 std::istream& | |
156 operator >> (std::istream& is, intNDArray<T>& a) | |
157 { | |
20438
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
158 octave_idx_type nel = a.numel (); |
4902 | 159 |
8999
dc07bc4157b8
allow empty matrices in stream input operators
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
160 if (nel > 0) |
4902 | 161 { |
162 T tmp; | |
163 | |
5275 | 164 for (octave_idx_type i = 0; i < nel; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
165 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
166 is >> tmp; |
4902 | 167 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
168 if (is) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
169 a.elem (i) = tmp; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
170 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
171 goto done; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
172 } |
4902 | 173 } |
174 | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
175 done: |
4902 | 176 |
177 return is; | |
178 } | |
179 | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
180 // FIXME: should abs and signum just be mapper functions? |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
181 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
182 template <class T> |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
183 intNDArray<T> |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
184 intNDArray<T>::abs (void) const |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
185 { |
20438
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
186 octave_idx_type nel = this->numel (); |
10577
87f879cf48fd
don't alter arg values in call to abs or sign for integer values
John W. Eaton <jwe@octave.org>
parents:
10362
diff
changeset
|
187 intNDArray<T> ret (this->dims ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
188 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
189 for (octave_idx_type i = 0; i < nel; i++) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
190 { |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
191 T val = this->elem (i); |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
192 ret.xelem (i) = val.abs (); |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
193 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
194 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
195 return ret; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
196 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
197 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
198 template <class T> |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
199 intNDArray<T> |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
200 intNDArray<T>::signum (void) const |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
201 { |
20438
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19898
diff
changeset
|
202 octave_idx_type nel = this->numel (); |
10577
87f879cf48fd
don't alter arg values in call to abs or sign for integer values
John W. Eaton <jwe@octave.org>
parents:
10362
diff
changeset
|
203 intNDArray<T> ret (this->dims ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
204 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
205 for (octave_idx_type i = 0; i < nel; i++) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
206 { |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
207 T val = this->elem (i); |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
208 ret.xelem (i) = val.signum (); |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
209 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
210 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
211 return ret; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
212 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7457
diff
changeset
|
213 |
7113 | 214 template <class T> |
215 intNDArray<T> | |
18890
8cc66f091584
Add "native" option to prod() (bug #40349).
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
216 intNDArray<T>::prod (int dim) const |
8cc66f091584
Add "native" option to prod() (bug #40349).
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
217 { |
8cc66f091584
Add "native" option to prod() (bug #40349).
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
218 return do_mx_red_op<T, T> (*this, dim, mx_inline_prod); |
8cc66f091584
Add "native" option to prod() (bug #40349).
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
219 } |
8cc66f091584
Add "native" option to prod() (bug #40349).
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
220 |
8cc66f091584
Add "native" option to prod() (bug #40349).
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
221 template <class T> |
8cc66f091584
Add "native" option to prod() (bug #40349).
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
222 intNDArray<T> |
7113 | 223 intNDArray<T>::sum (int dim) const |
224 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
225 return do_mx_red_op<T, T> (*this, dim, mx_inline_sum); |
7113 | 226 } |
227 | |
7189 | 228 template <class T> |
9721
192d94cff6c1
improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
229 NDArray |
192d94cff6c1
improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
230 intNDArray<T>::dsum (int dim) const |
192d94cff6c1
improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
231 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
232 return do_mx_red_op<double, T> (*this, dim, mx_inline_dsum); |
9721
192d94cff6c1
improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
233 } |
192d94cff6c1
improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
234 |
192d94cff6c1
improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
235 template <class T> |
7189 | 236 intNDArray<T> |
8780
ea76466605ba
support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents:
8777
diff
changeset
|
237 intNDArray<T>::cumsum (int dim) const |
ea76466605ba
support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents:
8777
diff
changeset
|
238 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
239 return do_mx_cum_op<T, T> (*this, dim, mx_inline_cumsum); |
8780
ea76466605ba
support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents:
8777
diff
changeset
|
240 } |
ea76466605ba
support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents:
8777
diff
changeset
|
241 |
ea76466605ba
support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents:
8777
diff
changeset
|
242 template <class T> |
ea76466605ba
support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents:
8777
diff
changeset
|
243 intNDArray<T> |
7189 | 244 intNDArray<T>::max (int dim) const |
245 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
246 return do_mx_minmax_op<T> (*this, dim, mx_inline_max); |
7189 | 247 } |
248 | |
249 template <class T> | |
250 intNDArray<T> | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9721
diff
changeset
|
251 intNDArray<T>::max (Array<octave_idx_type>& idx_arg, int dim) const |
7189 | 252 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
253 return do_mx_minmax_op<T> (*this, idx_arg, dim, mx_inline_max); |
7189 | 254 } |
255 | |
256 template <class T> | |
257 intNDArray<T> | |
258 intNDArray<T>::min (int dim) const | |
259 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
260 return do_mx_minmax_op<T> (*this, dim, mx_inline_min); |
7189 | 261 } |
262 | |
263 template <class T> | |
264 intNDArray<T> | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9721
diff
changeset
|
265 intNDArray<T>::min (Array<octave_idx_type>& idx_arg, int dim) const |
7189 | 266 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
267 return do_mx_minmax_op<T> (*this, idx_arg, dim, mx_inline_min); |
7189 | 268 } |
269 | |
8777
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
270 template <class T> |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
271 intNDArray<T> |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
272 intNDArray<T>::cummax (int dim) const |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
273 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
274 return do_mx_cumminmax_op<T> (*this, dim, mx_inline_cummax); |
8777
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
275 } |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
276 |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
277 template <class T> |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
278 intNDArray<T> |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9721
diff
changeset
|
279 intNDArray<T>::cummax (Array<octave_idx_type>& idx_arg, int dim) const |
8777
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
280 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
281 return do_mx_cumminmax_op<T> (*this, idx_arg, dim, mx_inline_cummax); |
8777
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
282 } |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
283 |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
284 template <class T> |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
285 intNDArray<T> |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
286 intNDArray<T>::cummin (int dim) const |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
287 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
288 return do_mx_cumminmax_op<T> (*this, dim, mx_inline_cummin); |
8777
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
289 } |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
290 |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
291 template <class T> |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
292 intNDArray<T> |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9721
diff
changeset
|
293 intNDArray<T>::cummin (Array<octave_idx_type>& idx_arg, int dim) const |
8777
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
294 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
295 return do_mx_cumminmax_op<T> (*this, idx_arg, dim, mx_inline_cummin); |
8777
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
296 } |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
297 |
9513
9f870f73ab7d
implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents:
9227
diff
changeset
|
298 template <class T> |
9f870f73ab7d
implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents:
9227
diff
changeset
|
299 intNDArray<T> |
9f870f73ab7d
implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents:
9227
diff
changeset
|
300 intNDArray<T>::diff (octave_idx_type order, int dim) const |
9f870f73ab7d
implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents:
9227
diff
changeset
|
301 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
302 return do_mx_diff_op<T> (*this, dim, order, mx_inline_diff); |
9513
9f870f73ab7d
implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents:
9227
diff
changeset
|
303 } |