annotate liboctave/array/Array-util.h @ 31225:3eab70385569

sparse-xpow.cc: Use faster multiplication technique, this time for complex
author Arun Giridhar <arungiridhar@gmail.com>
date Sun, 11 Sep 2022 13:53:38 -0400
parents 796f54d4ddbf
children 597f3ee61a48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29569
diff changeset
3 // Copyright (C) 2000-2022 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
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
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
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
27 #define octave_Array_util_h 1
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
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
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
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
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
33
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
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
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
36
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
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
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
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
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
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
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
46
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
47 extern OCTAVE_API bool is_scalar (const dim_vector& dim);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
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
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
51 extern OCTAVE_API bool any_ones (const Array<octave_idx_type>& arr);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
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
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
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
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
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
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
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
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
77
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
78 extern OCTAVE_API bool vector_equivalent (const dim_vector& dv);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
79
29569
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
80 extern OCTAVE_API bool all_ok (const Array<octave::idx_vector>& ra_idx);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
81
29569
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
82 extern OCTAVE_API bool
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
83 any_orig_empty (const Array<octave::idx_vector>& ra_idx);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
84
29569
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
85 extern OCTAVE_API bool
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
86 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
87 const dim_vector& frozen_lengths);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
88
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
89 extern OCTAVE_API bool all_ones (const Array<octave_idx_type>& arr);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
90
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
91 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
92 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
93 const Array<octave_idx_type>& result_idx);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
94
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
95 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
96 const dim_vector& dims);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
97
29569
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
98 extern OCTAVE_API dim_vector
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
99 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
100
29569
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
101 extern OCTAVE_API dim_vector
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
102 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
103 const dim_vector& rhdv);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
104
29569
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
105 extern OCTAVE_API octave::idx_vector
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
106 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
107
29569
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
108 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
109 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
110
7241
da540e715d05 [project @ 2007-12-03 22:55:20 by jwe]
jwe
parents: 7017
diff changeset
111 struct
da540e715d05 [project @ 2007-12-03 22:55:20 by jwe]
jwe
parents: 7017
diff changeset
112 permute_vector
da540e715d05 [project @ 2007-12-03 22:55:20 by jwe]
jwe
parents: 7017
diff changeset
113 {
da540e715d05 [project @ 2007-12-03 22:55:20 by jwe]
jwe
parents: 7017
diff changeset
114 octave_idx_type pidx;
da540e715d05 [project @ 2007-12-03 22:55:20 by jwe]
jwe
parents: 7017
diff changeset
115 octave_idx_type iidx;
da540e715d05 [project @ 2007-12-03 22:55:20 by jwe]
jwe
parents: 7017
diff changeset
116 };
da540e715d05 [project @ 2007-12-03 22:55:20 by jwe]
jwe
parents: 7017
diff changeset
117
7246
f81e80674b9b [project @ 2007-12-04 15:49:12 by jwe]
jwe
parents: 7241
diff changeset
118 extern int OCTAVE_API permute_vector_compare (const void *a, const void *b);
7241
da540e715d05 [project @ 2007-12-03 22:55:20 by jwe]
jwe
parents: 7017
diff changeset
119
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
120 #endif