Mercurial > octave
annotate liboctave/array/Array.h @ 21244:1473547f50f5
include octave-config.h in public header files
* mk-opts.pl, mkbuiltins, mk-ops.awk, sparse-mk-ops.awk:
Emit "#include octave-config.h" statement for generated header files.
* build-env.h, builtins.h, Cell.h, base-text-renderer.h,
c-file-ptr-stream.h, cdisplay.h, comment-list.h, data.h, debug.h,
defaults.in.h, defun-dld.h, defun-int.h, defun.h, dirfns.h, display.h,
dynamic-ld.h, error.h, errwarn.h, event-queue.h, file-io.h,
ft-text-renderer.h, gl-render.h, gl2ps-print.h, graphics.in.h,
gripes.h, help.h, hook-fcn.h, input.h, jit-ir.h, jit-typeinfo.h,
jit-util.h, load-path.h, load-save.h, ls-ascii-helper.h, ls-hdf5.h,
ls-mat-ascii.h, ls-mat4.h, ls-mat5.h, ls-oct-binary.h, ls-oct-text.h,
ls-utils.h, mex.h, mexproto.h, mxarray.in.h, oct-errno.h, oct-fstrm.h,
oct-handle.h, oct-hdf5-types.h, oct-hdf5.h, oct-hist.h, oct-iostrm.h,
oct-lvalue.h, oct-map.h, oct-obj.h, oct-opengl.h, oct-prcstrm.h,
oct-procbuf.h, oct-stdstrm.h, oct-stream.h, oct-strstrm.h, oct.h,
octave-default-image.h, octave-link.h, octave-preserve-stream-state.h,
pager.h, pr-output.h, procstream.h, profiler.h, pt-jit.h,
sighandlers.h, siglist.h, sparse-xdiv.h, sparse-xpow.h, symtab.h,
sysdep.h, text-renderer.h, toplev.h, txt-eng.h, utils.h, variables.h,
workspace-element.h, xdiv.h, xnorm.h, xpow.h, zfstream.h, oct-qhull.h,
ov-base-diag.h, ov-base-int.h, ov-base-mat.h, ov-base-scalar.h,
ov-base-sparse.h, ov-base.h, ov-bool-mat.h, ov-bool-sparse.h,
ov-bool.h, ov-builtin.h, ov-cell.h, ov-ch-mat.h, ov-class.h,
ov-classdef.h, ov-colon.h, ov-complex.h, ov-cs-list.h, ov-cx-diag.h,
ov-cx-mat.h, ov-cx-sparse.h, ov-dld-fcn.h, ov-fcn-handle.h,
ov-fcn-inline.h, ov-fcn.h, ov-float.h, ov-flt-complex.h,
ov-flt-cx-diag.h, ov-flt-cx-mat.h, ov-flt-re-diag.h, ov-flt-re-mat.h,
ov-int-traits.h, ov-int16.h, ov-int32.h, ov-int64.h, ov-int8.h,
ov-intx.h, ov-java.h, ov-lazy-idx.h, ov-mex-fcn.h, ov-null-mat.h,
ov-oncleanup.h, ov-perm.h, ov-range.h, ov-re-diag.h, ov-re-mat.h,
ov-re-sparse.h, ov-scalar.h, ov-str-mat.h, ov-struct.h,
ov-type-conv.h, ov-typeinfo.h, ov-uint16.h, ov-uint32.h, ov-uint64.h,
ov-uint8.h, ov-usr-fcn.h, ov.h, ovl.h, octave.h, op-int.h, ops.h,
options-usage.h, lex.h, parse.h, pt-all.h, pt-arg-list.h,
pt-array-list.h, pt-assign.h, pt-binop.h, pt-bp.h, pt-cbinop.h,
pt-cell.h, pt-check.h, pt-classdef.h, pt-cmd.h, pt-colon.h,
pt-const.h, pt-decl.h, pt-eval.h, pt-except.h, pt-exp.h,
pt-fcn-handle.h, pt-funcall.h, pt-id.h, pt-idx.h, pt-jump.h,
pt-loop.h, pt-mat.h, pt-misc.h, pt-pr-code.h, pt-select.h, pt-stmt.h,
pt-unop.h, pt-walk.h, pt.h, token.h, version.in.h, Array-util.h,
Array.h, CColVector.h, CDiagMatrix.h, CMatrix.h, CNDArray.h,
CRowVector.h, CSparse.h, DiagArray2.h, MArray.h, MDiagArray2.h,
MSparse.h, Matrix.h, MatrixType.h, PermMatrix.h, Range.h, Sparse.h,
boolMatrix.h, boolNDArray.h, boolSparse.h, chMatrix.h, chNDArray.h,
dColVector.h, dDiagMatrix.h, dMatrix.h, dNDArray.h, dRowVector.h,
dSparse.h, dim-vector.h, fCColVector.h, fCDiagMatrix.h, fCMatrix.h,
fCNDArray.h, fCRowVector.h, fColVector.h, fDiagMatrix.h, fMatrix.h,
fNDArray.h, fRowVector.h, idx-vector.h, int16NDArray.h,
int32NDArray.h, int64NDArray.h, int8NDArray.h, intNDArray.h,
uint16NDArray.h, uint32NDArray.h, uint64NDArray.h, uint8NDArray.h,
f77-fcn.h, lo-error.h, quit.h, CmplxAEPBAL.h, CmplxCHOL.h,
CmplxGEPBAL.h, CmplxHESS.h, CmplxLU.h, CmplxQR.h, CmplxQRP.h,
CmplxSCHUR.h, CmplxSVD.h, CollocWt.h, DAE.h, DAEFunc.h, DAERT.h,
DAERTFunc.h, DASPK.h, DASRT.h, DASSL.h, DET.h, EIG.h, LSODE.h, ODE.h,
ODEFunc.h, ODES.h, ODESFunc.h, Quad.h, base-aepbal.h, base-dae.h,
base-de.h, base-lu.h, base-min.h, base-qr.h, bsxfun-decl.h, bsxfun.h,
dbleAEPBAL.h, dbleCHOL.h, dbleGEPBAL.h, dbleHESS.h, dbleLU.h,
dbleQR.h, dbleQRP.h, dbleSCHUR.h, dbleSVD.h, eigs-base.h,
fCmplxAEPBAL.h, fCmplxCHOL.h, fCmplxGEPBAL.h, fCmplxHESS.h,
fCmplxLU.h, fCmplxQR.h, fCmplxQRP.h, fCmplxSCHUR.h, fCmplxSVD.h,
fEIG.h, floatAEPBAL.h, floatCHOL.h, floatGEPBAL.h, floatHESS.h,
floatLU.h, floatQR.h, floatQRP.h, floatSCHUR.h, floatSVD.h,
lo-mappers.h, lo-specfun.h, oct-convn.h, oct-fftw.h, oct-norm.h,
oct-rand.h, oct-spparms.h, randgamma.h, randmtzig.h, randpoisson.h,
sparse-chol.h, sparse-dmsolve.h, sparse-lu.h, sparse-qr.h,
Sparse-diag-op-defs.h, Sparse-op-decls.h, Sparse-op-defs.h,
Sparse-perm-op-defs.h, mx-base.h, mx-defs.h, mx-ext.h, mx-op-decl.h,
mx-op-defs.h, dir-ops.h, file-ops.h, file-stat.h, lo-sysdep.h,
mach-info.h, oct-env.h, oct-group.h, oct-openmp.h, oct-passwd.h,
oct-syscalls.h, oct-time.h, oct-uname.h, pathlen.h, sysdir.h,
syswait.h, action-container.h, base-list.h, byte-swap.h,
caseless-str.h, cmd-edit.h, cmd-hist.h, data-conv.h, functor.h,
glob-match.h, lo-array-errwarn.h, lo-array-gripes.h, lo-cutils.h,
lo-ieee.h, lo-macros.h, lo-math.h, lo-regexp.h, lo-traits.h,
lo-utils.h, oct-alloc.h, oct-base64.h, oct-binmap.h, oct-cmplx.h,
oct-glob.h, oct-inttypes.h, oct-locbuf.h, oct-mutex.h, oct-refcount.h,
oct-rl-edit.h, oct-rl-hist.h, oct-shlib.h, oct-sort.h, oct-sparse.h,
pathsearch.h, singleton-cleanup.h, sparse-sort.h, sparse-util.h,
statdefs.h, str-vec.h, sun-utils.h, unwind-prot.h, url-transfer.h:
Include octave-config.h.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 10 Feb 2016 14:25:53 -0500 |
parents | a83e7a384ee0 |
children | 3d25f9f4a62b |
rev | line source |
---|---|
1993 | 1 // Template array classes |
228 | 2 /* |
3 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19381
diff
changeset
|
4 Copyright (C) 1993-2015 John W. Eaton |
11523 | 5 Copyright (C) 2008-2009 Jaroslav Hajek |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10366
diff
changeset
|
6 Copyright (C) 2010 VZLU Prague |
228 | 7 |
8 This file is part of Octave. | |
9 | |
10 Octave is free software; you can redistribute it and/or modify it | |
11 under the terms of the GNU General Public License as published by the | |
7016 | 12 Free Software Foundation; either version 3 of the License, or (at your |
13 option) any later version. | |
228 | 14 |
15 Octave is distributed in the hope that it will be useful, but WITHOUT | |
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
18 for more details. | |
19 | |
20 You should have received a copy of the GNU General Public License | |
7016 | 21 along with Octave; see the file COPYING. If not, see |
22 <http://www.gnu.org/licenses/>. | |
228 | 23 |
24 */ | |
25 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
26 #if ! defined (octave_Array_h) |
382 | 27 #define octave_Array_h 1 |
28 | |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
29 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
30 |
1366 | 31 #include <cassert> |
4152 | 32 #include <cstddef> |
3613 | 33 |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8503
diff
changeset
|
34 #include <algorithm> |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
35 #include <iosfwd> |
3933 | 36 |
4513 | 37 #include "dim-vector.h" |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
38 #include "idx-vector.h" |
8725 | 39 #include "lo-traits.h" |
3613 | 40 #include "lo-utils.h" |
7433 | 41 #include "oct-sort.h" |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
42 #include "quit.h" |
12125
a21a3875ca83
implement a common class for reference counts
Jaroslav Hajek <highegg@gmail.com>
parents:
11586
diff
changeset
|
43 #include "oct-refcount.h" |
7433 | 44 |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
45 //! Handles the reference counting for all the derived classes. |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
46 template <typename T> |
3585 | 47 class |
48 Array | |
228 | 49 { |
3504 | 50 protected: |
1619 | 51 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
52 //! The real representation of all arrays. |
1735 | 53 class ArrayRep |
54 { | |
55 public: | |
56 | |
57 T *data; | |
5275 | 58 octave_idx_type len; |
12125
a21a3875ca83
implement a common class for reference counts
Jaroslav Hajek <highegg@gmail.com>
parents:
11586
diff
changeset
|
59 octave_refcount<int> count; |
1735 | 60 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
61 ArrayRep (T *d, octave_idx_type l) |
19381
af41e41ad28e
replace oct-mem.h inline indirections by standard function calls.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19330
diff
changeset
|
62 : data (new T [l]), len (l), count (1) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
63 { |
19381
af41e41ad28e
replace oct-mem.h inline indirections by standard function calls.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19330
diff
changeset
|
64 std::copy (d, d+l, data); |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
65 } |
10364
96ed7c629bbd
remove dangerous pointer-acquiring Array ctors
Jaroslav Hajek <highegg@gmail.com>
parents:
10358
diff
changeset
|
66 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
67 template <typename U> |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
68 ArrayRep (U *d, octave_idx_type l) |
19381
af41e41ad28e
replace oct-mem.h inline indirections by standard function calls.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19330
diff
changeset
|
69 : data (new T [l]), len (l), count (1) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
70 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
71 std::copy (d, d+l, data); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
72 } |
1735 | 73 |
74 ArrayRep (void) : data (0), len (0), count (1) { } | |
75 | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
76 explicit ArrayRep (octave_idx_type n) |
19381
af41e41ad28e
replace oct-mem.h inline indirections by standard function calls.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19330
diff
changeset
|
77 : data (new T [n]), len (n), count (1) { } |
1735 | 78 |
5275 | 79 explicit ArrayRep (octave_idx_type n, const T& val) |
19381
af41e41ad28e
replace oct-mem.h inline indirections by standard function calls.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19330
diff
changeset
|
80 : data (new T [n]), len (n), count (1) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
81 { |
19381
af41e41ad28e
replace oct-mem.h inline indirections by standard function calls.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19330
diff
changeset
|
82 std::fill_n (data, n, val); |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
83 } |
4513 | 84 |
1735 | 85 ArrayRep (const ArrayRep& a) |
19381
af41e41ad28e
replace oct-mem.h inline indirections by standard function calls.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19330
diff
changeset
|
86 : data (new T [a.len]), len (a.len), count (1) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
87 { |
19381
af41e41ad28e
replace oct-mem.h inline indirections by standard function calls.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19330
diff
changeset
|
88 std::copy (a.data, a.data + a.len, data); |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
89 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
90 |
19381
af41e41ad28e
replace oct-mem.h inline indirections by standard function calls.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19330
diff
changeset
|
91 ~ArrayRep (void) { delete [] data; } |
1735 | 92 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20229
diff
changeset
|
93 octave_idx_type numel (void) const { return len; } |
1735 | 94 |
4517 | 95 private: |
96 | |
97 // No assignment! | |
98 | |
99 ArrayRep& operator = (const ArrayRep& a); | |
1735 | 100 }; |
101 | |
4513 | 102 //-------------------------------------------------------------------- |
103 | |
6884 | 104 public: |
105 | |
9556
948795dc1974
make a few Array methods inline
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
106 void make_unique (void) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
107 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
108 if (rep->count > 1) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
109 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
110 ArrayRep *r = new ArrayRep (slice_data, slice_len); |
13985
43cc49c7abd1
Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
12125
diff
changeset
|
111 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
112 if (--rep->count == 0) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
113 delete rep; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
114 |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
115 rep = r; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
116 slice_data = rep->data; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
117 } |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
118 } |
238 | 119 |
5900 | 120 typedef T element_type; |
121 | |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9921
diff
changeset
|
122 typedef typename ref_param<T>::type crefT; |
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9921
diff
changeset
|
123 |
8725 | 124 typedef bool (*compare_fcn_type) (typename ref_param<T>::type, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
125 typename ref_param<T>::type); |
8725 | 126 |
8524
937921654627
clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
127 protected: |
4902 | 128 |
11507
c3ad80f4ce36
Array.h, Array.cc: more constructor fixes
John W. Eaton <jwe@octave.org>
parents:
11010
diff
changeset
|
129 dim_vector dimensions; |
4518 | 130 |
11507
c3ad80f4ce36
Array.h, Array.cc: more constructor fixes
John W. Eaton <jwe@octave.org>
parents:
11010
diff
changeset
|
131 typename Array<T>::ArrayRep *rep; |
4513 | 132 |
8531
b01fef323c24
add some explaining comments
Jaroslav Hajek <highegg@gmail.com>
parents:
8524
diff
changeset
|
133 // Rationale: |
b01fef323c24
add some explaining comments
Jaroslav Hajek <highegg@gmail.com>
parents:
8524
diff
changeset
|
134 // slice_data is a pointer to rep->data, denoting together with slice_len the |
b01fef323c24
add some explaining comments
Jaroslav Hajek <highegg@gmail.com>
parents:
8524
diff
changeset
|
135 // actual portion of the data referenced by this Array<T> object. This allows |
b01fef323c24
add some explaining comments
Jaroslav Hajek <highegg@gmail.com>
parents:
8524
diff
changeset
|
136 // to make shallow copies not only of a whole array, but also of contiguous |
b01fef323c24
add some explaining comments
Jaroslav Hajek <highegg@gmail.com>
parents:
8524
diff
changeset
|
137 // subranges. Every time rep is directly manipulated, slice_data and slice_len |
b01fef323c24
add some explaining comments
Jaroslav Hajek <highegg@gmail.com>
parents:
8524
diff
changeset
|
138 // need to be properly updated. |
b01fef323c24
add some explaining comments
Jaroslav Hajek <highegg@gmail.com>
parents:
8524
diff
changeset
|
139 |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8503
diff
changeset
|
140 T* slice_data; |
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8503
diff
changeset
|
141 octave_idx_type slice_len; |
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8503
diff
changeset
|
142 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
143 //! slice constructor |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8503
diff
changeset
|
144 Array (const Array<T>& a, const dim_vector& dv, |
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8503
diff
changeset
|
145 octave_idx_type l, octave_idx_type u) |
11507
c3ad80f4ce36
Array.h, Array.cc: more constructor fixes
John W. Eaton <jwe@octave.org>
parents:
11010
diff
changeset
|
146 : dimensions (dv), rep(a.rep), slice_data (a.slice_data+l), slice_len (u-l) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
147 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
148 rep->count++; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
149 dimensions.chop_trailing_singletons (); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
150 } |
4513 | 151 |
152 private: | |
153 | |
4585 | 154 typename Array<T>::ArrayRep *nil_rep (void) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
155 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
156 // NR was originally allocated with new, but that does not seem |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
157 // to be necessary since it will never be deleted. So just use |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
158 // a static object instead. |
4513 | 159 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
160 static typename Array<T>::ArrayRep nr; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
161 return &nr; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
162 } |
238 | 163 |
14951
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14616
diff
changeset
|
164 protected: |
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14616
diff
changeset
|
165 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
166 //! For jit support |
14951
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14616
diff
changeset
|
167 Array (T *sdata, octave_idx_type slen, octave_idx_type *adims, void *arep) |
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14616
diff
changeset
|
168 : dimensions (adims), |
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14616
diff
changeset
|
169 rep (reinterpret_cast<typename Array<T>::ArrayRep *> (arep)), |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
170 slice_data (sdata), slice_len (slen) { } |
14951
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14616
diff
changeset
|
171 |
228 | 172 public: |
238 | 173 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
174 //! Empty ctor (0 by 0). |
1550 | 175 Array (void) |
11507
c3ad80f4ce36
Array.h, Array.cc: more constructor fixes
John W. Eaton <jwe@octave.org>
parents:
11010
diff
changeset
|
176 : dimensions (), rep (nil_rep ()), slice_data (rep->data), |
c3ad80f4ce36
Array.h, Array.cc: more constructor fixes
John W. Eaton <jwe@octave.org>
parents:
11010
diff
changeset
|
177 slice_len (rep->len) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
178 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
179 rep->count++; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
180 } |
1550 | 181 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
182 //! nD uninitialized ctor. |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
183 explicit Array (const dim_vector& dv) |
11507
c3ad80f4ce36
Array.h, Array.cc: more constructor fixes
John W. Eaton <jwe@octave.org>
parents:
11010
diff
changeset
|
184 : dimensions (dv), |
c3ad80f4ce36
Array.h, Array.cc: more constructor fixes
John W. Eaton <jwe@octave.org>
parents:
11010
diff
changeset
|
185 rep (new typename Array<T>::ArrayRep (dv.safe_numel ())), |
c3ad80f4ce36
Array.h, Array.cc: more constructor fixes
John W. Eaton <jwe@octave.org>
parents:
11010
diff
changeset
|
186 slice_data (rep->data), slice_len (rep->len) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
187 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
188 dimensions.chop_trailing_singletons (); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
189 } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
190 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
191 //! nD initialized ctor. |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
192 explicit Array (const dim_vector& dv, const T& val) |
11507
c3ad80f4ce36
Array.h, Array.cc: more constructor fixes
John W. Eaton <jwe@octave.org>
parents:
11010
diff
changeset
|
193 : dimensions (dv), |
c3ad80f4ce36
Array.h, Array.cc: more constructor fixes
John W. Eaton <jwe@octave.org>
parents:
11010
diff
changeset
|
194 rep (new typename Array<T>::ArrayRep (dv.safe_numel ())), |
c3ad80f4ce36
Array.h, Array.cc: more constructor fixes
John W. Eaton <jwe@octave.org>
parents:
11010
diff
changeset
|
195 slice_data (rep->data), slice_len (rep->len) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
196 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
197 fill (val); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
198 dimensions.chop_trailing_singletons (); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
199 } |
4513 | 200 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
201 //! Reshape constructor. |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
202 Array (const Array<T>& a, const dim_vector& dv); |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
203 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
204 //! Type conversion case. |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
205 template <typename U> |
4902 | 206 Array (const Array<U>& a) |
11507
c3ad80f4ce36
Array.h, Array.cc: more constructor fixes
John W. Eaton <jwe@octave.org>
parents:
11010
diff
changeset
|
207 : dimensions (a.dims ()), |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20229
diff
changeset
|
208 rep (new typename Array<T>::ArrayRep (a.data (), a.numel ())), |
11507
c3ad80f4ce36
Array.h, Array.cc: more constructor fixes
John W. Eaton <jwe@octave.org>
parents:
11010
diff
changeset
|
209 slice_data (rep->data), slice_len (rep->len) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
210 { } |
4902 | 211 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
212 //! No type conversion case. |
4513 | 213 Array (const Array<T>& a) |
11507
c3ad80f4ce36
Array.h, Array.cc: more constructor fixes
John W. Eaton <jwe@octave.org>
parents:
11010
diff
changeset
|
214 : dimensions (a.dimensions), rep (a.rep), slice_data (a.slice_data), |
c3ad80f4ce36
Array.h, Array.cc: more constructor fixes
John W. Eaton <jwe@octave.org>
parents:
11010
diff
changeset
|
215 slice_len (a.slice_len) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
216 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
217 rep->count++; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
218 } |
1550 | 219 |
4513 | 220 public: |
221 | |
15216
dd7c37ceb800
avoid GCC warning by declaring Array destructor virtual
John W. Eaton <jwe@octave.org>
parents:
15212
diff
changeset
|
222 virtual ~Array (void) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
223 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
224 if (--rep->count == 0) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
225 delete rep; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
226 } |
228 | 227 |
9556
948795dc1974
make a few Array methods inline
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
228 Array<T>& operator = (const Array<T>& a) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
229 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
230 if (this != &a) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
231 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
232 if (--rep->count == 0) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
233 delete rep; |
9556
948795dc1974
make a few Array methods inline
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
234 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
235 rep = a.rep; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
236 rep->count++; |
9556
948795dc1974
make a few Array methods inline
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
237 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
238 dimensions = a.dimensions; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
239 slice_data = a.slice_data; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
240 slice_len = a.slice_len; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
241 } |
9556
948795dc1974
make a few Array methods inline
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
242 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
243 return *this; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
244 } |
4513 | 245 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
246 void fill (const T& val); |
9624
3fc7272937ce
implement Array<T>::clear overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
9556
diff
changeset
|
247 |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9341
diff
changeset
|
248 void clear (void); |
9624
3fc7272937ce
implement Array<T>::clear overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
9556
diff
changeset
|
249 void clear (const dim_vector& dv); |
3fc7272937ce
implement Array<T>::clear overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
9556
diff
changeset
|
250 |
3fc7272937ce
implement Array<T>::clear overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
9556
diff
changeset
|
251 void clear (octave_idx_type r, octave_idx_type c) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
252 { clear (dim_vector (r, c)); } |
238 | 253 |
20212
6af35d4f1ba4
doxygen: document Array::length() and similar methods (bug #45138)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
254 // Number of elements in the array. These are all synonyms. |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
255 //@{ |
20212
6af35d4f1ba4
doxygen: document Array::length() and similar methods (bug #45138)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
256 //! Number of elements in the array. |
20228
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20212
diff
changeset
|
257 //! Synonymous with numel(). |
20229
5dfaaaae784f
Deprecate Array::capacity() and Sparse::capacity() for numel() and nzmax().
Carnë Draug <carandraug@octave.org>
parents:
20228
diff
changeset
|
258 //! @note This method is deprecated in favour of numel(). |
21134
2e5c1f766ac9
provide replacement hints for deprecated C++ functions
John W. Eaton <jwe@octave.org>
parents:
21131
diff
changeset
|
259 OCTAVE_DEPRECATED ("use 'numel' instead") |
2e5c1f766ac9
provide replacement hints for deprecated C++ functions
John W. Eaton <jwe@octave.org>
parents:
21131
diff
changeset
|
260 octave_idx_type capacity (void) const { return numel (); } |
20212
6af35d4f1ba4
doxygen: document Array::length() and similar methods (bug #45138)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
261 |
6af35d4f1ba4
doxygen: document Array::length() and similar methods (bug #45138)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
262 //! Number of elements in the array. |
20229
5dfaaaae784f
Deprecate Array::capacity() and Sparse::capacity() for numel() and nzmax().
Carnë Draug <carandraug@octave.org>
parents:
20228
diff
changeset
|
263 /*! Synonymous with numel(). |
20228
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20212
diff
changeset
|
264 @note This method is deprecated in favour of numel(). |
20212
6af35d4f1ba4
doxygen: document Array::length() and similar methods (bug #45138)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
265 |
6af35d4f1ba4
doxygen: document Array::length() and similar methods (bug #45138)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
266 @note |
6af35d4f1ba4
doxygen: document Array::length() and similar methods (bug #45138)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
267 This is @em not the same as @c %length() at the Octave interpreter. |
6af35d4f1ba4
doxygen: document Array::length() and similar methods (bug #45138)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
268 At the Octave interpreter, the function @c %length() returns the |
6af35d4f1ba4
doxygen: document Array::length() and similar methods (bug #45138)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
269 length of the greatest dimension. This method returns the total |
6af35d4f1ba4
doxygen: document Array::length() and similar methods (bug #45138)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
270 number of elements. |
6af35d4f1ba4
doxygen: document Array::length() and similar methods (bug #45138)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
271 */ |
21134
2e5c1f766ac9
provide replacement hints for deprecated C++ functions
John W. Eaton <jwe@octave.org>
parents:
21131
diff
changeset
|
272 OCTAVE_DEPRECATED ("use 'numel' instead") |
2e5c1f766ac9
provide replacement hints for deprecated C++ functions
John W. Eaton <jwe@octave.org>
parents:
21131
diff
changeset
|
273 octave_idx_type length (void) const { return numel (); } |
20212
6af35d4f1ba4
doxygen: document Array::length() and similar methods (bug #45138)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
274 |
6af35d4f1ba4
doxygen: document Array::length() and similar methods (bug #45138)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
275 //! Number of elements in the array. |
20229
5dfaaaae784f
Deprecate Array::capacity() and Sparse::capacity() for numel() and nzmax().
Carnë Draug <carandraug@octave.org>
parents:
20228
diff
changeset
|
276 //! Synonymous with numel(). |
20228
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20212
diff
changeset
|
277 //! @note This method is deprecated in favour of numel(). |
21134
2e5c1f766ac9
provide replacement hints for deprecated C++ functions
John W. Eaton <jwe@octave.org>
parents:
21131
diff
changeset
|
278 OCTAVE_DEPRECATED ("use 'numel' instead") |
2e5c1f766ac9
provide replacement hints for deprecated C++ functions
John W. Eaton <jwe@octave.org>
parents:
21131
diff
changeset
|
279 octave_idx_type nelem (void) const { return numel (); } |
20212
6af35d4f1ba4
doxygen: document Array::length() and similar methods (bug #45138)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
280 |
6af35d4f1ba4
doxygen: document Array::length() and similar methods (bug #45138)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
281 //! Number of elements in the array. |
20228
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20212
diff
changeset
|
282 octave_idx_type numel (void) const { return slice_len; } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
283 //@} |
4513 | 284 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
285 //! Return the array as a column vector. |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
286 Array<T> as_column (void) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
287 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
288 Array<T> retval (*this); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
289 if (dimensions.length () != 2 || dimensions(1) != 1) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
290 retval.dimensions = dim_vector (numel (), 1); |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
291 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
292 return retval; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
293 } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
294 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
295 //! Return the array as a row vector. |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
296 Array<T> as_row (void) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
297 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
298 Array<T> retval (*this); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
299 if (dimensions.length () != 2 || dimensions(0) != 1) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
300 retval.dimensions = dim_vector (1, numel ()); |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
301 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
302 return retval; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
303 } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
304 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
305 //! Return the array as a matrix. |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
306 Array<T> as_matrix (void) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
307 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
308 Array<T> retval (*this); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
309 if (dimensions.length () != 2) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
310 retval.dimensions = dimensions.redim (2); |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
311 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
312 return retval; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
313 } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
314 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
315 //! @name First dimension |
19330
1f4455ff2329
Remove deprecated methods in liboctave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19326
diff
changeset
|
316 //! |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
317 //! Get the first dimension of the array (number of rows) |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
318 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
319 octave_idx_type dim1 (void) const { return dimensions(0); } |
5275 | 320 octave_idx_type rows (void) const { return dim1 (); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
321 //@} |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
322 |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
323 //! @name Second dimension |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
324 //! |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
325 //! Get the second dimension of the array (number of columns) |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
326 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
327 octave_idx_type dim2 (void) const { return dimensions(1); } |
5275 | 328 octave_idx_type cols (void) const { return dim2 (); } |
329 octave_idx_type columns (void) const { return dim2 (); } | |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
330 //@} |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
331 |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
332 //! @name Third dimension |
19330
1f4455ff2329
Remove deprecated methods in liboctave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19326
diff
changeset
|
333 //! |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
334 //! Get the third dimension of the array (number of pages) |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
335 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
336 octave_idx_type dim3 (void) const { return dimensions(2); } |
5275 | 337 octave_idx_type pages (void) const { return dim3 (); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
338 //@} |
4513 | 339 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
340 size_t byte_size (void) const |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
341 { return static_cast<size_t> (numel ()) * sizeof (T); } |
4902 | 342 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
343 //! Return a const-reference so that dims ()(i) works efficiently. |
9026
6890d411a0b8
adjust some array dim query methods
Jaroslav Hajek <highegg@gmail.com>
parents:
9025
diff
changeset
|
344 const dim_vector& dims (void) const { return dimensions; } |
4513 | 345 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
346 //! Chop off leading singleton dimensions |
4532 | 347 Array<T> squeeze (void) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
348 |
10366
e5ae13b8b2c2
improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents:
10364
diff
changeset
|
349 octave_idx_type compute_index (octave_idx_type i, octave_idx_type j) const; |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
350 octave_idx_type compute_index (octave_idx_type i, octave_idx_type j, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
351 octave_idx_type k) const; |
5275 | 352 octave_idx_type compute_index (const Array<octave_idx_type>& ra_idx) const; |
4517 | 353 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
354 octave_idx_type compute_index_unchecked (const Array<octave_idx_type>& ra_idx) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
355 const |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20229
diff
changeset
|
356 { return dimensions.compute_index (ra_idx.data (), ra_idx.numel ()); } |
10645
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10636
diff
changeset
|
357 |
2108 | 358 // No checking, even for multiple references, ever. |
359 | |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14981
diff
changeset
|
360 T& xelem (octave_idx_type n) { return slice_data[n]; } |
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14981
diff
changeset
|
361 crefT xelem (octave_idx_type n) const { return slice_data[n]; } |
2108 | 362 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
363 T& xelem (octave_idx_type i, octave_idx_type j) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
364 { return xelem (dim1 ()*j+i); } |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
365 crefT xelem (octave_idx_type i, octave_idx_type j) const |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
366 { return xelem (dim1 ()*j+i); } |
4513 | 367 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
368 T& xelem (octave_idx_type i, octave_idx_type j, octave_idx_type k) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
369 { return xelem (i, dim2 ()*k+j); } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
370 crefT xelem (octave_idx_type i, octave_idx_type j, octave_idx_type k) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
371 { return xelem (i, dim2 ()*k+j); } |
4513 | 372 |
6867 | 373 T& xelem (const 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
|
374 { return xelem (compute_index_unchecked (ra_idx)); } |
4513 | 375 |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9921
diff
changeset
|
376 crefT xelem (const Array<octave_idx_type>& ra_idx) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
377 { return xelem (compute_index_unchecked (ra_idx)); } |
4513 | 378 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
379 // FIXME: would be nice to fix this so that we don't unnecessarily force |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
380 // a copy, but that is not so easy, and I see no clean way to do it. |
2006 | 381 |
10366
e5ae13b8b2c2
improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents:
10364
diff
changeset
|
382 T& checkelem (octave_idx_type n); |
e5ae13b8b2c2
improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents:
10364
diff
changeset
|
383 T& checkelem (octave_idx_type i, octave_idx_type j); |
e5ae13b8b2c2
improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents:
10364
diff
changeset
|
384 T& checkelem (octave_idx_type i, octave_idx_type j, octave_idx_type k); |
e5ae13b8b2c2
improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents:
10364
diff
changeset
|
385 T& checkelem (const Array<octave_idx_type>& ra_idx); |
4513 | 386 |
5275 | 387 T& elem (octave_idx_type n) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
388 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
389 make_unique (); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
390 return xelem (n); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
391 } |
2306 | 392 |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14616
diff
changeset
|
393 T& elem (octave_idx_type i, octave_idx_type j) { return elem (dim1 ()*j+i); } |
4513 | 394 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
395 T& elem (octave_idx_type i, octave_idx_type j, octave_idx_type k) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
396 { return elem (i, dim2 ()*k+j); } |
4513 | 397 |
6867 | 398 T& elem (const 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
|
399 { return Array<T>::elem (compute_index_unchecked (ra_idx)); } |
4513 | 400 |
21229
a83e7a384ee0
create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
401 #if defined (OCTAVE_ENABLE_BOUNDS_CHECK) |
5275 | 402 T& operator () (octave_idx_type n) { return checkelem (n); } |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
403 T& operator () (octave_idx_type i, octave_idx_type j) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
404 { return checkelem (i, j); } |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
405 T& operator () (octave_idx_type i, octave_idx_type j, octave_idx_type k) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
406 { return checkelem (i, j, k); } |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
407 T& operator () (const Array<octave_idx_type>& ra_idx) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
408 { return checkelem (ra_idx); } |
2306 | 409 #else |
5275 | 410 T& operator () (octave_idx_type n) { return elem (n); } |
411 T& operator () (octave_idx_type i, octave_idx_type j) { return elem (i, j); } | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
412 T& operator () (octave_idx_type i, octave_idx_type j, octave_idx_type k) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
413 { return elem (i, j, k); } |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
414 T& operator () (const Array<octave_idx_type>& ra_idx) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
415 { return elem (ra_idx); } |
2006 | 416 #endif |
417 | |
10366
e5ae13b8b2c2
improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents:
10364
diff
changeset
|
418 crefT checkelem (octave_idx_type n) const; |
e5ae13b8b2c2
improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents:
10364
diff
changeset
|
419 crefT checkelem (octave_idx_type i, octave_idx_type j) const; |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
420 crefT checkelem (octave_idx_type i, octave_idx_type j, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
421 octave_idx_type k) const; |
10366
e5ae13b8b2c2
improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents:
10364
diff
changeset
|
422 crefT checkelem (const Array<octave_idx_type>& ra_idx) const; |
4513 | 423 |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9921
diff
changeset
|
424 crefT elem (octave_idx_type n) const { return xelem (n); } |
2306 | 425 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
426 crefT elem (octave_idx_type i, octave_idx_type j) const |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
427 { return xelem (i, j); } |
4513 | 428 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
429 crefT elem (octave_idx_type i, octave_idx_type j, octave_idx_type k) const |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
430 { return xelem (i, j, k); } |
4513 | 431 |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9921
diff
changeset
|
432 crefT elem (const Array<octave_idx_type>& ra_idx) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
433 { return Array<T>::xelem (compute_index_unchecked (ra_idx)); } |
4513 | 434 |
21229
a83e7a384ee0
create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
435 #if defined (OCTAVE_ENABLE_BOUNDS_CHECK) |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9921
diff
changeset
|
436 crefT operator () (octave_idx_type n) const { return checkelem (n); } |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
437 crefT operator () (octave_idx_type i, octave_idx_type j) const |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
438 { return checkelem (i, j); } |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
439 crefT operator () (octave_idx_type i, octave_idx_type j, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
440 octave_idx_type k) const |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
441 { return checkelem (i, j, k); } |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
442 crefT operator () (const Array<octave_idx_type>& ra_idx) const |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
443 { return checkelem (ra_idx); } |
2006 | 444 #else |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9921
diff
changeset
|
445 crefT operator () (octave_idx_type n) const { return elem (n); } |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
446 crefT operator () (octave_idx_type i, octave_idx_type j) const |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
447 { return elem (i, j); } |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
448 crefT operator () (octave_idx_type i, octave_idx_type j, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
449 octave_idx_type k) const |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
450 { return elem (i, j, k); } |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
451 crefT operator () (const Array<octave_idx_type>& ra_idx) const |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
452 { return elem (ra_idx); } |
2006 | 453 #endif |
454 | |
9731 | 455 // Fast extractors. All of these produce shallow copies. |
21131
54527108599a
store more --enable-FEATURE info in octave_config_info
John W. Eaton <jwe@octave.org>
parents:
21040
diff
changeset
|
456 // Warning: none of these do check bounds, unless |
21229
a83e7a384ee0
create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
457 // OCTAVE_ENABLE_BOUNDS_CHECK is defined! |
9731 | 458 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
459 //! Extract column: A(:,k+1). |
9731 | 460 Array<T> column (octave_idx_type k) const; |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
461 //! Extract page: A(:,:,k+1). |
9731 | 462 Array<T> page (octave_idx_type k) const; |
463 | |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
464 //! Extract a slice from this array as a column vector: A(:)(lo+1:up). |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
465 //! Must be 0 <= lo && up <= numel. May be up < lo. |
9731 | 466 Array<T> linear_slice (octave_idx_type lo, octave_idx_type up) const; |
467 | |
10352 | 468 Array<T> reshape (octave_idx_type nr, octave_idx_type nc) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
469 { return Array<T> (*this, dim_vector (nr, nc)); } |
10352 | 470 |
9731 | 471 Array<T> reshape (const dim_vector& new_dims) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
472 { return Array<T> (*this, new_dims); } |
4567 | 473 |
5275 | 474 Array<T> permute (const Array<octave_idx_type>& vec, bool inv = false) const; |
475 Array<T> ipermute (const Array<octave_idx_type>& vec) const | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
476 { return permute (vec, true); } |
4593 | 477 |
4513 | 478 bool is_square (void) const { return (dim1 () == dim2 ()); } |
479 | |
4559 | 480 bool is_empty (void) const { return numel () == 0; } |
481 | |
9026
6890d411a0b8
adjust some array dim query methods
Jaroslav Hajek <highegg@gmail.com>
parents:
9025
diff
changeset
|
482 bool is_vector (void) const { return dimensions.is_vector (); } |
6890d411a0b8
adjust some array dim query methods
Jaroslav Hajek <highegg@gmail.com>
parents:
9025
diff
changeset
|
483 |
4513 | 484 Array<T> transpose (void) const; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7717
diff
changeset
|
485 Array<T> hermitian (T (*fcn) (const T&) = 0) const; |
238 | 486 |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8503
diff
changeset
|
487 const T *data (void) const { return slice_data; } |
228 | 488 |
3952 | 489 const T *fortran_vec (void) const { return data (); } |
490 | |
238 | 491 T *fortran_vec (void); |
1560 | 492 |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9341
diff
changeset
|
493 bool is_shared (void) { return rep->count > 1; } |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9341
diff
changeset
|
494 |
4513 | 495 int ndims (void) const { return dimensions.length (); } |
1560 | 496 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
497 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
498 //! Indexing without resizing. |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
499 Array<T> index (const idx_vector& i) const; |
1560 | 500 |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
501 Array<T> index (const idx_vector& i, const idx_vector& j) const; |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
502 |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
503 Array<T> index (const Array<idx_vector>& ia) const; |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
504 //@} |
1560 | 505 |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
506 virtual T resize_fill_value (void) const; |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
507 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
508 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
509 //! Resizing (with fill). |
19330
1f4455ff2329
Remove deprecated methods in liboctave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19326
diff
changeset
|
510 void resize2 (octave_idx_type nr, octave_idx_type nc, const T& rfv); |
1f4455ff2329
Remove deprecated methods in liboctave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19326
diff
changeset
|
511 void resize2 (octave_idx_type nr, octave_idx_type nc) |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
512 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
513 resize2 (nr, nc, resize_fill_value ()); |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
514 } |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
515 |
19330
1f4455ff2329
Remove deprecated methods in liboctave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19326
diff
changeset
|
516 void resize1 (octave_idx_type n, const T& rfv); |
1f4455ff2329
Remove deprecated methods in liboctave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19326
diff
changeset
|
517 void resize1 (octave_idx_type n) { resize1 (n, resize_fill_value ()); } |
1f4455ff2329
Remove deprecated methods in liboctave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19326
diff
changeset
|
518 |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
519 void resize (const dim_vector& dv, const T& rfv); |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
520 void resize (const dim_vector& dv) { resize (dv, resize_fill_value ()); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
521 //@} |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
522 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
523 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
524 //! Indexing with possible resizing and fill |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
525 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
526 // FIXME: this is really a corner case, that should better be |
8333 | 527 // handled directly in liboctinterp. |
3933 | 528 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
529 |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
530 Array<T> index (const idx_vector& i, bool resize_ok, const T& rfv) const; |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
531 Array<T> index (const idx_vector& i, bool resize_ok) const |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
532 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
533 return index (i, resize_ok, resize_fill_value ()); |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
534 } |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
535 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
536 Array<T> index (const idx_vector& i, const idx_vector& j, bool resize_ok, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
537 const T& rfv) const; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
538 Array<T> index (const idx_vector& i, const idx_vector& j, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
539 bool resize_ok) const |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
540 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
541 return index (i, j, resize_ok, resize_fill_value ()); |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
542 } |
4513 | 543 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
544 Array<T> index (const Array<idx_vector>& ia, bool resize_ok, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
545 const T& rfv) const; |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
546 Array<T> index (const Array<idx_vector>& ia, bool resize_ok) const |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
547 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
548 return index (ia, resize_ok, resize_fill_value ()); |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
549 } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
550 //@} |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
551 |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
552 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
553 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
554 //! Indexed assignment (always with resize & fill). |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
555 void assign (const idx_vector& i, const Array<T>& rhs, const T& rfv); |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
556 void assign (const idx_vector& i, const Array<T>& rhs) |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
557 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
558 assign (i, rhs, resize_fill_value ()); |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
559 } |
4513 | 560 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
561 void assign (const idx_vector& i, const idx_vector& j, const Array<T>& rhs, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
562 const T& rfv); |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
563 void assign (const idx_vector& i, const idx_vector& j, const Array<T>& rhs) |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
564 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
565 assign (i, j, rhs, resize_fill_value ()); |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
566 } |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
567 |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
568 void assign (const Array<idx_vector>& ia, const Array<T>& rhs, const T& rfv); |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
569 void assign (const Array<idx_vector>& ia, const Array<T>& rhs) |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
570 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
571 assign (ia, rhs, resize_fill_value ()); |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
572 } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
573 //@} |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
574 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
575 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
576 //! Deleting elements. |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
577 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
578 //! A(I) = [] (with a single subscript) |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
579 void delete_elements (const idx_vector& i); |
4530 | 580 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
581 //! A(:,...,I,...,:) = [] (>= 2 subscripts, one of them is non-colon) |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
582 void delete_elements (int dim, const idx_vector& i); |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
583 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
584 //! Dispatcher to the above two. |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
585 void delete_elements (const Array<idx_vector>& ia); |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
586 //@} |
4513 | 587 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
588 //! Insert an array into another at a specified position. If |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
589 //! size (a) is [d1 d2 ... dN] and idx is [i1 i2 ... iN], this |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
590 //! method is equivalent to x(i1:i1+d1-1, i2:i2+d2-1, ... , |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
591 //! iN:iN+dN-1) = a. |
10115
ed49cef7e005
simplify Array::insert methods
Jaroslav Hajek <highegg@gmail.com>
parents:
10095
diff
changeset
|
592 Array<T>& insert (const Array<T>& a, const Array<octave_idx_type>& idx); |
3928 | 593 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
594 //! This is just a special case for idx = [r c 0 ...] |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
595 Array<T>& insert (const Array<T>& a, octave_idx_type r, octave_idx_type c); |
3933 | 596 |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8503
diff
changeset
|
597 void maybe_economize (void) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
598 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
599 if (rep->count == 1 && slice_len != rep->len) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
600 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
601 ArrayRep *new_rep = new ArrayRep (slice_data, slice_len); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
602 delete rep; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
603 rep = new_rep; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
604 slice_data = rep->data; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
605 } |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
606 } |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8503
diff
changeset
|
607 |
4517 | 608 void print_info (std::ostream& os, const std::string& prefix) const; |
5900 | 609 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
610 //! Give a pointer to the data in mex format. Unsafe. This function |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
611 //! exists to support the MEX interface. You should not use it |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
612 //! anywhere else. |
5900 | 613 void *mex_get_data (void) const { return const_cast<T *> (data ()); } |
7433 | 614 |
9725 | 615 Array<T> sort (int dim = 0, sortmode mode = ASCENDING) const; |
616 Array<T> sort (Array<octave_idx_type> &sidx, int dim = 0, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
617 sortmode mode = ASCENDING) const; |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
618 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
619 //! Ordering is auto-detected or can be specified. |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
620 sortmode is_sorted (sortmode mode = UNSORTED) const; |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
621 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
622 //! Sort by rows returns only indices. |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
623 Array<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const; |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
624 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
625 //! Ordering is auto-detected or can be specified. |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
626 sortmode is_sorted_rows (sortmode mode = UNSORTED) const; |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
627 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
628 //! @brief Do a binary lookup in a sorted array. Must not contain NaNs. |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
629 //! Mode can be specified or is auto-detected by comparing 1st and last element. |
8814
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
630 octave_idx_type lookup (const T& value, sortmode mode = UNSORTED) const; |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
631 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
632 //! Ditto, but for an array of values, specializing on the case when values |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
633 //! are sorted. NaNs get the value N. |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
634 Array<octave_idx_type> lookup (const Array<T>& values, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
635 sortmode mode = UNSORTED) const; |
9341
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
9201
diff
changeset
|
636 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
637 //! Count nonzero elements. |
9878
ead4f9c82a9a
implement Array<T>::nnz
Jaroslav Hajek <highegg@gmail.com>
parents:
9840
diff
changeset
|
638 octave_idx_type nnz (void) const; |
ead4f9c82a9a
implement Array<T>::nnz
Jaroslav Hajek <highegg@gmail.com>
parents:
9840
diff
changeset
|
639 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
640 //! Find indices of (at most n) nonzero elements. If n is specified, |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
641 //! backward specifies search from backward. |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
642 Array<octave_idx_type> find (octave_idx_type n = -1, |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
643 bool backward = false) const; |
9025 | 644 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
645 //! Returns the n-th element in increasing order, using the same |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
646 //! ordering as used for sort. n can either be a scalar index or a |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
647 //! contiguous range. |
9725 | 648 Array<T> nth_element (const idx_vector& n, int dim = 0) const; |
649 | |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
650 //! Get the kth super or subdiagonal. The zeroth diagonal is the |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
651 //! ordinary diagonal. |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
652 Array<T> diag (octave_idx_type k = 0) const; |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
653 |
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
|
654 Array<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
|
655 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
656 //! Concatenation along a specified (0-based) dimension, equivalent |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
657 //! to cat(). dim = -1 corresponds to dim = 0 and dim = -2 |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
658 //! corresponds to dim = 1, but apply the looser matching rules of |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
659 //! vertcat/horzcat. |
10531
2dd8ea8bfd71
basic cat functionality in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
660 static Array<T> |
2dd8ea8bfd71
basic cat functionality in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
661 cat (int dim, octave_idx_type n, const Array<T> *array_list); |
2dd8ea8bfd71
basic cat functionality in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
662 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
663 //! Apply function fcn to each element of the Array<T>. This function |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
664 //! is optimised with a manually unrolled loop. |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
665 template <typename U, typename F> |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
666 Array<U> |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
667 map (F fcn) const |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
668 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20229
diff
changeset
|
669 octave_idx_type len = numel (); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
670 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
671 const T *m = data (); |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
672 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
673 Array<U> result (dims ()); |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
674 U *p = result.fortran_vec (); |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
675 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
676 octave_idx_type i; |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
677 for (i = 0; i < len - 3; i += 4) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
678 { |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
679 octave_quit (); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
680 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
681 p[i] = fcn (m[i]); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
682 p[i+1] = fcn (m[i+1]); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
683 p[i+2] = fcn (m[i+2]); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
684 p[i+3] = fcn (m[i+3]); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
685 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
686 |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
10115
diff
changeset
|
687 octave_quit (); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
688 |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
689 for (; i < len; i++) |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
690 p[i] = fcn (m[i]); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
691 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
692 return result; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
693 } |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8950
diff
changeset
|
694 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
695 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
696 //! Overloads for function references. |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
697 template <typename U> |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
698 Array<U> |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
699 map (U (&fcn) (T)) const |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
700 { return map<U, U (&) (T)> (fcn); } |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
701 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
702 template <typename U> |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
703 Array<U> |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
704 map (U (&fcn) (const T&)) const |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
705 { return map<U, U (&) (const T&)> (fcn); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
706 //@} |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
707 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
708 //! Generic any/all test functionality with arbitrary predicate. |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
709 template <typename F, bool zero> |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
710 bool test (F fcn) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
711 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20229
diff
changeset
|
712 return any_all_test<F, T, zero> (fcn, data (), numel ()); |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
713 } |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
714 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
715 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
716 //! Simpler calls. |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
717 template <typename F> |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
718 bool test_any (F fcn) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
719 { return test<F, false> (fcn); } |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
720 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
721 template <typename F> |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
722 bool test_all (F fcn) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
723 { return test<F, true> (fcn); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
724 //@} |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
725 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
726 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
727 //! Overloads for function references. |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
728 bool test_any (bool (&fcn) (T)) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
729 { return test<bool (&) (T), false> (fcn); } |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
730 |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
731 bool test_any (bool (&fcn) (const T&)) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
732 { return test<bool (&) (const T&), false> (fcn); } |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
733 |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
734 bool test_all (bool (&fcn) (T)) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
735 { return test<bool (&) (T), true> (fcn); } |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
736 |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
737 bool test_all (bool (&fcn) (const T&)) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
738 { return test<bool (&) (const T&), true> (fcn); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
739 //@} |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
740 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
741 template <typename U> friend class Array; |
9201
472f0e22aa60
guard against implicit instantiation
Jaroslav Hajek <highegg@gmail.com>
parents:
9046
diff
changeset
|
742 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
743 //! Returns true if this->dims () == dv, and if so, replaces this->dimensions |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
744 //! by a shallow copy of dv. This is useful for maintaining several arrays with |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
745 //! supposedly equal dimensions (e.g. structs in the interpreter). |
10674
e3064439d6b4
new Array method for internal use
Jaroslav Hajek <highegg@gmail.com>
parents:
10673
diff
changeset
|
746 bool optimize_dimensions (const dim_vector& dv); |
e3064439d6b4
new Array method for internal use
Jaroslav Hajek <highegg@gmail.com>
parents:
10673
diff
changeset
|
747 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
748 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
749 //! WARNING: Only call these functions from jit |
19330
1f4455ff2329
Remove deprecated methods in liboctave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19326
diff
changeset
|
750 |
14951
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14616
diff
changeset
|
751 int *jit_ref_count (void) { return rep->count.get (); } |
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14616
diff
changeset
|
752 |
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14616
diff
changeset
|
753 T *jit_slice_data (void) const { return slice_data; } |
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14616
diff
changeset
|
754 |
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14616
diff
changeset
|
755 octave_idx_type *jit_dimensions (void) const { return dimensions.to_jit (); } |
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14616
diff
changeset
|
756 |
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14616
diff
changeset
|
757 void *jit_array_rep (void) const { return rep; } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
758 //@} |
14951
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14616
diff
changeset
|
759 |
9201
472f0e22aa60
guard against implicit instantiation
Jaroslav Hajek <highegg@gmail.com>
parents:
9046
diff
changeset
|
760 private: |
472f0e22aa60
guard against implicit instantiation
Jaroslav Hajek <highegg@gmail.com>
parents:
9046
diff
changeset
|
761 static void instantiation_guard (); |
4513 | 762 }; |
4459 | 763 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
764 //! This is a simple wrapper template that will subclass an Array<T> |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
765 //! type or any later type derived from it and override the default |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
766 //! non-const operator() to not check for the array's uniqueness. It |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
767 //! is, however, the user's responsibility to ensure the array is |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
768 //! actually unaliased whenever elements are accessed. |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
769 template <typename ArrayClass> |
9653
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
770 class NoAlias : public ArrayClass |
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
771 { |
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
772 typedef typename ArrayClass::element_type T; |
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
773 public: |
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
774 NoAlias () : ArrayClass () { } |
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
775 |
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
776 // FIXME: this would be simpler once C++0x is available |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
777 template <typename X> |
9653
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
778 explicit NoAlias (X x) : ArrayClass (x) { } |
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
779 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
780 template <typename X, typename Y> |
9653
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
781 explicit NoAlias (X x, Y y) : ArrayClass (x, y) { } |
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
782 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
783 template <typename X, typename Y, typename Z> |
9653
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
784 explicit NoAlias (X x, Y y, Z z) : ArrayClass (x, y, z) { } |
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
785 |
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
786 T& operator () (octave_idx_type n) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
787 { return ArrayClass::xelem (n); } |
9653
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
788 T& operator () (octave_idx_type i, octave_idx_type j) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
789 { return ArrayClass::xelem (i, j); } |
9653
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
790 T& operator () (octave_idx_type i, octave_idx_type j, octave_idx_type k) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
791 { return ArrayClass::xelem (i, j, k); } |
9653
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
792 T& operator () (const 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
|
793 { return ArrayClass::xelem (ra_idx); } |
9653
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
794 }; |
e087d7c77ff9
improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9624
diff
changeset
|
795 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
796 template <typename T> |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9731
diff
changeset
|
797 std::ostream& |
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9731
diff
changeset
|
798 operator << (std::ostream& os, const Array<T>& a); |
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9731
diff
changeset
|
799 |
9773
01f897d8a130
optimize memory manipulation by arrays & indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
800 #endif |