annotate liboctave/Array-util.h @ 11129:0de5cc44e690

use gripe functions for NaN to logical and NaN to character conversions more consistently
author John W. Eaton <jwe@octave.org>
date Thu, 21 Oct 2010 16:12:00 -0400
parents 8645b7087859
children 7c573eb981eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
1 /*
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
2
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8290
diff changeset
3 Copyright (C) 2000, 2003, 2004, 2005, 2006, 2007, 2008 John W. Eaton
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
4
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
6
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
10 option) any later version.
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
11
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
15 for more details.
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
16
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
19 <http://www.gnu.org/licenses/>.
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
20
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
21 */
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
22
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
23 #if !defined (octave_Array_util_h)
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
24 #define octave_Array_util_h 1
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
25
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
26 #include <cassert>
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
27
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
28 #include "Array.h"
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
29 #include "dim-vector.h"
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
30 #include "idx-vector.h"
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
31 #include "lo-error.h"
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
32
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
33 extern OCTAVE_API bool index_in_bounds (const Array<octave_idx_type>& ra_idx,
10312
cbc402e64d83 untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
34 const dim_vector& dimensions);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
35
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
36 extern OCTAVE_API void increment_index (Array<octave_idx_type>& ra_idx,
10312
cbc402e64d83 untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
37 const dim_vector& dimensions,
cbc402e64d83 untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
38 int start_dimension = 0);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
39
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
40 extern OCTAVE_API octave_idx_type get_scalar_idx (Array<octave_idx_type>& idx, dim_vector& dims);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
41
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
42 extern OCTAVE_API octave_idx_type num_ones (const Array<octave_idx_type>& ra_idx);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
43
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
44 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
45
7642
9a4541c622b5 refactor Array::assignN dimensioning code for empty initial matrices
David Bateman <dbateman@free.fr>
parents: 7246
diff changeset
46 extern OCTAVE_API bool is_vector (const dim_vector& dim);
9a4541c622b5 refactor Array::assignN dimensioning code for empty initial matrices
David Bateman <dbateman@free.fr>
parents: 7246
diff changeset
47
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
48 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
49
10645
8645b7087859 abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents: 10512
diff changeset
50 // 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
51 // exceptions on invalid indices.
8645b7087859 abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents: 10512
diff changeset
52 extern OCTAVE_API octave_idx_type
8645b7087859 abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents: 10512
diff changeset
53 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
54
8645b7087859 abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents: 10512
diff changeset
55 extern OCTAVE_API octave_idx_type
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 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
57
8645b7087859 abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents: 10512
diff changeset
58 extern OCTAVE_API octave_idx_type
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, 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
60 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
61
8645b7087859 abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents: 10512
diff changeset
62 extern OCTAVE_API octave_idx_type
8645b7087859 abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents: 10512
diff changeset
63 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
64
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
65 extern OCTAVE_API Array<octave_idx_type> conv_to_int_array (const Array<idx_vector>& a);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
66
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
67 extern OCTAVE_API Array<idx_vector> conv_to_array (const idx_vector *tmp, const octave_idx_type len);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
68
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
69 extern OCTAVE_API dim_vector freeze (Array<idx_vector>& ra_idx,
10312
cbc402e64d83 untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
70 const dim_vector& dimensions, int resize_ok);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
71
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
72 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
73
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
74 extern OCTAVE_API bool all_ok (const Array<idx_vector>& ra_idx);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
75
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
76 extern OCTAVE_API bool any_orig_empty (const Array<idx_vector>& ra_idx);
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 all_colon_equiv (const Array<idx_vector>& ra_idx,
10312
cbc402e64d83 untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
79 const dim_vector& frozen_lengths);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
80
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
81 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
82
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
83 extern OCTAVE_API Array<octave_idx_type> get_elt_idx (const Array<idx_vector>& ra_idx,
10312
cbc402e64d83 untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
84 const Array<octave_idx_type>& result_idx);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
85
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
86 extern OCTAVE_API Array<octave_idx_type> get_ra_idx (octave_idx_type idx, const dim_vector& dims);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
87
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7922
diff changeset
88 extern OCTAVE_API dim_vector zero_dims_inquire (const Array<idx_vector>& ia,
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7922
diff changeset
89 const dim_vector& rhdv);
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7922
diff changeset
90
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7922
diff changeset
91 extern OCTAVE_API dim_vector zero_dims_inquire (const idx_vector& i, const idx_vector& j,
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 7922
diff changeset
92 const dim_vector& rhdv);
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
93
9479
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
94 extern OCTAVE_API idx_vector sub2ind (const dim_vector& dv, const Array<idx_vector>& idxa);
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
95
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
96 extern OCTAVE_API Array<idx_vector> ind2sub (const dim_vector& dv, const idx_vector& idx);
d9716e3ee0dd supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
97
7241
da540e715d05 [project @ 2007-12-03 22:55:20 by jwe]
jwe
parents: 7017
diff changeset
98 struct
da540e715d05 [project @ 2007-12-03 22:55:20 by jwe]
jwe
parents: 7017
diff changeset
99 permute_vector
da540e715d05 [project @ 2007-12-03 22:55:20 by jwe]
jwe
parents: 7017
diff changeset
100 {
da540e715d05 [project @ 2007-12-03 22:55:20 by jwe]
jwe
parents: 7017
diff changeset
101 octave_idx_type pidx;
da540e715d05 [project @ 2007-12-03 22:55:20 by jwe]
jwe
parents: 7017
diff changeset
102 octave_idx_type iidx;
da540e715d05 [project @ 2007-12-03 22:55:20 by jwe]
jwe
parents: 7017
diff changeset
103 };
da540e715d05 [project @ 2007-12-03 22:55:20 by jwe]
jwe
parents: 7017
diff changeset
104
7246
f81e80674b9b [project @ 2007-12-04 15:49:12 by jwe]
jwe
parents: 7241
diff changeset
105 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
106
10370
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10366
diff changeset
107 extern OCTAVE_API const char *error_id_nonconformant_args;
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10366
diff changeset
108
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10366
diff changeset
109 extern OCTAVE_API const char *error_id_index_out_of_bounds;
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10366
diff changeset
110
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10366
diff changeset
111 extern OCTAVE_API const char *error_id_invalid_index;
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10366
diff changeset
112
7922
935be827eaf8 error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents: 7642
diff changeset
113 extern void OCTAVE_API gripe_nan_to_logical_conversion (void);
935be827eaf8 error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents: 7642
diff changeset
114
11129
0de5cc44e690 use gripe functions for NaN to logical and NaN to character conversions more consistently
John W. Eaton <jwe@octave.org>
parents: 10645
diff changeset
115 extern void OCTAVE_API gripe_nan_to_character_conversion (void);
0de5cc44e690 use gripe functions for NaN to logical and NaN to character conversions more consistently
John W. Eaton <jwe@octave.org>
parents: 10645
diff changeset
116
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
117 extern void OCTAVE_API gripe_nonconformant (const char *op, int op1_len, int op2_len);
4669
334a27c8f453 [project @ 2003-11-26 07:02:42 by jwe]
jwe
parents: 4593
diff changeset
118
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5607
diff changeset
119 extern void OCTAVE_API gripe_nonconformant (const char *op, int op1_nr, int op1_nc,
10312
cbc402e64d83 untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
120 int op2_nr, int op2_nc);
4669
334a27c8f453 [project @ 2003-11-26 07:02:42 by jwe]
jwe
parents: 4593
diff changeset
121
334a27c8f453 [project @ 2003-11-26 07:02:42 by jwe]
jwe
parents: 4593
diff changeset
122
10366
e5ae13b8b2c2 improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
123 extern void OCTAVE_API gripe_nonconformant (const char *op, const dim_vector& op1_dims,
e5ae13b8b2c2 improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
124 const dim_vector& op2_dims);
e5ae13b8b2c2 improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
125
e5ae13b8b2c2 improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
126 extern void OCTAVE_API gripe_index_out_of_range (int nd, int dim,
e5ae13b8b2c2 improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
127 octave_idx_type iext, octave_idx_type ext);
e5ae13b8b2c2 improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
128
e5ae13b8b2c2 improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
129 extern void OCTAVE_API gripe_del_index_out_of_range (bool is1d, octave_idx_type iext,
e5ae13b8b2c2 improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents: 10312
diff changeset
130 octave_idx_type ext);
4669
334a27c8f453 [project @ 2003-11-26 07:02:42 by jwe]
jwe
parents: 4593
diff changeset
131
10489
d47802f0e557 Back out changeset 4e64fbbd5c58
Jaroslav Hajek <highegg@gmail.com>
parents: 10486
diff changeset
132 extern void OCTAVE_API gripe_invalid_index (void);
10370
9c4daf174387 implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents: 10366
diff changeset
133
10425
0677c5d80b77 rewrite 1D sparse indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 10370
diff changeset
134 extern void OCTAVE_API gripe_invalid_resize (void);
0677c5d80b77 rewrite 1D sparse indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 10370
diff changeset
135
10512
aac9f4265048 rewrite sparse indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 10489
diff changeset
136 extern void OCTAVE_API gripe_invalid_assignment_size (void);
aac9f4265048 rewrite sparse indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 10489
diff changeset
137
aac9f4265048 rewrite sparse indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 10489
diff changeset
138 extern void OCTAVE_API gripe_assignment_dimension_mismatch (void);
aac9f4265048 rewrite sparse indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 10489
diff changeset
139
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents:
diff changeset
140 #endif