GNU Octave  4.4.1
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-2018 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_Array_util_h)
24 #define octave_Array_util_h 1
25 
26 #include "octave-config.h"
27 
28 #include "Array.h"
29 #include "lo-array-errwarn.h"
30 
31 extern OCTAVE_API bool index_in_bounds (const Array<octave_idx_type>& ra_idx,
32  const dim_vector& dimensions);
33 
34 extern OCTAVE_API void increment_index (Array<octave_idx_type>& ra_idx,
35  const dim_vector& dimensions,
36  int start_dimension = 0);
37 
39  dim_vector& dims);
40 
41 extern OCTAVE_API octave_idx_type num_ones (const Array<octave_idx_type>&
42  ra_idx);
43 
44 extern OCTAVE_API bool is_scalar (const dim_vector& dim);
45 
46 extern OCTAVE_API bool isvector (const dim_vector& dim);
47 
48 extern OCTAVE_API bool any_ones (const Array<octave_idx_type>& arr);
49 
50 // These four compute a linear index for given dimensions, throwing
51 // exceptions on invalid indices.
52 extern OCTAVE_API octave_idx_type
54 
55 extern OCTAVE_API octave_idx_type
57 
58 extern OCTAVE_API octave_idx_type
60  const dim_vector& dims);
61 
62 extern OCTAVE_API octave_idx_type
64 
65 extern OCTAVE_API Array<octave_idx_type>
67 
68 extern OCTAVE_API Array<idx_vector> conv_to_array (const idx_vector *tmp,
69  const octave_idx_type len);
70 
71 extern OCTAVE_API dim_vector freeze (Array<idx_vector>& ra_idx,
72  const dim_vector& dimensions,
73  int resize_ok);
74 
75 extern OCTAVE_API bool vector_equivalent (const dim_vector& dv);
76 
77 extern OCTAVE_API bool all_ok (const Array<idx_vector>& ra_idx);
78 
79 extern OCTAVE_API bool any_orig_empty (const Array<idx_vector>& ra_idx);
80 
81 extern OCTAVE_API bool all_colon_equiv (const Array<idx_vector>& ra_idx,
82  const dim_vector& frozen_lengths);
83 
84 extern OCTAVE_API bool all_ones (const Array<octave_idx_type>& arr);
85 
86 extern OCTAVE_API Array<octave_idx_type>
88  const Array<octave_idx_type>& result_idx);
89 
91  const dim_vector& dims);
92 
93 extern OCTAVE_API dim_vector zero_dims_inquire (const Array<idx_vector>& ia,
94  const dim_vector& rhdv);
95 
96 extern OCTAVE_API dim_vector zero_dims_inquire (const idx_vector& i,
97  const idx_vector& j,
98  const dim_vector& rhdv);
99 
100 extern OCTAVE_API idx_vector sub2ind (const dim_vector& dv,
101  const Array<idx_vector>& idxa);
102 
103 extern OCTAVE_API Array<idx_vector> ind2sub (const dim_vector& dv,
104  const idx_vector& idx);
105 
106 struct
108 {
111 };
112 
113 extern int OCTAVE_API permute_vector_compare (const void *a, const void *b);
114 
115 #endif
int OCTAVE_API permute_vector_compare(const void *a, const void *b)
Definition: Array-util.cc:663
const octave_base_value const Array< octave_idx_type > & ra_idx
OCTAVE_API octave_idx_type get_scalar_idx(Array< octave_idx_type > &idx, dim_vector &dims)
Definition: Array-util.cc:79
for large enough k
Definition: lu.cc:617
OCTAVE_API bool isvector(const dim_vector &dim)
Definition: Array-util.cc:138
OCTAVE_API void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension=0)
Definition: Array-util.cc:58
OCTAVE_API Array< octave_idx_type > get_ra_idx(octave_idx_type idx, const dim_vector &dims)
Definition: Array-util.cc:393
OCTAVE_API bool is_scalar(const dim_vector &dim)
Definition: Array-util.cc:114
OCTAVE_API idx_vector sub2ind(const dim_vector &dv, const Array< idx_vector > &idxa)
Definition: Array-util.cc:533
OCTAVE_API Array< idx_vector > conv_to_array(const idx_vector *tmp, const octave_idx_type len)
Definition: Array-util.cc:248
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
OCTAVE_API bool all_ones(const Array< octave_idx_type > &arr)
Definition: Array-util.cc:362
OCTAVE_API bool vector_equivalent(const dim_vector &dv)
Definition: Array-util.cc:279
OCTAVE_API bool index_in_bounds(const Array< octave_idx_type > &ra_idx, const dim_vector &dimensions)
Definition: Array-util.cc:33
OCTAVE_API Array< octave_idx_type > conv_to_int_array(const Array< idx_vector > &a)
Definition: Array-util.cc:237
OCTAVE_API octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
Definition: Array-util.cc:175
OCTAVE_API octave_idx_type num_ones(const Array< octave_idx_type > &ra_idx)
Definition: Array-util.cc:100
double tmp
Definition: data.cc:6252
OCTAVE_API bool any_ones(const Array< octave_idx_type > &arr)
Definition: Array-util.cc:158
the exceeded dimensions are set to if fewer subscripts than dimensions are the exceeding dimensions are merged into the final requested dimension For consider the following dims
Definition: sub2ind.cc:255
OCTAVE_API Array< idx_vector > ind2sub(const dim_vector &dv, const idx_vector &idx)
Definition: Array-util.cc:618
OCTAVE_API bool all_colon_equiv(const Array< idx_vector > &ra_idx, const dim_vector &frozen_lengths)
Definition: Array-util.cc:338
OCTAVE_API Array< octave_idx_type > get_elt_idx(const Array< idx_vector > &ra_idx, const Array< octave_idx_type > &result_idx)
Definition: Array-util.cc:379
OCTAVE_API bool all_ok(const Array< idx_vector > &ra_idx)
Definition: Array-util.cc:300
OCTAVE_API dim_vector zero_dims_inquire(const Array< idx_vector > &ia, const dim_vector &rhdv)
Definition: Array-util.cc:427
b
Definition: cellfun.cc:400
octave_idx_type iidx
Definition: Array-util.h:110
for i
Definition: data.cc:5264
octave_idx_type pidx
Definition: Array-util.h:109
OCTAVE_API bool any_orig_empty(const Array< idx_vector > &ra_idx)
Definition: Array-util.cc:319
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
dim_vector dv
Definition: sub2ind.cc:263
OCTAVE_API dim_vector freeze(Array< idx_vector > &ra_idx, const dim_vector &dimensions, int resize_ok)
Definition: Array-util.cc:259