Mercurial > octave
annotate liboctave/array/Array.h @ 31550:c58f0f6ae207
maint: merge stable to default
author | Rik <rik@octave.org> |
---|---|
date | Fri, 25 Nov 2022 21:38:43 -0800 |
parents | db8735ee84da ed7b17c7ddf3 |
children | edd01ca92952 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30501
diff
changeset
|
3 // Copyright (C) 1993-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
228 | 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> |
23443
3f1bf237908b
maint: Eliminate <cfloat.h> header from liboctave files.
Rik <rik@octave.org>
parents:
23420
diff
changeset
|
36 #include <string> |
3933 | 37 |
30429
e38202d3628d
provide header file for forward declaration of Array<T> template
John W. Eaton <jwe@octave.org>
parents:
30394
diff
changeset
|
38 #include "Array-fwd.h" |
4513 | 39 #include "dim-vector.h" |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
40 #include "idx-vector.h" |
22139
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
41 #include "lo-error.h" |
8725 | 42 #include "lo-traits.h" |
3613 | 43 #include "lo-utils.h" |
23443
3f1bf237908b
maint: Eliminate <cfloat.h> header from liboctave files.
Rik <rik@octave.org>
parents:
23420
diff
changeset
|
44 #include "oct-refcount.h" |
7433 | 45 #include "oct-sort.h" |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
46 #include "quit.h" |
7433 | 47 |
22273
91c5442ea9fd
doc: doxygen explaining Array<T>.
Carnë Draug <carandraug@octave.org>
parents:
22139
diff
changeset
|
48 //! N Dimensional Array with copy-on-write semantics. |
24624
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
49 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
50 //! The Array class is at the root of Octave. It provides a container |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
51 //! with an arbitrary number of dimensions. The operator () provides |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
52 //! access to individual elements via subscript and linear indexing. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
53 //! Indexing starts at 0. Arrays are column-major order as in Fortran. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
54 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
55 //! @code{.cc} |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
56 //! // 3 D Array with 10 rows, 20 columns, and 5 pages, filled with 7.0 |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
57 //! Array<double> A Array<double (dim_vector (10, 20, 5), 7.0); |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
58 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
59 //! // set value for row 0, column 10, and page 3 |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
60 //! A(0, 10, 3) = 2.5; |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
61 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
62 //! // get value for row 1, column 2, and page 0 |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
63 //! double v = A(1, 2, 0); |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
64 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
65 //! // get value for 25th element (row 4, column 3, page 1) |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
66 //! double v = A(24); |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
67 //! @endcode |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
68 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
69 //! ## Notes on STL compatibility |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
70 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
71 //! ### size() and length() |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
72 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
73 //! To access the total number of elements in an Array, use numel() |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
74 //! which is short for number of elements and is equivalent to the |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
75 //! Octave function with same name. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
76 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
77 //! @code{.cc} |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
78 //! Array<int> A (dim_vector (10, 20, 4), 1); |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
79 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
80 //! octave_idx_type n = A.numel (); // returns 800 (10x20x4) |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
81 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
82 //! octave_idx_type nr = A.size (0); // returns 10 (number of rows/dimension 0) |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
83 //! octave_idx_type nc = A.size (1); // returns 20 (number of columns) |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
84 //! octave_idx_type nc = A.size (2); // returns 4 (size of dimension 3) |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
85 //! octave_idx_type l6 = A.size (6); // returns 1 (implicit singleton dimension) |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
86 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
87 //! // Alternatively, get a dim_vector which represents the dimensions. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
88 //! dim_vector dims = A.dims (); |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
89 //! @endcode |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
90 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
91 //! The methods size() and length() as they exist in the STL cause |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
92 //! confusion in the context of a N dimensional array. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
93 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
94 //! The size() of an array is the length of all dimensions. In Octave, |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
95 //! the size() function returns a row vector with the length of each |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
96 //! dimension, or the size of a specific dimension. Only the latter is |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
97 //! present in liboctave. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
98 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
99 //! Since there is more than 1 dimension, length() would not make sense |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
100 //! without expliciting which dimension. If the function existed, which |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
101 //! length should it return? Octave length() function returns the length |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
102 //! of the longest dimension which is an odd definition, only useful for |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
103 //! vectors and square matrices. The alternatives numel(), rows(), |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
26569
diff
changeset
|
104 //! columns(), and size(d) are more explicit and recommended. |
24624
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
105 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
106 //! ### size_type |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
107 //! |
27216
823b4bcf79fc
unless necessary for formatting or code, use ' instead of `
John W. Eaton <jwe@octave.org>
parents:
26574
diff
changeset
|
108 //! Array::size_type is 'octave_idx_type' which is a typedef for 'int' |
823b4bcf79fc
unless necessary for formatting or code, use ' instead of `
John W. Eaton <jwe@octave.org>
parents:
26574
diff
changeset
|
109 //! or 'long int', depending whether Octave was configured for 64-bit |
24624
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
110 //! indexing. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
111 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
112 //! This is a signed integer which may cause problems when mixed with |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
113 //! STL containers. The reason is that Octave interacts with Fortran |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
114 //! routines, providing an interface many Fortran numeric libraries. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
115 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
116 //! ## Subclasses |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
117 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
118 //! The following subclasses specializations, will be of most use: |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
119 //! - Matrix: Array<double> with only 2 dimensions |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
120 //! - ComplexMatrix: Array<std::complex<double>> with only 2 dimensions |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
121 //! - boolNDArray: N dimensional Array<bool> |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
122 //! - ColumnVector: Array<double> with 1 column |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
123 //! - string_vector: Array<std::string> with 1 column |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
124 //! - Cell: Array<octave_value>, equivalent to an Octave cell. |
22279
3bb1dc8b723e
Array: new typedef size_type and value_type, and new method size(dimension).
Carnë Draug <carandraug@octave.org>
parents:
22276
diff
changeset
|
125 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
126 template <typename T, typename Alloc> |
3585 | 127 class |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
128 OCTARRAY_TEMPLATE_API |
3585 | 129 Array |
228 | 130 { |
3504 | 131 protected: |
1619 | 132 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
133 //! The real representation of all arrays. |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
134 class ArrayRep : public Alloc |
1735 | 135 { |
136 public: | |
137 | |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
138 typedef std::allocator_traits<Alloc> Alloc_traits; |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
139 |
30492
e9a6d3822244
fix syntax error in previous change
John W. Eaton <jwe@octave.org>
parents:
30488
diff
changeset
|
140 typedef typename Alloc_traits::template rebind_traits<T> T_Alloc_traits; |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
141 typedef typename T_Alloc_traits::pointer pointer; |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
142 |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
143 pointer m_data; |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
144 octave_idx_type m_len; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
145 octave::refcount<octave_idx_type> m_count; |
1735 | 146 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
147 ArrayRep (pointer d, octave_idx_type len) |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
148 : Alloc (), m_data (allocate (len)), m_len (len), m_count (1) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
149 { |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
150 std::copy_n (d, len, m_data); |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
151 } |
10364
96ed7c629bbd
remove dangerous pointer-acquiring Array ctors
Jaroslav Hajek <highegg@gmail.com>
parents:
10358
diff
changeset
|
152 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
153 template <typename U> |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
154 ArrayRep (U *d, octave_idx_type len) |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
155 : Alloc (), m_data (allocate (len)), m_len (len), m_count (1) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
156 { |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
157 std::copy_n (d, len, m_data); |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
158 } |
1735 | 159 |
23401
e0c20a22da7e
eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents:
23386
diff
changeset
|
160 // Use new instead of setting data to 0 so that fortran_vec and |
e0c20a22da7e
eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents:
23386
diff
changeset
|
161 // data always return valid addresses, even for zero-size arrays. |
e0c20a22da7e
eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents:
23386
diff
changeset
|
162 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
163 ArrayRep (void) |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
164 : Alloc (), m_data (allocate (0)), m_len (0), m_count (1) { } |
1735 | 165 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
166 explicit ArrayRep (octave_idx_type len) |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
167 : Alloc (), m_data (allocate (len)), m_len (len), m_count (1) { } |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
168 |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
169 explicit ArrayRep (octave_idx_type len, const T& val) |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
170 : Alloc (), m_data (allocate (len)), m_len (len), m_count (1) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
171 { |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
172 std::fill_n (m_data, len, val); |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
173 } |
4513 | 174 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
175 explicit ArrayRep (pointer ptr, const dim_vector& dv, |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
176 const Alloc& xallocator = Alloc ()) |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
177 : Alloc (xallocator), m_data (ptr), m_len (dv.safe_numel ()), m_count (1) |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
178 { } |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
179 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
180 // FIXME: Should the allocator be copied or created with the default? |
1735 | 181 ArrayRep (const ArrayRep& a) |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
182 : Alloc (), m_data (allocate (a.m_len)), m_len (a.m_len), |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
183 m_count (1) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
184 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
185 std::copy_n (a.m_data, a.m_len, m_data); |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
186 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
187 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
188 ~ArrayRep (void) { deallocate (m_data, m_len); } |
1735 | 189 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
190 octave_idx_type numel (void) const { return m_len; } |
1735 | 191 |
4517 | 192 // No assignment! |
193 | |
29946
3e5e88d9c85f
tag ArrayRep copy assignment operator with =delete
John W. Eaton <jwe@octave.org>
parents:
29937
diff
changeset
|
194 ArrayRep& operator = (const ArrayRep&) = delete; |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
195 |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
196 pointer allocate (size_t len) |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
197 { |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
198 pointer data = Alloc_traits::allocate (*this, len); |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
199 for (size_t i = 0; i < len; i++) |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
200 T_Alloc_traits::construct (*this, data+i); |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
201 return data; |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
202 } |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
203 |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
204 void deallocate (pointer data, size_t len) |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
205 { |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
206 for (size_t i = 0; i < len; i++) |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
207 T_Alloc_traits::destroy (*this, data+i); |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
208 Alloc_traits::deallocate (*this, data, len); |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
209 } |
1735 | 210 }; |
211 | |
4513 | 212 //-------------------------------------------------------------------- |
213 | |
6884 | 214 public: |
215 | |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
216 OCTARRAY_OVERRIDABLE_FUNC_API void make_unique (void) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
217 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
218 if (m_rep->m_count > 1) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
219 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
220 ArrayRep *r = new ArrayRep (m_slice_data, m_slice_len); |
13985
43cc49c7abd1
Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
12125
diff
changeset
|
221 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
222 if (--m_rep->m_count == 0) |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
223 delete m_rep; |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
224 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
225 m_rep = r; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
226 m_slice_data = m_rep->m_data; |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
227 } |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
228 } |
238 | 229 |
5900 | 230 typedef T element_type; |
231 | |
22279
3bb1dc8b723e
Array: new typedef size_type and value_type, and new method size(dimension).
Carnë Draug <carandraug@octave.org>
parents:
22276
diff
changeset
|
232 typedef T value_type; |
3bb1dc8b723e
Array: new typedef size_type and value_type, and new method size(dimension).
Carnë Draug <carandraug@octave.org>
parents:
22276
diff
changeset
|
233 |
3bb1dc8b723e
Array: new typedef size_type and value_type, and new method size(dimension).
Carnë Draug <carandraug@octave.org>
parents:
22276
diff
changeset
|
234 //! Used for operator(), and returned by numel() and size() |
3bb1dc8b723e
Array: new typedef size_type and value_type, and new method size(dimension).
Carnë Draug <carandraug@octave.org>
parents:
22276
diff
changeset
|
235 //! (beware: signed integer) |
3bb1dc8b723e
Array: new typedef size_type and value_type, and new method size(dimension).
Carnë Draug <carandraug@octave.org>
parents:
22276
diff
changeset
|
236 typedef octave_idx_type size_type; |
3bb1dc8b723e
Array: new typedef size_type and value_type, and new method size(dimension).
Carnë Draug <carandraug@octave.org>
parents:
22276
diff
changeset
|
237 |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9921
diff
changeset
|
238 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
|
239 |
8725 | 240 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
|
241 typename ref_param<T>::type); |
8725 | 242 |
8524
937921654627
clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
243 protected: |
4902 | 244 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
245 dim_vector m_dimensions; |
4518 | 246 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
247 typename Array<T, Alloc>::ArrayRep *m_rep; |
4513 | 248 |
8531
b01fef323c24
add some explaining comments
Jaroslav Hajek <highegg@gmail.com>
parents:
8524
diff
changeset
|
249 // Rationale: |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
250 // m_slice_data is a pointer to m_rep->m_data, denoting together with m_slice_len the |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21660
diff
changeset
|
251 // actual portion of the data referenced by this Array<T> object. This |
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21660
diff
changeset
|
252 // allows to make shallow copies not only of a whole array, but also of |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
253 // contiguous subranges. Every time m_rep is directly manipulated, m_slice_data |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
254 // and m_slice_len need to be properly updated. |
8531
b01fef323c24
add some explaining comments
Jaroslav Hajek <highegg@gmail.com>
parents:
8524
diff
changeset
|
255 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
256 T *m_slice_data; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
257 octave_idx_type m_slice_len; |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8503
diff
changeset
|
258 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
259 //! slice constructor |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
260 Array (const Array<T, Alloc>& a, const dim_vector& dv, |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8503
diff
changeset
|
261 octave_idx_type l, octave_idx_type u) |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
262 : m_dimensions (dv), m_rep(a.m_rep), m_slice_data (a.m_slice_data+l), m_slice_len (u-l) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
263 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
264 m_rep->m_count++; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
265 m_dimensions.chop_trailing_singletons (); |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
266 } |
4513 | 267 |
268 private: | |
269 | |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
270 static OCTARRAY_API typename Array<T, Alloc>::ArrayRep *nil_rep (void); |
238 | 271 |
228 | 272 public: |
238 | 273 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
274 //! Empty ctor (0 by 0). |
1550 | 275 Array (void) |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
276 : m_dimensions (), m_rep (nil_rep ()), m_slice_data (m_rep->m_data), |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
277 m_slice_len (m_rep->m_len) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
278 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
279 m_rep->m_count++; |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
280 } |
1550 | 281 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
282 //! nD uninitialized ctor. |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
283 explicit Array (const dim_vector& dv) |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
284 : m_dimensions (dv), |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
285 m_rep (new typename Array<T, Alloc>::ArrayRep (dv.safe_numel ())), |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
286 m_slice_data (m_rep->m_data), m_slice_len (m_rep->m_len) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
287 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
288 m_dimensions.chop_trailing_singletons (); |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
289 } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
290 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
291 //! nD initialized ctor. |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
292 explicit Array (const dim_vector& dv, const T& val) |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
293 : m_dimensions (dv), |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
294 m_rep (new typename Array<T, Alloc>::ArrayRep (dv.safe_numel ())), |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
295 m_slice_data (m_rep->m_data), m_slice_len (m_rep->m_len) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
296 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
297 fill (val); |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
298 m_dimensions.chop_trailing_singletons (); |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
299 } |
4513 | 300 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
301 // Construct an Array from a pointer to an externally allocated array |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
302 // of values. PTR must be allocated with operator new. The Array |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
303 // object takes ownership of PTR and will delete it when the Array |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
304 // object is deleted. The dimension vector DV must be consistent with |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
305 // the size of the allocated PTR array. |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
306 |
31404
3ea38ae97cc6
Array: Move constructor with custom allocator back to header (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31400
diff
changeset
|
307 OCTARRAY_OVERRIDABLE_FUNC_API |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
308 explicit Array (T *ptr, const dim_vector& dv, |
31404
3ea38ae97cc6
Array: Move constructor with custom allocator back to header (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31400
diff
changeset
|
309 const Alloc& xallocator = Alloc ()) |
3ea38ae97cc6
Array: Move constructor with custom allocator back to header (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31400
diff
changeset
|
310 : m_dimensions (dv), |
3ea38ae97cc6
Array: Move constructor with custom allocator back to header (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31400
diff
changeset
|
311 m_rep (new typename Array<T, Alloc>::ArrayRep (ptr, dv, xallocator)), |
3ea38ae97cc6
Array: Move constructor with custom allocator back to header (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31400
diff
changeset
|
312 m_slice_data (m_rep->m_data), m_slice_len (m_rep->m_len) |
3ea38ae97cc6
Array: Move constructor with custom allocator back to header (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31400
diff
changeset
|
313 { |
3ea38ae97cc6
Array: Move constructor with custom allocator back to header (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31400
diff
changeset
|
314 m_dimensions.chop_trailing_singletons (); |
3ea38ae97cc6
Array: Move constructor with custom allocator back to header (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31400
diff
changeset
|
315 } |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
316 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
317 //! Reshape constructor. |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
318 OCTARRAY_API Array (const Array<T, Alloc>& a, const dim_vector& dv); |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
319 |
22139
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
320 //! Constructor from standard library sequence containers. |
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
321 template<template <typename...> class Container> |
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
322 Array (const Container<T>& a, const dim_vector& dv); |
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
323 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
324 //! Type conversion case. |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
325 template <typename U, typename A = Alloc> |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
326 Array (const Array<U, A>& a) |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
327 : m_dimensions (a.dims ()), |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
328 m_rep (new typename Array<T, Alloc>::ArrayRep (a.data (), a.numel ())), |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
329 m_slice_data (m_rep->m_data), m_slice_len (m_rep->m_len) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
330 { } |
4902 | 331 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
332 //! No type conversion case. |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
333 Array (const Array<T, Alloc>& a) |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
334 : m_dimensions (a.m_dimensions), m_rep (a.m_rep), m_slice_data (a.m_slice_data), |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
335 m_slice_len (a.m_slice_len) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
336 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
337 m_rep->m_count++; |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
338 } |
1550 | 339 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
340 Array (Array<T, Alloc>&& a) |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
341 : m_dimensions (std::move (a.m_dimensions)), m_rep (a.m_rep), |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
342 m_slice_data (a.m_slice_data), m_slice_len (a.m_slice_len) |
27352
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
343 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
344 a.m_rep = nullptr; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
345 a.m_slice_data = nullptr; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
346 a.m_slice_len = 0; |
27352
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
347 } |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
348 |
4513 | 349 public: |
350 | |
15216
dd7c37ceb800
avoid GCC warning by declaring Array destructor virtual
John W. Eaton <jwe@octave.org>
parents:
15212
diff
changeset
|
351 virtual ~Array (void) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
352 { |
27352
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
353 // Because we define a move constructor and a move assignment |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
354 // operator, m_rep may be a nullptr here. We should only need to |
27352
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
355 // protect the move assignment operator in a similar way. |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
356 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
357 if (m_rep && --m_rep->m_count == 0) |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
358 delete m_rep; |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
359 } |
228 | 360 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
361 Array<T, Alloc>& operator = (const Array<T, Alloc>& a) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
362 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
363 if (this != &a) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
364 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
365 if (--m_rep->m_count == 0) |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
366 delete m_rep; |
9556
948795dc1974
make a few Array methods inline
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
367 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
368 m_rep = a.m_rep; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
369 m_rep->m_count++; |
9556
948795dc1974
make a few Array methods inline
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
370 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
371 m_dimensions = a.m_dimensions; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
372 m_slice_data = a.m_slice_data; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
373 m_slice_len = a.m_slice_len; |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
374 } |
9556
948795dc1974
make a few Array methods inline
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
375 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
376 return *this; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
377 } |
4513 | 378 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
379 Array<T, Alloc>& operator = (Array<T, Alloc>&& a) |
27352
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
380 { |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
381 if (this != &a) |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
382 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
383 m_dimensions = std::move (a.m_dimensions); |
27352
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
384 |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
385 // Because we define a move constructor and a move assignment |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
386 // operator, m_rep may be a nullptr here. We should only need to |
27352
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
387 // protect the destructor in a similar way. |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
388 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
389 if (m_rep && --m_rep->m_count == 0) |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
390 delete m_rep; |
27352
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
391 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
392 m_rep = a.m_rep; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
393 m_slice_data = a.m_slice_data; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
394 m_slice_len = a.m_slice_len; |
27352
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
395 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
396 a.m_rep = nullptr; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
397 a.m_slice_data = nullptr; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
398 a.m_slice_len = 0; |
27352
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
399 } |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
400 |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
401 return *this; |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
402 } |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
403 |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
404 OCTARRAY_API void fill (const T& val); |
9624
3fc7272937ce
implement Array<T>::clear overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
9556
diff
changeset
|
405 |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
406 OCTARRAY_API void clear (void); |
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
407 OCTARRAY_API void clear (const dim_vector& dv); |
9624
3fc7272937ce
implement Array<T>::clear overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
9556
diff
changeset
|
408 |
3fc7272937ce
implement Array<T>::clear overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
9556
diff
changeset
|
409 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
|
410 { clear (dim_vector (r, c)); } |
238 | 411 |
20212
6af35d4f1ba4
doxygen: document Array::length() and similar methods (bug #45138)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
412 //! Number of elements in the array. |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
413 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
414 numel (void) const |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
415 { return m_slice_len; } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
416 //@} |
4513 | 417 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
418 //! Return the array as a column vector. |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
419 OCTARRAY_OVERRIDABLE_FUNC_API Array<T, Alloc> |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
420 as_column (void) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
421 { |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
422 Array<T, Alloc> retval (*this); |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
423 if (m_dimensions.ndims () != 2 || m_dimensions(1) != 1) |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
424 retval.m_dimensions = dim_vector (numel (), 1); |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
425 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
426 return retval; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
427 } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
428 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
429 //! Return the array as a row vector. |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
430 OCTARRAY_OVERRIDABLE_FUNC_API Array<T, Alloc> |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
431 as_row (void) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
432 { |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
433 Array<T, Alloc> retval (*this); |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
434 if (m_dimensions.ndims () != 2 || m_dimensions(0) != 1) |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
435 retval.m_dimensions = dim_vector (1, numel ()); |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
436 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
437 return retval; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
438 } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
439 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
440 //! Return the array as a matrix. |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
441 OCTARRAY_OVERRIDABLE_FUNC_API Array<T, Alloc> |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
442 as_matrix (void) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
443 { |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
444 Array<T, Alloc> retval (*this); |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
445 if (m_dimensions.ndims () != 2) |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
446 retval.m_dimensions = m_dimensions.redim (2); |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
447 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
448 return retval; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
449 } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
450 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
451 //! @name First dimension |
19330
1f4455ff2329
Remove deprecated methods in liboctave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19326
diff
changeset
|
452 //! |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
453 //! 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
|
454 //@{ |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
455 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
456 dim1 (void) const |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
457 { return m_dimensions(0); } |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
458 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
459 rows (void) const |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
460 { return dim1 (); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
461 //@} |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
462 |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
463 //! @name Second dimension |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
464 //! |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
465 //! 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
|
466 //@{ |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
467 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type dim2 (void) const |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
468 { return m_dimensions(1); } |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
469 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type cols (void) const |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
470 { return dim2 (); } |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
471 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type columns (void) const |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
472 { return dim2 (); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
473 //@} |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
474 |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
475 //! @name Third dimension |
19330
1f4455ff2329
Remove deprecated methods in liboctave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19326
diff
changeset
|
476 //! |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
477 //! 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
|
478 //@{ |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
479 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type dim3 (void) const |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
480 { return m_dimensions(2); } |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
481 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type pages (void) const |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
482 { return dim3 (); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
483 //@} |
4513 | 484 |
22279
3bb1dc8b723e
Array: new typedef size_type and value_type, and new method size(dimension).
Carnë Draug <carandraug@octave.org>
parents:
22276
diff
changeset
|
485 //! Size of the specified dimension. |
24624
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
486 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
487 //! Dimensions beyond the Array number of dimensions return 1 as |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
488 //! those are implicit singleton dimensions. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
489 //! |
27216
823b4bcf79fc
unless necessary for formatting or code, use ' instead of `
John W. Eaton <jwe@octave.org>
parents:
26574
diff
changeset
|
490 //! Equivalent to Octave's 'size (A, DIM)' |
22279
3bb1dc8b723e
Array: new typedef size_type and value_type, and new method size(dimension).
Carnë Draug <carandraug@octave.org>
parents:
22276
diff
changeset
|
491 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
492 OCTARRAY_OVERRIDABLE_FUNC_API size_type size (const size_type d) const |
22279
3bb1dc8b723e
Array: new typedef size_type and value_type, and new method size(dimension).
Carnë Draug <carandraug@octave.org>
parents:
22276
diff
changeset
|
493 { |
3bb1dc8b723e
Array: new typedef size_type and value_type, and new method size(dimension).
Carnë Draug <carandraug@octave.org>
parents:
22276
diff
changeset
|
494 // Should we throw for negative values? |
3bb1dc8b723e
Array: new typedef size_type and value_type, and new method size(dimension).
Carnë Draug <carandraug@octave.org>
parents:
22276
diff
changeset
|
495 // Should >= ndims () be handled by dim_vector operator() instead ? |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
496 return d >= ndims () ? 1 : m_dimensions(d); |
22279
3bb1dc8b723e
Array: new typedef size_type and value_type, and new method size(dimension).
Carnë Draug <carandraug@octave.org>
parents:
22276
diff
changeset
|
497 } |
3bb1dc8b723e
Array: new typedef size_type and value_type, and new method size(dimension).
Carnë Draug <carandraug@octave.org>
parents:
22276
diff
changeset
|
498 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
499 OCTARRAY_OVERRIDABLE_FUNC_API std::size_t byte_size (void) const |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
500 { return static_cast<std::size_t> (numel ()) * sizeof (T); } |
4902 | 501 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
502 //! Return a const-reference so that dims ()(i) works efficiently. |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
503 OCTARRAY_OVERRIDABLE_FUNC_API const dim_vector& dims (void) const |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
504 { return m_dimensions; } |
4513 | 505 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
506 //! Chop off leading singleton dimensions |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
507 OCTARRAY_API Array<T, Alloc> squeeze (void) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
508 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
509 OCTARRAY_API octave_idx_type |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
510 compute_index (octave_idx_type i, octave_idx_type j) const; |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
511 OCTARRAY_API octave_idx_type |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
512 compute_index (octave_idx_type i, octave_idx_type j, octave_idx_type k) const; |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
513 OCTARRAY_API octave_idx_type |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
514 compute_index (const Array<octave_idx_type>& ra_idx) const; |
4517 | 515 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
516 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
517 compute_index_unchecked (const Array<octave_idx_type>& ra_idx) const |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
518 { |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
519 return m_dimensions.compute_index (ra_idx.data (), ra_idx.numel ()); |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
520 } |
10645
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10636
diff
changeset
|
521 |
2108 | 522 // No checking, even for multiple references, ever. |
523 | |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
524 OCTARRAY_OVERRIDABLE_FUNC_API T& xelem (octave_idx_type n) |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
525 { return m_slice_data[n]; } |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
526 OCTARRAY_OVERRIDABLE_FUNC_API crefT xelem (octave_idx_type n) const |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
527 { return m_slice_data[n]; } |
2108 | 528 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
529 OCTARRAY_OVERRIDABLE_FUNC_API T& |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
530 xelem (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
|
531 { return xelem (dim1 ()*j+i); } |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
532 OCTARRAY_OVERRIDABLE_FUNC_API crefT |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
533 xelem (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
|
534 { return xelem (dim1 ()*j+i); } |
4513 | 535 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
536 OCTARRAY_OVERRIDABLE_FUNC_API T& |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
537 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
|
538 { return xelem (i, dim2 ()*k+j); } |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
539 OCTARRAY_OVERRIDABLE_FUNC_API crefT |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
540 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
|
541 { return xelem (i, dim2 ()*k+j); } |
4513 | 542 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
543 OCTARRAY_OVERRIDABLE_FUNC_API T& |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
544 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
|
545 { return xelem (compute_index_unchecked (ra_idx)); } |
4513 | 546 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
547 OCTARRAY_OVERRIDABLE_FUNC_API crefT |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
548 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
|
549 { return xelem (compute_index_unchecked (ra_idx)); } |
4513 | 550 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
551 // 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
|
552 // a copy, but that is not so easy, and I see no clean way to do it. |
2006 | 553 |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
554 OCTARRAY_API T& checkelem (octave_idx_type n); |
23487
af2f1f3dbe06
eliminate --enable-bounds-check configure option
John W. Eaton <jwe@octave.org>
parents:
23461
diff
changeset
|
555 |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
556 OCTARRAY_API T& checkelem (octave_idx_type i, octave_idx_type j); |
23487
af2f1f3dbe06
eliminate --enable-bounds-check configure option
John W. Eaton <jwe@octave.org>
parents:
23461
diff
changeset
|
557 |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
558 OCTARRAY_API T& checkelem (octave_idx_type i, octave_idx_type j, octave_idx_type k); |
23487
af2f1f3dbe06
eliminate --enable-bounds-check configure option
John W. Eaton <jwe@octave.org>
parents:
23461
diff
changeset
|
559 |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
560 OCTARRAY_API T& checkelem (const Array<octave_idx_type>& ra_idx); |
4513 | 561 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
562 OCTARRAY_OVERRIDABLE_FUNC_API 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
|
563 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
564 make_unique (); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
565 return xelem (n); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
566 } |
2306 | 567 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
568 OCTARRAY_OVERRIDABLE_FUNC_API T& elem (octave_idx_type i, octave_idx_type j) |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
569 { return elem (dim1 ()*j+i); } |
4513 | 570 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
571 OCTARRAY_OVERRIDABLE_FUNC_API T& elem (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
|
572 { return elem (i, dim2 ()*k+j); } |
4513 | 573 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
574 OCTARRAY_OVERRIDABLE_FUNC_API T& elem (const Array<octave_idx_type>& ra_idx) |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
575 { return Array<T, Alloc>::elem (compute_index_unchecked (ra_idx)); } |
4513 | 576 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
577 OCTARRAY_OVERRIDABLE_FUNC_API T& operator () (octave_idx_type n) |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
578 { return elem (n); } |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
579 OCTARRAY_OVERRIDABLE_FUNC_API T& operator () (octave_idx_type i, octave_idx_type j) |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
580 { return elem (i, j); } |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
581 OCTARRAY_OVERRIDABLE_FUNC_API 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
|
582 { return elem (i, j, k); } |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
583 OCTARRAY_OVERRIDABLE_FUNC_API 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
|
584 { return elem (ra_idx); } |
2006 | 585 |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
586 OCTARRAY_API crefT checkelem (octave_idx_type n) const; |
23487
af2f1f3dbe06
eliminate --enable-bounds-check configure option
John W. Eaton <jwe@octave.org>
parents:
23461
diff
changeset
|
587 |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
588 OCTARRAY_API crefT checkelem (octave_idx_type i, octave_idx_type j) const; |
23487
af2f1f3dbe06
eliminate --enable-bounds-check configure option
John W. Eaton <jwe@octave.org>
parents:
23461
diff
changeset
|
589 |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
590 OCTARRAY_API crefT checkelem (octave_idx_type i, octave_idx_type j, |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30232
diff
changeset
|
591 octave_idx_type k) const; |
23487
af2f1f3dbe06
eliminate --enable-bounds-check configure option
John W. Eaton <jwe@octave.org>
parents:
23461
diff
changeset
|
592 |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
593 OCTARRAY_API crefT checkelem (const Array<octave_idx_type>& ra_idx) const; |
4513 | 594 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
595 OCTARRAY_OVERRIDABLE_FUNC_API crefT elem (octave_idx_type n) const |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
596 { return xelem (n); } |
2306 | 597 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
598 OCTARRAY_OVERRIDABLE_FUNC_API crefT |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
599 elem (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
|
600 { return xelem (i, j); } |
4513 | 601 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
602 OCTARRAY_OVERRIDABLE_FUNC_API crefT |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
603 elem (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
|
604 { return xelem (i, j, k); } |
4513 | 605 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
606 OCTARRAY_OVERRIDABLE_FUNC_API crefT |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
607 elem (const Array<octave_idx_type>& ra_idx) const |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
608 { return Array<T, Alloc>::xelem (compute_index_unchecked (ra_idx)); } |
4513 | 609 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
610 OCTARRAY_OVERRIDABLE_FUNC_API crefT |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
611 operator () (octave_idx_type n) const { return elem (n); } |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
612 OCTARRAY_OVERRIDABLE_FUNC_API crefT |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
613 operator () (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
|
614 { return elem (i, j); } |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
615 OCTARRAY_OVERRIDABLE_FUNC_API crefT |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
616 operator () (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
|
617 { return elem (i, j, k); } |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
618 OCTARRAY_OVERRIDABLE_FUNC_API crefT |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
619 operator () (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
|
620 { return elem (ra_idx); } |
2006 | 621 |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21660
diff
changeset
|
622 // Fast extractors. All of these produce shallow copies. |
9731 | 623 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
624 //! Extract column: A(:,k+1). |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
625 OCTARRAY_API Array<T, Alloc> column (octave_idx_type k) const; |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
626 //! Extract page: A(:,:,k+1). |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
627 OCTARRAY_API Array<T, Alloc> page (octave_idx_type k) const; |
9731 | 628 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
629 //! Extract a slice from this array as a column vector: A(:)(lo+1:up). |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21660
diff
changeset
|
630 //! Must be 0 <= lo && up <= numel. May be up < lo. |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
631 OCTARRAY_API Array<T, Alloc> |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
632 linear_slice (octave_idx_type lo, octave_idx_type up) const; |
9731 | 633 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
634 OCTARRAY_OVERRIDABLE_FUNC_API Array<T, Alloc> |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
635 reshape (octave_idx_type nr, octave_idx_type nc) const |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
636 { return Array<T, Alloc> (*this, dim_vector (nr, nc)); } |
10352 | 637 |
31549
ed7b17c7ddf3
maint: Strip trailing spaces and add missing EOL to all files.
Rik <rik@octave.org>
parents:
31404
diff
changeset
|
638 OCTARRAY_OVERRIDABLE_FUNC_API Array<T, Alloc> |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
639 reshape (const dim_vector& new_dims) const |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
640 { return Array<T, Alloc> (*this, new_dims); } |
4567 | 641 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
642 OCTARRAY_API Array<T, Alloc> |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
643 permute (const Array<octave_idx_type>& vec, bool inv = false) const; |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
644 OCTARRAY_OVERRIDABLE_FUNC_API Array<T, Alloc> |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
645 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
|
646 { return permute (vec, true); } |
4593 | 647 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
648 OCTARRAY_OVERRIDABLE_FUNC_API bool issquare (void) const |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
649 { return (dim1 () == dim2 ()); } |
23593
a8361bc2361a
maint: Deprecate is_square and replace with issquare.
Rik <rik@octave.org>
parents:
23592
diff
changeset
|
650 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
651 OCTARRAY_OVERRIDABLE_FUNC_API bool isempty (void) const |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
652 { return numel () == 0; } |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23487
diff
changeset
|
653 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
654 OCTARRAY_OVERRIDABLE_FUNC_API bool isvector (void) const |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
655 { return m_dimensions.isvector (); } |
23592
80e3bfb7bd5a
maint: Deprecate is_vector and replace with isvector.
Rik <rik@octave.org>
parents:
23588
diff
changeset
|
656 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
657 OCTARRAY_OVERRIDABLE_FUNC_API bool is_nd_vector (void) const |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
658 { return m_dimensions.is_nd_vector (); } |
23386
f1ea44e92df8
improve compatibility for single index indexing (bug #50776)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
659 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
660 OCTARRAY_API Array<T, Alloc> transpose (void) const; |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
661 OCTARRAY_API Array<T, Alloc> hermitian (T (*fcn) (const T&) = nullptr) const; |
238 | 662 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
663 OCTARRAY_OVERRIDABLE_FUNC_API const T * data (void) const |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
664 { return m_slice_data; } |
228 | 665 |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
666 OCTARRAY_API T * fortran_vec (void); |
1560 | 667 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
668 OCTARRAY_OVERRIDABLE_FUNC_API bool is_shared (void) |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
669 { return m_rep->m_count > 1; } |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9341
diff
changeset
|
670 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
671 OCTARRAY_OVERRIDABLE_FUNC_API int ndims (void) const |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
672 { return m_dimensions.ndims (); } |
1560 | 673 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
674 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
675 //! Indexing without resizing. |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
676 OCTARRAY_API Array<T, Alloc> index (const octave::idx_vector& i) const; |
1560 | 677 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
678 OCTARRAY_API Array<T, Alloc> index (const octave::idx_vector& i, const octave::idx_vector& j) const; |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
679 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
680 OCTARRAY_API Array<T, Alloc> index (const Array<octave::idx_vector>& ia) const; |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
681 //@} |
1560 | 682 |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
683 virtual OCTARRAY_API T resize_fill_value (void) const; |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
684 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
685 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
686 //! Resizing (with fill). |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
687 OCTARRAY_API void resize2 (octave_idx_type nr, octave_idx_type nc, const T& rfv); |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
688 OCTARRAY_OVERRIDABLE_FUNC_API 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
|
689 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
690 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
|
691 } |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
692 |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
693 OCTARRAY_API void resize1 (octave_idx_type n, const T& rfv); |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
694 OCTARRAY_OVERRIDABLE_FUNC_API void resize1 (octave_idx_type n) |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
695 { resize1 (n, resize_fill_value ()); } |
19330
1f4455ff2329
Remove deprecated methods in liboctave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19326
diff
changeset
|
696 |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
697 OCTARRAY_API void resize (const dim_vector& dv, const T& rfv); |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
698 OCTARRAY_OVERRIDABLE_FUNC_API void resize (const dim_vector& dv) |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
699 { resize (dv, resize_fill_value ()); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
700 //@} |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
701 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
702 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
703 //! Indexing with possible resizing and fill |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
704 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
705 // FIXME: this is really a corner case, that should better be |
8333 | 706 // handled directly in liboctinterp. |
3933 | 707 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
708 OCTARRAY_API Array<T, Alloc> |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
709 index (const octave::idx_vector& i, bool resize_ok, const T& rfv) const; |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
710 OCTARRAY_OVERRIDABLE_FUNC_API Array<T, Alloc> |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
711 index (const octave::idx_vector& i, 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
|
712 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
713 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
|
714 } |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
715 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
716 OCTARRAY_API Array<T, Alloc> |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
717 index (const octave::idx_vector& i, const octave::idx_vector& j, |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
718 bool resize_ok, const T& rfv) const; |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
719 OCTARRAY_OVERRIDABLE_FUNC_API Array<T, Alloc> |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
720 index (const octave::idx_vector& i, const octave::idx_vector& j, |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
721 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
|
722 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
723 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
|
724 } |
4513 | 725 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
726 OCTARRAY_API Array<T, Alloc> |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
727 index (const Array<octave::idx_vector>& ia, bool resize_ok, |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
728 const T& rfv) const; |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
729 OCTARRAY_OVERRIDABLE_FUNC_API Array<T, Alloc> |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
730 index (const Array<octave::idx_vector>& ia, 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
|
731 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
732 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
|
733 } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
734 //@} |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
735 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
736 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
737 //! Indexed assignment (always with resize & fill). |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
738 OCTARRAY_API void |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
739 assign (const octave::idx_vector& i, const Array<T, Alloc>& rhs, const T& rfv); |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
740 OCTARRAY_OVERRIDABLE_FUNC_API void |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
741 assign (const octave::idx_vector& i, const Array<T, Alloc>& rhs) |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
742 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
743 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
|
744 } |
4513 | 745 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
746 OCTARRAY_API void |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
747 assign (const octave::idx_vector& i, const octave::idx_vector& j, |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
748 const Array<T, Alloc>& rhs, const T& rfv); |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
749 OCTARRAY_OVERRIDABLE_FUNC_API void |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
750 assign (const octave::idx_vector& i, const octave::idx_vector& j, |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
751 const Array<T, Alloc>& rhs) |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
752 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
753 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
|
754 } |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
755 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
756 OCTARRAY_API void |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
757 assign (const Array<octave::idx_vector>& ia, const Array<T, Alloc>& rhs, const T& rfv); |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
758 OCTARRAY_OVERRIDABLE_FUNC_API void |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
759 assign (const Array<octave::idx_vector>& ia, const Array<T, Alloc>& rhs) |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
760 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
761 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
|
762 } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
763 //@} |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
764 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
765 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
766 //! Deleting elements. |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
767 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
768 //! A(I) = [] (with a single subscript) |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
769 OCTARRAY_API void delete_elements (const octave::idx_vector& i); |
4530 | 770 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
771 //! A(:,...,I,...,:) = [] (>= 2 subscripts, one of them is non-colon) |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
772 OCTARRAY_API void delete_elements (int dim, const octave::idx_vector& i); |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
773 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
774 //! Dispatcher to the above two. |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
775 OCTARRAY_API void delete_elements (const Array<octave::idx_vector>& ia); |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
776 //@} |
4513 | 777 |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21660
diff
changeset
|
778 //! Insert an array into another at a specified position. If |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
779 //! 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
|
780 //! 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
|
781 //! iN:iN+dN-1) = a. |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
782 OCTARRAY_API Array<T, Alloc>& |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
783 insert (const Array<T, Alloc>& a, const Array<octave_idx_type>& idx); |
3928 | 784 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
785 //! This is just a special case for idx = [r c 0 ...] |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
786 OCTARRAY_API Array<T, Alloc>& |
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
787 insert (const Array<T, Alloc>& a, octave_idx_type r, octave_idx_type c); |
3933 | 788 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
789 OCTARRAY_OVERRIDABLE_FUNC_API void maybe_economize (void) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
790 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
791 if (m_rep->m_count == 1 && m_slice_len != m_rep->m_len) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
792 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
793 ArrayRep *new_rep = new ArrayRep (m_slice_data, m_slice_len); |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
794 delete m_rep; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
795 m_rep = new_rep; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
796 m_slice_data = m_rep->m_data; |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
797 } |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
798 } |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8503
diff
changeset
|
799 |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
800 OCTARRAY_API void print_info (std::ostream& os, const std::string& prefix) const; |
5900 | 801 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
802 OCTARRAY_API Array<T, Alloc> sort (int dim = 0, sortmode mode = ASCENDING) const; |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
803 OCTARRAY_API Array<T, Alloc> sort (Array<octave_idx_type>& sidx, int dim = 0, |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
804 sortmode mode = ASCENDING) const; |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
805 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
806 //! Ordering is auto-detected or can be specified. |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
807 OCTARRAY_API sortmode issorted (sortmode mode = UNSORTED) const; |
23588
0549061d35b9
maint: Deprecate is_sorted and replace with issorted.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
808 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
809 //! Sort by rows returns only indices. |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
810 OCTARRAY_API Array<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const; |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
811 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
812 //! Ordering is auto-detected or can be specified. |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
813 OCTARRAY_API sortmode is_sorted_rows (sortmode mode = UNSORTED) const; |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
814 |
24624
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
815 //! Do a binary lookup in a sorted array. Must not contain NaNs. |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
816 //! Mode can be specified or is auto-detected by comparing 1st and last element. |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
817 OCTARRAY_API octave_idx_type lookup (const T& value, sortmode mode = UNSORTED) const; |
8814
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
818 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
819 //! Ditto, but for an array of values, specializing on the case when values |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21660
diff
changeset
|
820 //! are sorted. NaNs get the value N. |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
821 OCTARRAY_API Array<octave_idx_type> lookup (const Array<T, Alloc>& values, |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
822 sortmode mode = UNSORTED) const; |
9341
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
9201
diff
changeset
|
823 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
824 //! Count nonzero elements. |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
825 OCTARRAY_API octave_idx_type nnz (void) const; |
9878
ead4f9c82a9a
implement Array<T>::nnz
Jaroslav Hajek <highegg@gmail.com>
parents:
9840
diff
changeset
|
826 |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21660
diff
changeset
|
827 //! Find indices of (at most n) nonzero elements. If n is specified, |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
828 //! backward specifies search from backward. |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
829 OCTARRAY_API Array<octave_idx_type> find (octave_idx_type n = -1, |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
830 bool backward = false) const; |
9025 | 831 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
832 //! Returns the n-th element in increasing order, using the same |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21660
diff
changeset
|
833 //! ordering as used for sort. n can either be a scalar index or a |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
834 //! contiguous range. |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
835 OCTARRAY_API Array<T, Alloc> nth_element (const octave::idx_vector& n, int dim = 0) const; |
9725 | 836 |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21660
diff
changeset
|
837 //! Get the kth super or subdiagonal. The zeroth diagonal is the |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
838 //! ordinary diagonal. |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
839 OCTARRAY_API Array<T, Alloc> diag (octave_idx_type k = 0) const; |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
840 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
841 OCTARRAY_API Array<T, Alloc> diag (octave_idx_type m, octave_idx_type n) const; |
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
|
842 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
843 //! Concatenation along a specified (0-based) dimension, equivalent |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21660
diff
changeset
|
844 //! to cat(). dim = -1 corresponds to dim = 0 and dim = -2 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
845 //! 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
|
846 //! vertcat/horzcat. |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
847 static OCTARRAY_API Array<T, Alloc> |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
848 cat (int dim, octave_idx_type n, const Array<T, Alloc> *array_list); |
10531
2dd8ea8bfd71
basic cat functionality in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
849 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
850 //! Apply function fcn to each element of the Array<T, Alloc>. This function |
21567
3d25f9f4a62b
maint: Eliminate Britishicisms in the code.
Rik <rik@octave.org>
parents:
21244
diff
changeset
|
851 //! is optimized with a manually unrolled loop. |
30501
79a7f3e3cf54
Use consistent name for OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR (bug #61472).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30492
diff
changeset
|
852 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30486
diff
changeset
|
853 template <typename U, typename F, |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30486
diff
changeset
|
854 typename A = std::pmr::polymorphic_allocator<U>> |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30486
diff
changeset
|
855 #else |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
856 template <typename U, typename F, typename A = std::allocator<U>> |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30486
diff
changeset
|
857 #endif |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
858 Array<U, A> |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
859 map (F fcn) const |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
860 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20229
diff
changeset
|
861 octave_idx_type len = numel (); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
862 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
863 const T *m = data (); |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
864 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
865 Array<U, A> result (dims ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
866 U *p = result.fortran_vec (); |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
867 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
868 octave_idx_type i; |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
869 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
|
870 { |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
871 octave_quit (); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
872 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
873 p[i] = fcn (m[i]); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
874 p[i+1] = fcn (m[i+1]); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
875 p[i+2] = fcn (m[i+2]); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
876 p[i+3] = fcn (m[i+3]); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
877 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
878 |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
10115
diff
changeset
|
879 octave_quit (); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
880 |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
881 for (; i < len; i++) |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
882 p[i] = fcn (m[i]); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
883 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
884 return result; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
885 } |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8950
diff
changeset
|
886 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
887 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
888 //! Overloads for function references. |
30501
79a7f3e3cf54
Use consistent name for OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR (bug #61472).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30492
diff
changeset
|
889 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30486
diff
changeset
|
890 template <typename U, typename A = std::pmr::polymorphic_allocator<U>> |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30486
diff
changeset
|
891 #else |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
892 template <typename U, typename A = std::allocator<U>> |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30486
diff
changeset
|
893 #endif |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
894 Array<U, A> |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
895 map (U (&fcn) (T)) const |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
896 { return map<U, U (&) (T), A> (fcn); } |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
897 |
30501
79a7f3e3cf54
Use consistent name for OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR (bug #61472).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30492
diff
changeset
|
898 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR) |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30486
diff
changeset
|
899 template <typename U, typename A = std::pmr::polymorphic_allocator<U>> |
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30486
diff
changeset
|
900 #else |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
901 template <typename U, typename A = std::allocator<U>> |
30488
abb4823df535
with C++17, match malloc/free for MEX memory (bug #61472)
John W. Eaton <jwe@octave.org>
parents:
30486
diff
changeset
|
902 #endif |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
903 Array<U, A> |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
904 map (U (&fcn) (const T&)) const |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
905 { return map<U, U (&) (const T&), A> (fcn); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
906 //@} |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
907 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
908 //! 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
|
909 template <typename F, bool zero> |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
910 bool test (F fcn) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
911 { |
29937
da7210e30f3e
move some utility functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29931
diff
changeset
|
912 return octave::any_all_test<F, T, zero> (fcn, data (), numel ()); |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
913 } |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
914 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
915 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
916 //! Simpler calls. |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
917 template <typename F> |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
918 bool test_any (F fcn) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
919 { return test<F, false> (fcn); } |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
920 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
921 template <typename F> |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
922 bool test_all (F fcn) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
923 { return test<F, true> (fcn); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
924 //@} |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
925 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
926 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
927 //! Overloads for function references. |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
928 bool test_any (bool (&fcn) (T)) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
929 { return test<bool (&) (T), false> (fcn); } |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
930 |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
931 bool test_any (bool (&fcn) (const T&)) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
932 { return test<bool (&) (const T&), false> (fcn); } |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
933 |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
934 bool test_all (bool (&fcn) (T)) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
935 { return test<bool (&) (T), true> (fcn); } |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
936 |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
937 bool test_all (bool (&fcn) (const T&)) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
938 { return test<bool (&) (const T&), true> (fcn); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
939 //@} |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
940 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
941 template <typename U, typename A> friend class Array; |
9201
472f0e22aa60
guard against implicit instantiation
Jaroslav Hajek <highegg@gmail.com>
parents:
9046
diff
changeset
|
942 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
943 //! Returns true if this->dims () == dv, and if so, replaces this->m_dimensions |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21660
diff
changeset
|
944 //! by a shallow copy of dv. This is useful for maintaining several arrays |
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21660
diff
changeset
|
945 //! with supposedly equal dimensions (e.g. structs in the interpreter). |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
946 OCTARRAY_API bool optimize_dimensions (const dim_vector& dv); |
10674
e3064439d6b4
new Array method for internal use
Jaroslav Hajek <highegg@gmail.com>
parents:
10673
diff
changeset
|
947 |
9201
472f0e22aa60
guard against implicit instantiation
Jaroslav Hajek <highegg@gmail.com>
parents:
9046
diff
changeset
|
948 private: |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
949 OCTARRAY_API static void instantiation_guard (); |
4513 | 950 }; |
4459 | 951 |
22139
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
952 // We use a variadic template for template template parameter so that |
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
953 // we don't have to specify all the template parameters and limit this |
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
954 // to Container<T>. http://stackoverflow.com/a/20499809/1609556 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
955 template<typename T, typename Alloc> |
22139
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
956 template<template <typename...> class Container> |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
957 Array<T, Alloc>::Array (const Container<T>& a, const dim_vector& dv) |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
958 : m_dimensions (dv), m_rep (new typename Array<T, Alloc>::ArrayRep (dv.safe_numel ())), |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
959 m_slice_data (m_rep->m_data), m_slice_len (m_rep->m_len) |
22139
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
960 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
961 if (m_dimensions.safe_numel () != octave_idx_type (a.size ())) |
22139
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
962 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
963 std::string new_dims_str = m_dimensions.str (); |
22139
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
964 |
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
965 (*current_liboctave_error_handler) |
26569
0e77df67b522
Add static compile-time checking of printf functions in liboctave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
966 ("reshape: can't reshape %zi elements into %s array", |
22139
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
967 a.size (), new_dims_str.c_str ()); |
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
968 } |
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
969 |
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
970 octave_idx_type i = 0; |
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
971 for (const T& x : a) |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
972 m_slice_data[i++] = x; |
22139
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
973 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
974 m_dimensions.chop_trailing_singletons (); |
22139
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
975 } |
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
976 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
977 template <typename T, typename Alloc> |
29224
cc4a4df4e32f
Add API tag for Array class that is exported from liboctave and liboctinterp (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27957
diff
changeset
|
978 OCTARRAY_API std::ostream& |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
979 operator << (std::ostream& os, const Array<T, Alloc>& a); |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9731
diff
changeset
|
980 |
9773
01f897d8a130
optimize memory manipulation by arrays & indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
981 #endif |