GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Array-util.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2000-2024 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_Array_util_h)
27 #define octave_Array_util_h 1
28 
29 #include "octave-config.h"
30 
31 #include "Array.h"
32 #include "lo-array-errwarn.h"
33 
35  const dim_vector& dimensions);
36 
38  const dim_vector& dimensions,
39  int start_dimension = 0);
40 
42  dim_vector& dims);
43 
45  ra_idx);
46 
47 extern OCTAVE_API bool is_scalar (const dim_vector& dim);
48 
49 extern OCTAVE_API bool isvector (const dim_vector& dim);
50 
51 extern OCTAVE_API bool any_ones (const Array<octave_idx_type>& arr);
52 
53 // These four compute a linear index for given dimensions, throwing
54 // exceptions on invalid indices.
57 
60 
63  const dim_vector& dims);
64 
67 
70 
73 
76  int resize_ok);
77 
78 extern OCTAVE_API bool vector_equivalent (const dim_vector& dv);
79 
80 OCTAVE_DEPRECATED (9, "all_ok (Array<octave::idx_vector>&) is obsolete and always returns true")
81 extern OCTAVE_API bool all_ok (const Array<octave::idx_vector>& ra_idx);
82 
83 extern OCTAVE_API bool
85 
86 extern OCTAVE_API bool
88  const dim_vector& frozen_lengths);
89 
90 extern OCTAVE_API bool all_ones (const Array<octave_idx_type>& arr);
91 
94  const Array<octave_idx_type>& result_idx);
95 
97  const dim_vector& dims);
98 
100 zero_dims_inquire (const Array<octave::idx_vector>& ia, const dim_vector& rhdv);
101 
102 extern OCTAVE_API dim_vector
103 zero_dims_inquire (const octave::idx_vector& i, const octave::idx_vector& j,
104  const dim_vector& rhdv);
105 
107 sub2ind (const dim_vector& dv, const Array<octave::idx_vector>& idxa);
108 
110 ind2sub (const dim_vector& dv, const octave::idx_vector& idx);
111 
112 struct
114 {
117 };
118 
119 extern int OCTAVE_API permute_vector_compare (const void *a, const void *b);
120 
121 #endif
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
Definition: Array-util.cc:177
Array< octave::idx_vector > conv_to_array(const octave::idx_vector *tmp, const octave_idx_type len)
Definition: Array-util.cc:250
bool is_scalar(const dim_vector &dim)
Definition: Array-util.cc:116
int permute_vector_compare(const void *a, const void *b)
Definition: Array-util.cc:644
dim_vector zero_dims_inquire(const Array< octave::idx_vector > &ia, const dim_vector &rhdv)
Definition: Array-util.cc:408
Array< octave_idx_type > conv_to_int_array(const Array< octave::idx_vector > &a)
Definition: Array-util.cc:239
octave::idx_vector sub2ind(const dim_vector &dv, const Array< octave::idx_vector > &idxa)
Definition: Array-util.cc:503
bool all_ones(const Array< octave_idx_type > &arr)
Definition: Array-util.cc:355
octave_idx_type num_ones(const Array< octave_idx_type > &ra_idx)
Definition: Array-util.cc:102
bool all_colon_equiv(const Array< octave::idx_vector > &ra_idx, const dim_vector &frozen_lengths)
Definition: Array-util.cc:331
Array< octave_idx_type > get_ra_idx(octave_idx_type idx, const dim_vector &dims)
Definition: Array-util.cc:386
Array< octave_idx_type > get_elt_idx(const Array< octave::idx_vector > &ra_idx, const Array< octave_idx_type > &result_idx)
Definition: Array-util.cc:372
void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension=0)
Definition: Array-util.cc:60
bool vector_equivalent(const dim_vector &dv)
Definition: Array-util.cc:281
bool any_ones(const Array< octave_idx_type > &arr)
Definition: Array-util.cc:160
dim_vector freeze(Array< octave::idx_vector > &ra_idx, const dim_vector &dimensions, int resize_ok)
Definition: Array-util.cc:261
bool any_orig_empty(const Array< octave::idx_vector > &ra_idx)
Definition: Array-util.cc:312
Array< octave::idx_vector > ind2sub(const dim_vector &dv, const octave::idx_vector &idx)
Definition: Array-util.cc:598
bool isvector(const dim_vector &dim)
Definition: Array-util.cc:140
bool index_in_bounds(const Array< octave_idx_type > &ra_idx, const dim_vector &dimensions)
Definition: Array-util.cc:35
bool all_ok(const Array< octave::idx_vector > &ra_idx)
Definition: Array-util.cc:303
octave_idx_type get_scalar_idx(Array< octave_idx_type > &idx, dim_vector &dims)
Definition: Array-util.cc:81
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:94
octave::idx_vector idx_vector
Definition: idx-vector.h:1022
#define OCTAVE_API
Definition: main.cc:55
octave_idx_type n
Definition: mx-inlines.cc:761
const octave_base_value const Array< octave_idx_type > & ra_idx
octave_idx_type pidx
Definition: Array-util.h:115
octave_idx_type iidx
Definition: Array-util.h:116
F77_RET_T len
Definition: xerbla.cc:61