GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Array-util.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2000-2017 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 the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 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 <http://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 "dim-vector.h"
30 #include "idx-vector.h"
31 #include "lo-array-errwarn.h"
32 
33 extern OCTAVE_API bool index_in_bounds (const Array<octave_idx_type>& ra_idx,
34  const dim_vector& dimensions);
35 
36 extern OCTAVE_API void increment_index (Array<octave_idx_type>& ra_idx,
37  const dim_vector& dimensions,
38  int start_dimension = 0);
39 
41  dim_vector& dims);
42 
43 extern OCTAVE_API octave_idx_type num_ones (const Array<octave_idx_type>&
44  ra_idx);
45 
46 extern OCTAVE_API bool is_scalar (const dim_vector& dim);
47 
48 extern OCTAVE_API bool is_vector (const dim_vector& dim);
49 
50 extern OCTAVE_API bool any_ones (const Array<octave_idx_type>& arr);
51 
52 // These four compute a linear index for given dimensions, throwing
53 // exceptions on invalid indices.
54 extern OCTAVE_API octave_idx_type
56 
57 extern OCTAVE_API octave_idx_type
59 
60 extern OCTAVE_API octave_idx_type
62  const dim_vector& dims);
63 
64 extern OCTAVE_API octave_idx_type
66 
67 extern OCTAVE_API Array<octave_idx_type>
69 
70 extern OCTAVE_API Array<idx_vector> conv_to_array (const idx_vector *tmp,
71  const octave_idx_type len);
72 
73 extern OCTAVE_API dim_vector freeze (Array<idx_vector>& ra_idx,
74  const dim_vector& dimensions,
75  int resize_ok);
76 
77 extern OCTAVE_API bool vector_equivalent (const dim_vector& dv);
78 
79 extern OCTAVE_API bool all_ok (const Array<idx_vector>& ra_idx);
80 
81 extern OCTAVE_API bool any_orig_empty (const Array<idx_vector>& ra_idx);
82 
83 extern OCTAVE_API bool all_colon_equiv (const Array<idx_vector>& ra_idx,
84  const dim_vector& frozen_lengths);
85 
86 extern OCTAVE_API bool all_ones (const Array<octave_idx_type>& arr);
87 
88 extern OCTAVE_API Array<octave_idx_type>
90  const Array<octave_idx_type>& result_idx);
91 
93  const dim_vector& dims);
94 
95 extern OCTAVE_API dim_vector zero_dims_inquire (const Array<idx_vector>& ia,
96  const dim_vector& rhdv);
97 
98 extern OCTAVE_API dim_vector zero_dims_inquire (const idx_vector& i,
99  const idx_vector& j,
100  const dim_vector& rhdv);
101 
102 extern OCTAVE_API idx_vector sub2ind (const dim_vector& dv,
103  const Array<idx_vector>& idxa);
104 
105 extern OCTAVE_API Array<idx_vector> ind2sub (const dim_vector& dv,
106  const idx_vector& idx);
107 
108 struct
110 {
113 };
114 
115 extern int OCTAVE_API permute_vector_compare (const void *a, const void *b);
116 
117 #endif
int OCTAVE_API permute_vector_compare(const void *a, const void *b)
Definition: Array-util.cc:664
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:80
for large enough k
Definition: lu.cc:606
OCTAVE_API void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension=0)
Definition: Array-util.cc:59
OCTAVE_API Array< octave_idx_type > get_ra_idx(octave_idx_type idx, const dim_vector &dims)
Definition: Array-util.cc:394
OCTAVE_API bool is_scalar(const dim_vector &dim)
Definition: Array-util.cc:115
OCTAVE_API idx_vector sub2ind(const dim_vector &dv, const Array< idx_vector > &idxa)
Definition: Array-util.cc:534
OCTAVE_API Array< idx_vector > conv_to_array(const idx_vector *tmp, const octave_idx_type len)
Definition: Array-util.cc:249
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:398
OCTAVE_API bool all_ones(const Array< octave_idx_type > &arr)
Definition: Array-util.cc:363
OCTAVE_API bool vector_equivalent(const dim_vector &dv)
Definition: Array-util.cc:280
OCTAVE_API bool index_in_bounds(const Array< octave_idx_type > &ra_idx, const dim_vector &dimensions)
Definition: Array-util.cc:34
OCTAVE_API Array< octave_idx_type > conv_to_int_array(const Array< idx_vector > &a)
Definition: Array-util.cc:238
OCTAVE_API octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
Definition: Array-util.cc:176
OCTAVE_API octave_idx_type num_ones(const Array< octave_idx_type > &ra_idx)
Definition: Array-util.cc:101
double tmp
Definition: data.cc:6300
OCTAVE_API bool any_ones(const Array< octave_idx_type > &arr)
Definition: Array-util.cc:159
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:619
OCTAVE_API bool is_vector(const dim_vector &dim)
Definition: Array-util.cc:139
OCTAVE_API bool all_colon_equiv(const Array< idx_vector > &ra_idx, const dim_vector &frozen_lengths)
Definition: Array-util.cc:339
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:380
OCTAVE_API bool all_ok(const Array< idx_vector > &ra_idx)
Definition: Array-util.cc:301
OCTAVE_API dim_vector zero_dims_inquire(const Array< idx_vector > &ia, const dim_vector &rhdv)
Definition: Array-util.cc:428
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
b
Definition: cellfun.cc:398
octave_idx_type iidx
Definition: Array-util.h:112
octave_idx_type pidx
Definition: Array-util.h:111
OCTAVE_API bool any_orig_empty(const Array< idx_vector > &ra_idx)
Definition: Array-util.cc:320
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:260