Mercurial > octave
annotate liboctave/array/Array-util.h @ 33639:65b1cf6aa60a bytecode-interpreter tip
maint: Merge default to bytecode-interpreter
author | Arun Giridhar <arungiridhar@gmail.com> |
---|---|
date | Mon, 03 Jun 2024 14:38:47 -0400 |
parents | 2e484f9f1f18 |
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:
31812
diff
changeset
|
3 // Copyright (C) 2000-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 //////////////////////////////////////////////////////////////////////// |
4588 | 25 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
26 #if ! defined (octave_Array_util_h) |
4588 | 27 #define octave_Array_util_h 1 |
28 | |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21100
diff
changeset
|
29 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21100
diff
changeset
|
30 |
4588 | 31 #include "Array.h" |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
32 #include "lo-array-errwarn.h" |
4588 | 33 |
6108 | 34 extern OCTAVE_API bool index_in_bounds (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
|
35 const dim_vector& dimensions); |
4588 | 36 |
6108 | 37 extern OCTAVE_API void increment_index (Array<octave_idx_type>& ra_idx, |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
38 const dim_vector& dimensions, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
39 int start_dimension = 0); |
4588 | 40 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
41 extern OCTAVE_API octave_idx_type get_scalar_idx (Array<octave_idx_type>& idx, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
42 dim_vector& dims); |
4588 | 43 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
44 extern OCTAVE_API octave_idx_type num_ones (const Array<octave_idx_type>& |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
45 ra_idx); |
4588 | 46 |
6108 | 47 extern OCTAVE_API bool is_scalar (const dim_vector& dim); |
4588 | 48 |
23592
80e3bfb7bd5a
maint: Deprecate is_vector and replace with isvector.
Rik <rik@octave.org>
parents:
23443
diff
changeset
|
49 extern OCTAVE_API bool isvector (const dim_vector& dim); |
7642
9a4541c622b5
refactor Array::assignN dimensioning code for empty initial matrices
David Bateman <dbateman@free.fr>
parents:
7246
diff
changeset
|
50 |
6108 | 51 extern OCTAVE_API bool any_ones (const Array<octave_idx_type>& arr); |
4588 | 52 |
10645
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10512
diff
changeset
|
53 // These four compute a linear index for given dimensions, throwing |
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10512
diff
changeset
|
54 // exceptions on invalid indices. |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
55 extern OCTAVE_API octave_idx_type |
10645
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10512
diff
changeset
|
56 compute_index (octave_idx_type n, const dim_vector& dims); |
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10512
diff
changeset
|
57 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
58 extern OCTAVE_API octave_idx_type |
10645
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10512
diff
changeset
|
59 compute_index (octave_idx_type i, octave_idx_type j, const dim_vector& dims); |
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10512
diff
changeset
|
60 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
61 extern OCTAVE_API octave_idx_type |
10645
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10512
diff
changeset
|
62 compute_index (octave_idx_type i, octave_idx_type j, octave_idx_type k, |
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10512
diff
changeset
|
63 const dim_vector& dims); |
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10512
diff
changeset
|
64 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
65 extern OCTAVE_API octave_idx_type |
10645
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10512
diff
changeset
|
66 compute_index (const Array<octave_idx_type>& ra_idx, const dim_vector& dims); |
4588 | 67 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
68 extern OCTAVE_API Array<octave_idx_type> |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
69 conv_to_int_array (const Array<octave::idx_vector>& a); |
4588 | 70 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
71 extern OCTAVE_API Array<octave::idx_vector> |
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
72 conv_to_array (const octave::idx_vector *tmp, const octave_idx_type len); |
4588 | 73 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
74 extern OCTAVE_API dim_vector |
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
75 freeze (Array<octave::idx_vector>& ra_idx, const dim_vector& dimensions, |
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
76 int resize_ok); |
4588 | 77 |
6108 | 78 extern OCTAVE_API bool vector_equivalent (const dim_vector& dv); |
4588 | 79 |
31812
174a224a85ab
Add change accidentally left out of changeset 8e6a9cf412c1.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
80 OCTAVE_DEPRECATED (9, "all_ok (Array<octave::idx_vector>&) is obsolete and always returns true") |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
81 extern OCTAVE_API bool all_ok (const Array<octave::idx_vector>& ra_idx); |
4588 | 82 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
83 extern OCTAVE_API bool |
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
84 any_orig_empty (const Array<octave::idx_vector>& ra_idx); |
4588 | 85 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
86 extern OCTAVE_API bool |
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
87 all_colon_equiv (const Array<octave::idx_vector>& ra_idx, |
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
88 const dim_vector& frozen_lengths); |
4588 | 89 |
6108 | 90 extern OCTAVE_API bool all_ones (const Array<octave_idx_type>& arr); |
4588 | 91 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
92 extern OCTAVE_API Array<octave_idx_type> |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
93 get_elt_idx (const Array<octave::idx_vector>& ra_idx, |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
94 const Array<octave_idx_type>& result_idx); |
4588 | 95 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
96 extern OCTAVE_API Array<octave_idx_type> get_ra_idx (octave_idx_type idx, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
97 const dim_vector& dims); |
4588 | 98 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
99 extern OCTAVE_API dim_vector |
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
100 zero_dims_inquire (const Array<octave::idx_vector>& ia, const dim_vector& rhdv); |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
101 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
102 extern OCTAVE_API dim_vector |
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
103 zero_dims_inquire (const octave::idx_vector& i, const octave::idx_vector& j, |
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
104 const dim_vector& rhdv); |
4588 | 105 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
106 extern OCTAVE_API octave::idx_vector |
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
107 sub2ind (const dim_vector& dv, const Array<octave::idx_vector>& idxa); |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
108 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
109 extern OCTAVE_API Array<octave::idx_vector> |
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
110 ind2sub (const dim_vector& dv, const octave::idx_vector& idx); |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
111 |
7241 | 112 struct |
113 permute_vector | |
114 { | |
115 octave_idx_type pidx; | |
116 octave_idx_type iidx; | |
117 }; | |
118 | |
7246 | 119 extern int OCTAVE_API permute_vector_compare (const void *a, const void *b); |
7241 | 120 |
4588 | 121 #endif |