Mercurial > octave
annotate liboctave/array/Array.h @ 33636:3ec6fcce7715 default tip @
gui: Avoid using HAVE_QSCINTILLA in more header files.
* gui-settings.h, settings-dialog.h: Don't include QScintilla header.
Forward-declare QSciLexer class instead if necessary. Declare all member
functions unconditionally.
* gui-settings.cc (gui_settings::get_valid_lexer_styles,
gui_settings::read_lexer_settings),
settings-dialog.cc (settings_dialog::update_lexer,
settings_dialog::get_lexer_settings, settings_dialog::write_lexer_settings):
Define functions unconditionally.
* gui-preferences-ed.h: Don't include QScintilla header. Remove definition of
local variable os_eol_mode from header.
* gui-preferences-ed.cc (os_eol_mode): Move definition of local variable here.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Tue, 28 May 2024 14:54:58 +0200 |
parents | a7d829ba6d44 |
children |
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 // |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31771
diff
changeset
|
3 // Copyright (C) 1993-2024 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 |
4152 | 31 #include <cstddef> |
3613 | 32 |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8503
diff
changeset
|
33 #include <algorithm> |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
34 #include <iosfwd> |
23443
3f1bf237908b
maint: Eliminate <cfloat.h> header from liboctave files.
Rik <rik@octave.org>
parents:
23420
diff
changeset
|
35 #include <string> |
3933 | 36 |
30429
e38202d3628d
provide header file for forward declaration of Array<T> template
John W. Eaton <jwe@octave.org>
parents:
30394
diff
changeset
|
37 #include "Array-fwd.h" |
4513 | 38 #include "dim-vector.h" |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
39 #include "idx-vector.h" |
22139
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
40 #include "lo-error.h" |
8725 | 41 #include "lo-traits.h" |
3613 | 42 #include "lo-utils.h" |
23443
3f1bf237908b
maint: Eliminate <cfloat.h> header from liboctave files.
Rik <rik@octave.org>
parents:
23420
diff
changeset
|
43 #include "oct-refcount.h" |
7433 | 44 #include "oct-sort.h" |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
45 #include "quit.h" |
7433 | 46 |
22273
91c5442ea9fd
doc: doxygen explaining Array<T>.
Carnë Draug <carandraug@octave.org>
parents:
22139
diff
changeset
|
47 //! 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
|
48 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
49 //! 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
|
50 //! 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
|
51 //! 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
|
52 //! 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
|
53 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
54 //! @code{.cc} |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
55 //! // 3 D Array with 10 rows, 20 columns, and 5 pages, filled with 7.0 |
31654
33ce26ffc42b
Stop potential invalid memory access in Array.dim3() (bug #63466)
Rik <rik@octave.org>
parents:
31549
diff
changeset
|
56 //! Array<double> A (dim_vector (10, 20, 5), 7.0); |
24624
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
57 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
58 //! // 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
|
59 //! A(0, 10, 3) = 2.5; |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
60 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
61 //! // 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
|
62 //! double v = A(1, 2, 0); |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
63 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
64 //! // 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
|
65 //! double v = A(24); |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
66 //! @endcode |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
67 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
68 //! ## Notes on STL compatibility |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
69 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
70 //! ### size() and length() |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
71 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
72 //! 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
|
73 //! 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
|
74 //! Octave function with same name. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
75 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
76 //! @code{.cc} |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
77 //! 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
|
78 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
79 //! 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
|
80 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
81 //! 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
|
82 //! 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
|
83 //! 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
|
84 //! 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
|
85 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
86 //! // 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
|
87 //! dim_vector dims = A.dims (); |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
88 //! @endcode |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
89 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
90 //! 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
|
91 //! 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
|
92 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
93 //! 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
|
94 //! 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
|
95 //! 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
|
96 //! present in liboctave. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
97 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
98 //! 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
|
99 //! 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
|
100 //! 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
|
101 //! 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
|
102 //! 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
|
103 //! 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
|
104 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
105 //! ### size_type |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
106 //! |
27216
823b4bcf79fc
unless necessary for formatting or code, use ' instead of `
John W. Eaton <jwe@octave.org>
parents:
26574
diff
changeset
|
107 //! 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
|
108 //! 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
|
109 //! indexing. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
110 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
111 //! 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
|
112 //! 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
|
113 //! 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
|
114 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
115 //! ## Subclasses |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
116 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
117 //! 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
|
118 //! - 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
|
119 //! - 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
|
120 //! - boolNDArray: N dimensional Array<bool> |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
121 //! - ColumnVector: Array<double> with 1 column |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
122 //! - 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
|
123 //! - 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
|
124 |
32909
37cb0ade8b01
Array: Avoid implicitly instantiating template class in its declaration.
Markus Mützel <markus.muetzel@gmx.de>
parents:
32695
diff
changeset
|
125 // forward declare template with visibility attributes |
37cb0ade8b01
Array: Avoid implicitly instantiating template class in its declaration.
Markus Mützel <markus.muetzel@gmx.de>
parents:
32695
diff
changeset
|
126 template <typename T, typename Alloc> class OCTARRAY_API Array; |
37cb0ade8b01
Array: Avoid implicitly instantiating template class in its declaration.
Markus Mützel <markus.muetzel@gmx.de>
parents:
32695
diff
changeset
|
127 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
128 template <typename T, typename Alloc> |
32628
ae4e19c0a2b1
maint: Place class name and class keyword on one line.
Rik <rik@octave.org>
parents:
31771
diff
changeset
|
129 class OCTARRAY_TEMPLATE_API 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. |
33263
a7d829ba6d44
Export Array<T>::ArrayRep from shared library.
Markus Mützel <markus.muetzel@gmx.de>
parents:
33248
diff
changeset
|
134 class OCTARRAY_TEMPLATE_API 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 |
33263
a7d829ba6d44
Export Array<T>::ArrayRep from shared library.
Markus Mützel <markus.muetzel@gmx.de>
parents:
33248
diff
changeset
|
147 OCTARRAY_OVERRIDABLE_FUNC_API |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
148 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
|
149 : 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
|
150 { |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
151 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
|
152 } |
10364
96ed7c629bbd
remove dangerous pointer-acquiring Array ctors
Jaroslav Hajek <highegg@gmail.com>
parents:
10358
diff
changeset
|
153 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
154 template <typename U> |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
155 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
|
156 : 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
|
157 { |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
158 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
|
159 } |
1735 | 160 |
32660
f53ac65ffba6
maint: New method rwdata() as clearer alternative to fortran_vec().
Rik <rik@octave.org>
parents:
32633
diff
changeset
|
161 // Use new instead of setting data to 0 so that rwdata() and data() |
f53ac65ffba6
maint: New method rwdata() as clearer alternative to fortran_vec().
Rik <rik@octave.org>
parents:
32633
diff
changeset
|
162 // always return valid addresses, even for zero-size arrays. |
23401
e0c20a22da7e
eliminate some errors exposed by -fsanitize=undefined
John W. Eaton <jwe@octave.org>
parents:
23386
diff
changeset
|
163 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
164 ArrayRep () |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
165 : Alloc (), m_data (allocate (0)), m_len (0), m_count (1) { } |
1735 | 166 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
167 explicit ArrayRep (octave_idx_type len) |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
168 : 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
|
169 |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
170 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
|
171 : 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
|
172 { |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
173 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
|
174 } |
4513 | 175 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
176 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
|
177 const Alloc& xallocator = Alloc ()) |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
178 : 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
|
179 { } |
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
180 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
181 // FIXME: Should the allocator be copied or created with the default? |
1735 | 182 ArrayRep (const ArrayRep& a) |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
183 : 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
|
184 m_count (1) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
185 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
186 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
|
187 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
188 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
189 ~ArrayRep () { deallocate (m_data, m_len); } |
1735 | 190 |
33263
a7d829ba6d44
Export Array<T>::ArrayRep from shared library.
Markus Mützel <markus.muetzel@gmx.de>
parents:
33248
diff
changeset
|
191 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type numel () const |
a7d829ba6d44
Export Array<T>::ArrayRep from shared library.
Markus Mützel <markus.muetzel@gmx.de>
parents:
33248
diff
changeset
|
192 { |
a7d829ba6d44
Export Array<T>::ArrayRep from shared library.
Markus Mützel <markus.muetzel@gmx.de>
parents:
33248
diff
changeset
|
193 return m_len; |
a7d829ba6d44
Export Array<T>::ArrayRep from shared library.
Markus Mützel <markus.muetzel@gmx.de>
parents:
33248
diff
changeset
|
194 } |
1735 | 195 |
4517 | 196 // No assignment! |
197 | |
29946
3e5e88d9c85f
tag ArrayRep copy assignment operator with =delete
John W. Eaton <jwe@octave.org>
parents:
29937
diff
changeset
|
198 ArrayRep& operator = (const ArrayRep&) = delete; |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
199 |
33263
a7d829ba6d44
Export Array<T>::ArrayRep from shared library.
Markus Mützel <markus.muetzel@gmx.de>
parents:
33248
diff
changeset
|
200 OCTARRAY_OVERRIDABLE_FUNC_API pointer allocate (size_t len) |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
201 { |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
202 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
|
203 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
|
204 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
|
205 return data; |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
206 } |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
207 |
33263
a7d829ba6d44
Export Array<T>::ArrayRep from shared library.
Markus Mützel <markus.muetzel@gmx.de>
parents:
33248
diff
changeset
|
208 OCTARRAY_OVERRIDABLE_FUNC_API void deallocate (pointer data, size_t len) |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
209 { |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
210 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
|
211 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
|
212 Alloc_traits::deallocate (*this, data, len); |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
213 } |
1735 | 214 }; |
215 | |
4513 | 216 //-------------------------------------------------------------------- |
217 | |
6884 | 218 public: |
219 | |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
220 OCTARRAY_OVERRIDABLE_FUNC_API void make_unique () |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
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 > 1) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
223 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
224 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
|
225 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
226 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
|
227 delete m_rep; |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
228 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
229 m_rep = r; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
230 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
|
231 } |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
232 } |
238 | 233 |
5900 | 234 typedef T element_type; |
235 | |
22279
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 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
|
237 |
3bb1dc8b723e
Array: new typedef size_type and value_type, and new method size(dimension).
Carnë Draug <carandraug@octave.org>
parents:
22276
diff
changeset
|
238 //! 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
|
239 //! (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
|
240 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
|
241 |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9921
diff
changeset
|
242 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
|
243 |
8725 | 244 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
|
245 typename ref_param<T>::type); |
8725 | 246 |
8524
937921654627
clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
247 protected: |
4902 | 248 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
249 dim_vector m_dimensions; |
4518 | 250 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
251 typename Array<T, Alloc>::ArrayRep *m_rep; |
4513 | 252 |
8531
b01fef323c24
add some explaining comments
Jaroslav Hajek <highegg@gmail.com>
parents:
8524
diff
changeset
|
253 // Rationale: |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
254 // 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
|
255 // 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
|
256 // 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
|
257 // 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
|
258 // and m_slice_len need to be properly updated. |
8531
b01fef323c24
add some explaining comments
Jaroslav Hajek <highegg@gmail.com>
parents:
8524
diff
changeset
|
259 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
260 T *m_slice_data; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
261 octave_idx_type m_slice_len; |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8503
diff
changeset
|
262 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
263 //! slice constructor |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
264 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
|
265 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
|
266 : 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
|
267 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
268 m_rep->m_count++; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
269 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
|
270 } |
4513 | 271 |
272 private: | |
273 | |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
274 static OCTARRAY_API typename Array<T, Alloc>::ArrayRep *nil_rep (); |
238 | 275 |
228 | 276 public: |
238 | 277 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
278 //! Empty ctor (0 by 0). |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
279 Array () |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
280 : 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
|
281 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
|
282 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
283 m_rep->m_count++; |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
284 } |
1550 | 285 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
286 //! nD uninitialized ctor. |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
287 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
|
288 : m_dimensions (dv), |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
289 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
|
290 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
|
291 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
292 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
|
293 } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
294 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
295 //! nD initialized ctor. |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
296 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
|
297 : m_dimensions (dv), |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
298 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
|
299 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
|
300 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
301 fill (val); |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
302 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
|
303 } |
4513 | 304 |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
305 // 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
|
306 // 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
|
307 // 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
|
308 // 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
|
309 // 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
|
310 |
31404
3ea38ae97cc6
Array: Move constructor with custom allocator back to header (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31400
diff
changeset
|
311 OCTARRAY_OVERRIDABLE_FUNC_API |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
312 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
|
313 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
|
314 : 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
|
315 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
|
316 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
|
317 { |
3ea38ae97cc6
Array: Move constructor with custom allocator back to header (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31400
diff
changeset
|
318 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
|
319 } |
30227
b00ff462e0f2
improve efficiency of mxArray -> octave_value conversion
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
320 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
321 //! Reshape constructor. |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
322 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
|
323 |
22139
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
324 //! 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
|
325 template<template <typename...> class Container> |
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
326 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
|
327 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
328 //! Type conversion case. |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
329 template <typename U, typename A = Alloc> |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
330 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
|
331 : m_dimensions (a.dims ()), |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
332 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
|
333 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
|
334 { } |
4902 | 335 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
336 //! No type conversion case. |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
337 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
|
338 : 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
|
339 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
|
340 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
341 m_rep->m_count++; |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
342 } |
1550 | 343 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
344 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
|
345 : 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
|
346 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
|
347 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
348 a.m_rep = nullptr; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
349 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
|
350 a.m_slice_len = 0; |
27352
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
351 } |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
352 |
4513 | 353 public: |
354 | |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
355 virtual ~Array () |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
356 { |
27352
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
357 // 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
|
358 // 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
|
359 // 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
|
360 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
361 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
|
362 delete m_rep; |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
363 } |
228 | 364 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
365 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
|
366 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
367 if (this != &a) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
368 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
369 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
|
370 delete m_rep; |
9556
948795dc1974
make a few Array methods inline
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
371 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
372 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
|
373 m_rep->m_count++; |
9556
948795dc1974
make a few Array methods inline
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
374 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
375 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
|
376 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
|
377 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
|
378 } |
9556
948795dc1974
make a few Array methods inline
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
379 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
380 return *this; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
381 } |
4513 | 382 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
383 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
|
384 { |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
385 if (this != &a) |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
386 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
387 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
|
388 |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
389 // 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
|
390 // 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
|
391 // 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
|
392 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
393 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
|
394 delete m_rep; |
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 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
|
397 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
|
398 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
|
399 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
400 a.m_rep = nullptr; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
401 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
|
402 a.m_slice_len = 0; |
27352
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
403 } |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
404 |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
405 return *this; |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
406 } |
7335ebd4c798
define some move constructors and assignment operators
John W. Eaton <jwe@octave.org>
parents:
27216
diff
changeset
|
407 |
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
|
408 OCTARRAY_API void fill (const T& val); |
9624
3fc7272937ce
implement Array<T>::clear overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
9556
diff
changeset
|
409 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
410 OCTARRAY_API void clear (); |
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
|
411 OCTARRAY_API void clear (const dim_vector& dv); |
9624
3fc7272937ce
implement Array<T>::clear overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
9556
diff
changeset
|
412 |
3fc7272937ce
implement Array<T>::clear overloads
Jaroslav Hajek <highegg@gmail.com>
parents:
9556
diff
changeset
|
413 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
|
414 { clear (dim_vector (r, c)); } |
238 | 415 |
20212
6af35d4f1ba4
doxygen: document Array::length() and similar methods (bug #45138)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
416 //! 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
|
417 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
418 numel () const |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
419 { return m_slice_len; } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
420 //@} |
4513 | 421 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
422 //! 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
|
423 OCTARRAY_OVERRIDABLE_FUNC_API Array<T, Alloc> |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
424 as_column () const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
425 { |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
426 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
|
427 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
|
428 retval.m_dimensions = dim_vector (numel (), 1); |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
429 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
430 return retval; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
431 } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
432 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
433 //! 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
|
434 OCTARRAY_OVERRIDABLE_FUNC_API Array<T, Alloc> |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
435 as_row () const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
436 { |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
437 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
|
438 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
|
439 retval.m_dimensions = dim_vector (1, numel ()); |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
440 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
441 return retval; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
442 } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
443 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
444 //! 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
|
445 OCTARRAY_OVERRIDABLE_FUNC_API Array<T, Alloc> |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
446 as_matrix () const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
447 { |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
448 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
|
449 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
|
450 retval.m_dimensions = m_dimensions.redim (2); |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
451 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
452 return retval; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
453 } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
454 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
455 //! @name First dimension |
19330
1f4455ff2329
Remove deprecated methods in liboctave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19326
diff
changeset
|
456 //! |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
457 //! 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
|
458 //@{ |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
459 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
460 dim1 () const |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
461 { 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
|
462 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
463 rows () const |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
464 { return dim1 (); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
465 //@} |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
466 |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
467 //! @name Second dimension |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
468 //! |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
469 //! 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
|
470 //@{ |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
471 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type dim2 () const |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
472 { return m_dimensions(1); } |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
473 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type cols () const |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
474 { return dim2 (); } |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
475 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type columns () const |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
476 { return dim2 (); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
477 //@} |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
478 |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
479 //! @name Third dimension |
19330
1f4455ff2329
Remove deprecated methods in liboctave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19326
diff
changeset
|
480 //! |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
481 //! 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
|
482 //@{ |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
483 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type dim3 () const |
31654
33ce26ffc42b
Stop potential invalid memory access in Array.dim3() (bug #63466)
Rik <rik@octave.org>
parents:
31549
diff
changeset
|
484 { return m_dimensions.ndims () >= 3 ? m_dimensions(2) : 1; } |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
485 OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type pages () const |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
486 { return dim3 (); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
487 //@} |
4513 | 488 |
22279
3bb1dc8b723e
Array: new typedef size_type and value_type, and new method size(dimension).
Carnë Draug <carandraug@octave.org>
parents:
22276
diff
changeset
|
489 //! Size of the specified dimension. |
24624
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
490 //! |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
491 //! 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
|
492 //! those are implicit singleton dimensions. |
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
493 //! |
27216
823b4bcf79fc
unless necessary for formatting or code, use ' instead of `
John W. Eaton <jwe@octave.org>
parents:
26574
diff
changeset
|
494 //! 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
|
495 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
496 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
|
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 // 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
|
499 // 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
|
500 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
|
501 } |
3bb1dc8b723e
Array: new typedef size_type and value_type, and new method size(dimension).
Carnë Draug <carandraug@octave.org>
parents:
22276
diff
changeset
|
502 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
503 OCTARRAY_OVERRIDABLE_FUNC_API std::size_t byte_size () 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
|
504 { return static_cast<std::size_t> (numel ()) * sizeof (T); } |
4902 | 505 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
506 //! Return a const-reference so that dims ()(i) works efficiently. |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
507 OCTARRAY_OVERRIDABLE_FUNC_API const dim_vector& dims () const |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
508 { return m_dimensions; } |
4513 | 509 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
510 //! Chop off leading singleton dimensions |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
511 OCTARRAY_API Array<T, Alloc> squeeze () const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
512 |
31400
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 (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
|
515 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
|
516 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
|
517 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
|
518 compute_index (const Array<octave_idx_type>& ra_idx) const; |
4517 | 519 |
32909
37cb0ade8b01
Array: Avoid implicitly instantiating template class in its declaration.
Markus Mützel <markus.muetzel@gmx.de>
parents:
32695
diff
changeset
|
520 OCTARRAY_API octave_idx_type |
37cb0ade8b01
Array: Avoid implicitly instantiating template class in its declaration.
Markus Mützel <markus.muetzel@gmx.de>
parents:
32695
diff
changeset
|
521 compute_index_unchecked (const Array<octave_idx_type>& ra_idx) const; |
10645
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10636
diff
changeset
|
522 |
2108 | 523 // No checking, even for multiple references, ever. |
524 | |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
525 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
|
526 { 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
|
527 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
|
528 { return m_slice_data[n]; } |
2108 | 529 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
530 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
|
531 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
|
532 { 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
|
533 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
|
534 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
|
535 { return xelem (dim1 ()*j+i); } |
4513 | 536 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
537 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
|
538 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
|
539 { 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
|
540 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
|
541 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
|
542 { return xelem (i, dim2 ()*k+j); } |
4513 | 543 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
544 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
|
545 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
|
546 { return xelem (compute_index_unchecked (ra_idx)); } |
4513 | 547 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
548 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
|
549 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
|
550 { return xelem (compute_index_unchecked (ra_idx)); } |
4513 | 551 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
552 // 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
|
553 // a copy, but that is not so easy, and I see no clean way to do it. |
2006 | 554 |
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
|
555 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
|
556 |
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
|
557 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
|
558 |
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
|
559 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
|
560 |
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
|
561 OCTARRAY_API T& checkelem (const Array<octave_idx_type>& ra_idx); |
4513 | 562 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
563 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
|
564 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
565 make_unique (); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
566 return xelem (n); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
567 } |
2306 | 568 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
569 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
|
570 { return elem (dim1 ()*j+i); } |
4513 | 571 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
572 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
|
573 { return elem (i, dim2 ()*k+j); } |
4513 | 574 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
575 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
|
576 { return Array<T, Alloc>::elem (compute_index_unchecked (ra_idx)); } |
4513 | 577 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
578 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
|
579 { 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
|
580 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
|
581 { 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
|
582 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
|
583 { 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
|
584 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
|
585 { return elem (ra_idx); } |
2006 | 586 |
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
|
587 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
|
588 |
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
|
589 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
|
590 |
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
|
591 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
|
592 octave_idx_type k) const; |
23487
af2f1f3dbe06
eliminate --enable-bounds-check configure option
John W. Eaton <jwe@octave.org>
parents:
23461
diff
changeset
|
593 |
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
|
594 OCTARRAY_API crefT checkelem (const Array<octave_idx_type>& ra_idx) const; |
4513 | 595 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
596 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
|
597 { return xelem (n); } |
2306 | 598 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
599 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
|
600 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
|
601 { return xelem (i, j); } |
4513 | 602 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
603 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
|
604 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
|
605 { return xelem (i, j, k); } |
4513 | 606 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
607 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
|
608 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
|
609 { return Array<T, Alloc>::xelem (compute_index_unchecked (ra_idx)); } |
4513 | 610 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
611 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
|
612 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
|
613 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
|
614 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
|
615 { 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
|
616 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
|
617 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
|
618 { 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
|
619 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
|
620 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
|
621 { return elem (ra_idx); } |
2006 | 622 |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21660
diff
changeset
|
623 // Fast extractors. All of these produce shallow copies. |
9731 | 624 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
625 //! Extract column: A(:,k+1). |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
626 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
|
627 //! Extract page: A(:,:,k+1). |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
628 OCTARRAY_API Array<T, Alloc> page (octave_idx_type k) const; |
9731 | 629 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
630 //! 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
|
631 //! 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
|
632 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
|
633 linear_slice (octave_idx_type lo, octave_idx_type up) const; |
9731 | 634 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
635 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
|
636 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
|
637 { return Array<T, Alloc> (*this, dim_vector (nr, nc)); } |
10352 | 638 |
31549
ed7b17c7ddf3
maint: Strip trailing spaces and add missing EOL to all files.
Rik <rik@octave.org>
parents:
31404
diff
changeset
|
639 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
|
640 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
|
641 { return Array<T, Alloc> (*this, new_dims); } |
4567 | 642 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
643 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
|
644 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
|
645 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
|
646 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
|
647 { return permute (vec, true); } |
4593 | 648 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
649 OCTARRAY_OVERRIDABLE_FUNC_API bool issquare () const |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
650 { return (dim1 () == dim2 ()); } |
23593
a8361bc2361a
maint: Deprecate is_square and replace with issquare.
Rik <rik@octave.org>
parents:
23592
diff
changeset
|
651 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
652 OCTARRAY_OVERRIDABLE_FUNC_API bool isempty () const |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
653 { return numel () == 0; } |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23487
diff
changeset
|
654 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
655 OCTARRAY_OVERRIDABLE_FUNC_API bool isvector () const |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
656 { return m_dimensions.isvector (); } |
23592
80e3bfb7bd5a
maint: Deprecate is_vector and replace with isvector.
Rik <rik@octave.org>
parents:
23588
diff
changeset
|
657 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
658 OCTARRAY_OVERRIDABLE_FUNC_API bool is_nd_vector () const |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
659 { 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
|
660 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
661 OCTARRAY_API Array<T, Alloc> transpose () const; |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
662 OCTARRAY_API Array<T, Alloc> hermitian (T (*fcn) (const T&) = nullptr) const; |
238 | 663 |
32660
f53ac65ffba6
maint: New method rwdata() as clearer alternative to fortran_vec().
Rik <rik@octave.org>
parents:
32633
diff
changeset
|
664 // Use for direct read-only access to Array data. |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
665 OCTARRAY_OVERRIDABLE_FUNC_API const T * data () const |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
666 { return m_slice_data; } |
228 | 667 |
32660
f53ac65ffba6
maint: New method rwdata() as clearer alternative to fortran_vec().
Rik <rik@octave.org>
parents:
32633
diff
changeset
|
668 // Use for direct read-write access to Array data. |
f53ac65ffba6
maint: New method rwdata() as clearer alternative to fortran_vec().
Rik <rik@octave.org>
parents:
32633
diff
changeset
|
669 OCTARRAY_API T * rwdata (); |
f53ac65ffba6
maint: New method rwdata() as clearer alternative to fortran_vec().
Rik <rik@octave.org>
parents:
32633
diff
changeset
|
670 |
f53ac65ffba6
maint: New method rwdata() as clearer alternative to fortran_vec().
Rik <rik@octave.org>
parents:
32633
diff
changeset
|
671 // Alias for direct read-write access to Array data. |
f53ac65ffba6
maint: New method rwdata() as clearer alternative to fortran_vec().
Rik <rik@octave.org>
parents:
32633
diff
changeset
|
672 // FIXME: It is recommended to use rwdata() in future code for clarity. |
32695
a25b691d9d3d
Array.h: Do not export inlined function "fortran_vec".
Markus Mützel <markus.muetzel@gmx.de>
parents:
32660
diff
changeset
|
673 inline T * fortran_vec () |
32660
f53ac65ffba6
maint: New method rwdata() as clearer alternative to fortran_vec().
Rik <rik@octave.org>
parents:
32633
diff
changeset
|
674 { return rwdata (); } |
1560 | 675 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
676 OCTARRAY_OVERRIDABLE_FUNC_API bool is_shared () const |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
677 { return m_rep->m_count > 1; } |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9341
diff
changeset
|
678 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
679 OCTARRAY_OVERRIDABLE_FUNC_API int ndims () const |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
680 { return m_dimensions.ndims (); } |
1560 | 681 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
682 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
683 //! Indexing without resizing. |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
684 OCTARRAY_API Array<T, Alloc> index (const octave::idx_vector& i) const; |
1560 | 685 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
686 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
|
687 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
688 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
|
689 //@} |
1560 | 690 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
691 virtual OCTARRAY_API T resize_fill_value () const; |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
692 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
693 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
694 //! 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
|
695 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
|
696 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
|
697 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
698 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
|
699 } |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
700 |
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
|
701 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
|
702 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
|
703 { resize1 (n, resize_fill_value ()); } |
19330
1f4455ff2329
Remove deprecated methods in liboctave.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19326
diff
changeset
|
704 |
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
|
705 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
|
706 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
|
707 { resize (dv, resize_fill_value ()); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
708 //@} |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
709 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
710 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
711 //! Indexing with possible resizing and fill |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
712 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
713 // FIXME: this is really a corner case, that should better be |
8333 | 714 // handled directly in liboctinterp. |
3933 | 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, 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
|
718 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
|
719 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
|
720 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
721 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
|
722 } |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
723 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
724 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
|
725 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
|
726 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
|
727 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
|
728 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
|
729 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
|
730 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
731 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
|
732 } |
4513 | 733 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
734 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
|
735 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
|
736 const T& rfv) const; |
32909
37cb0ade8b01
Array: Avoid implicitly instantiating template class in its declaration.
Markus Mützel <markus.muetzel@gmx.de>
parents:
32695
diff
changeset
|
737 OCTARRAY_API Array<T, Alloc> |
37cb0ade8b01
Array: Avoid implicitly instantiating template class in its declaration.
Markus Mützel <markus.muetzel@gmx.de>
parents:
32695
diff
changeset
|
738 index (const Array<octave::idx_vector>& ia, bool resize_ok) const; |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
739 //@} |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
740 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
741 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
742 //! 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
|
743 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
|
744 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
|
745 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
|
746 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
|
747 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
748 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
|
749 } |
4513 | 750 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
751 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
|
752 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
|
753 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
|
754 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
|
755 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
|
756 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
|
757 { |
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
758 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
|
759 } |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
760 |
31400
e7fc6251b698
Use more specialized API flags for template classes (bug #61711).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31383
diff
changeset
|
761 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
|
762 assign (const Array<octave::idx_vector>& ia, const Array<T, Alloc>& rhs, const T& rfv); |
32909
37cb0ade8b01
Array: Avoid implicitly instantiating template class in its declaration.
Markus Mützel <markus.muetzel@gmx.de>
parents:
32695
diff
changeset
|
763 OCTARRAY_API void |
37cb0ade8b01
Array: Avoid implicitly instantiating template class in its declaration.
Markus Mützel <markus.muetzel@gmx.de>
parents:
32695
diff
changeset
|
764 assign (const Array<octave::idx_vector>& ia, const Array<T, Alloc>& rhs); |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
765 //@} |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
766 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
767 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
768 //! Deleting elements. |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
769 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
770 //! 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
|
771 OCTARRAY_API void delete_elements (const octave::idx_vector& i); |
4530 | 772 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
773 //! 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
|
774 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
|
775 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
776 //! Dispatcher to the above two. |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
777 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
|
778 //@} |
4513 | 779 |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21660
diff
changeset
|
780 //! 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
|
781 //! 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
|
782 //! 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
|
783 //! 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
|
784 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
|
785 insert (const Array<T, Alloc>& a, const Array<octave_idx_type>& idx); |
3928 | 786 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
787 //! 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
|
788 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
|
789 insert (const Array<T, Alloc>& a, octave_idx_type r, octave_idx_type c); |
3933 | 790 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
791 OCTARRAY_OVERRIDABLE_FUNC_API void maybe_economize () |
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 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
|
794 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
795 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
|
796 delete m_rep; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
797 m_rep = new_rep; |
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
798 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
|
799 } |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
800 } |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8503
diff
changeset
|
801 |
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
|
802 OCTARRAY_API void print_info (std::ostream& os, const std::string& prefix) const; |
5900 | 803 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
804 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
|
805 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
|
806 sortmode mode = ASCENDING) const; |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
807 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
808 //! 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
|
809 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
|
810 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
811 //! 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
|
812 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
|
813 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
814 //! 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
|
815 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
|
816 |
24624
ce2eb28e0a6d
doc: make all Doxygen comment blocks more consistent
Mike Miller <mtmiller@octave.org>
parents:
24534
diff
changeset
|
817 //! 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
|
818 //! 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
|
819 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
|
820 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
821 //! 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
|
822 //! 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
|
823 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
|
824 sortmode mode = UNSORTED) const; |
9341
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
9201
diff
changeset
|
825 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
826 //! Count nonzero elements. |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31707
diff
changeset
|
827 OCTARRAY_API octave_idx_type nnz () const; |
9878
ead4f9c82a9a
implement Array<T>::nnz
Jaroslav Hajek <highegg@gmail.com>
parents:
9840
diff
changeset
|
828 |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21660
diff
changeset
|
829 //! 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
|
830 //! 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
|
831 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
|
832 bool backward = false) const; |
9025 | 833 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
834 //! 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
|
835 //! 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
|
836 //! contiguous range. |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
837 OCTARRAY_API Array<T, Alloc> nth_element (const octave::idx_vector& n, int dim = 0) const; |
9725 | 838 |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21660
diff
changeset
|
839 //! 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
|
840 //! ordinary diagonal. |
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 k = 0) const; |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
842 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
843 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
|
844 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
845 //! 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
|
846 //! 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
|
847 //! 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
|
848 //! vertcat/horzcat. |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
849 static OCTARRAY_API Array<T, Alloc> |
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
850 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
|
851 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
852 //! 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
|
853 //! 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
|
854 #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
|
855 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
|
856 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
|
857 #else |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
858 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
|
859 #endif |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
860 Array<U, A> |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
861 map (F fcn) const |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
862 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20229
diff
changeset
|
863 octave_idx_type len = numel (); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
864 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
865 const T *m = data (); |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
866 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
867 Array<U, A> result (dims ()); |
32660
f53ac65ffba6
maint: New method rwdata() as clearer alternative to fortran_vec().
Rik <rik@octave.org>
parents:
32633
diff
changeset
|
868 U *p = result.rwdata (); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
869 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
870 octave_idx_type i; |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
871 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
|
872 { |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
873 octave_quit (); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
874 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
875 p[i] = fcn (m[i]); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
876 p[i+1] = fcn (m[i+1]); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
877 p[i+2] = fcn (m[i+2]); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
878 p[i+3] = fcn (m[i+3]); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
879 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
880 |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
10115
diff
changeset
|
881 octave_quit (); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
882 |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
883 for (; i < len; i++) |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
884 p[i] = fcn (m[i]); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
885 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
886 return result; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7463
diff
changeset
|
887 } |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8950
diff
changeset
|
888 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
889 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
890 //! 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
|
891 #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
|
892 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
|
893 #else |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
894 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
|
895 #endif |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
896 Array<U, A> |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
897 map (U (&fcn) (T)) const |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
898 { return map<U, U (&) (T), A> (fcn); } |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
899 |
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
|
900 #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
|
901 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
|
902 #else |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
903 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
|
904 #endif |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
905 Array<U, A> |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
906 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
|
907 { return map<U, U (&) (const T&), A> (fcn); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
908 //@} |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9800
diff
changeset
|
909 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
910 //! 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
|
911 template <typename F, bool zero> |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
912 bool test (F fcn) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
913 { |
29937
da7210e30f3e
move some utility functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29931
diff
changeset
|
914 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
|
915 } |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
916 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
917 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
918 //! Simpler calls. |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
919 template <typename F> |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
920 bool test_any (F fcn) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
921 { return test<F, false> (fcn); } |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
922 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
923 template <typename F> |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
924 bool test_all (F fcn) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
925 { return test<F, true> (fcn); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
926 //@} |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
927 |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
928 //@{ |
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
929 //! Overloads for function references. |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
930 bool test_any (bool (&fcn) (T)) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
931 { return test<bool (&) (T), false> (fcn); } |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
932 |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
933 bool test_any (bool (&fcn) (const T&)) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
934 { return test<bool (&) (const T&), false> (fcn); } |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
935 |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
936 bool test_all (bool (&fcn) (T)) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
937 { return test<bool (&) (T), true> (fcn); } |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
938 |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
939 bool test_all (bool (&fcn) (const T&)) const |
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
940 { return test<bool (&) (const T&), true> (fcn); } |
19006
96751a74bbbb
Start doxygenising sources
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
17769
diff
changeset
|
941 //@} |
11010
9478b216752e
simplify more array tests
Jaroslav Hajek <highegg@gmail.com>
parents:
10716
diff
changeset
|
942 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
943 template <typename U, typename A> friend class Array; |
9201
472f0e22aa60
guard against implicit instantiation
Jaroslav Hajek <highegg@gmail.com>
parents:
9046
diff
changeset
|
944 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
945 //! 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
|
946 //! 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
|
947 //! 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
|
948 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
|
949 |
9201
472f0e22aa60
guard against implicit instantiation
Jaroslav Hajek <highegg@gmail.com>
parents:
9046
diff
changeset
|
950 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
|
951 OCTARRAY_API static void instantiation_guard (); |
4513 | 952 }; |
4459 | 953 |
22139
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
954 // 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
|
955 // 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
|
956 // 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
|
957 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
|
958 template<template <typename...> class Container> |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
959 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
|
960 : 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
|
961 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
|
962 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
963 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
|
964 { |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
965 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
|
966 |
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
967 (*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
|
968 ("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
|
969 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
|
970 } |
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
971 |
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
972 octave_idx_type i = 0; |
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
973 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
|
974 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
|
975 |
29887
be669d935fb6
use m_prefix for data members in array classes
John W. Eaton <jwe@octave.org>
parents:
29655
diff
changeset
|
976 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
|
977 } |
f8212eb6da00
Array: add constructor from std sequence containers (patch 9047)
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
978 |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
979 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
|
980 OCTARRAY_API std::ostream& |
30486
298995435071
allow custom allocators for the Array class
John W. Eaton <jwe@octave.org>
parents:
30429
diff
changeset
|
981 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
|
982 |
9773
01f897d8a130
optimize memory manipulation by arrays & indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
983 #endif |