Mercurial > hg > octave-nkf
annotate liboctave/util/lo-array-gripes.cc @ 20330:2db2db2df55b
Automatically convert arrays of java primitives into Octave types (bug #44882)
* libinterp/octave-value/ov-java.cc (box): when the result of a java method is
a java primitive type, these are converted to octave types automatically. We
seem to be handling this correctly for scalars but not for arrays yet. This
fixes it on the java -> octave direction.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Mon, 20 Apr 2015 15:01:27 +0100 |
parents | 4197fc428c7d |
children | dd6345fd8a97 |
rev | line source |
---|---|
11135 | 1 /* |
2 | |
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19605
diff
changeset
|
3 Copyright (C) 2003-2015 John W. Eaton |
11135 | 4 Copyright (C) 2009 VZLU Prague |
5 | |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
10 Free Software Foundation; either version 3 of the License, or (at your | |
11 option) any later version. | |
12 | |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with Octave; see the file COPYING. If not, see | |
20 <http://www.gnu.org/licenses/>. | |
21 | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
28 #include "lo-array-gripes.h" | |
29 #include "lo-error.h" | |
30 | |
31 const char *error_id_nonconformant_args = "Octave:nonconformant-args"; | |
32 | |
33 const char *error_id_index_out_of_bounds = "Octave:index-out-of-bounds"; | |
34 | |
35 const char *error_id_invalid_index = "Octave:invalid-index"; | |
36 | |
19605
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
37 const char *warning_id_nearly_singular_matrix = "Octave:nearly-singular-matrix"; |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
38 |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
39 const char *warning_id_singular_matrix = "Octave:singular-matrix"; |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
40 |
11135 | 41 void |
42 gripe_nan_to_logical_conversion (void) | |
43 { | |
44 (*current_liboctave_error_handler) | |
45 ("invalid conversion from NaN to logical"); | |
46 } | |
47 | |
48 void | |
49 gripe_nan_to_character_conversion (void) | |
50 { | |
51 (*current_liboctave_error_handler) | |
52 ("invalid conversion from NaN to character"); | |
53 } | |
54 | |
55 void | |
56 gripe_nonconformant (const char *op, octave_idx_type op1_len, | |
57 octave_idx_type op2_len) | |
58 { | |
59 const char *err_id = error_id_nonconformant_args; | |
60 | |
61 (*current_liboctave_error_with_id_handler) | |
62 (err_id, "%s: nonconformant arguments (op1 len: %d, op2 len: %d)", | |
63 op, op1_len, op2_len); | |
64 } | |
65 | |
66 void | |
67 gripe_nonconformant (const char *op, | |
68 octave_idx_type op1_nr, octave_idx_type op1_nc, | |
69 octave_idx_type op2_nr, octave_idx_type op2_nc) | |
70 { | |
71 const char *err_id = error_id_nonconformant_args; | |
72 | |
73 (*current_liboctave_error_with_id_handler) | |
74 (err_id, "%s: nonconformant arguments (op1 is %dx%d, op2 is %dx%d)", | |
75 op, op1_nr, op1_nc, op2_nr, op2_nc); | |
76 } | |
77 | |
78 void | |
79 gripe_nonconformant (const char *op, const dim_vector& op1_dims, | |
80 const dim_vector& op2_dims) | |
81 { | |
82 const char *err_id = error_id_nonconformant_args; | |
83 | |
84 std::string op1_dims_str = op1_dims.str (); | |
85 std::string op2_dims_str = op2_dims.str (); | |
86 | |
87 (*current_liboctave_error_with_id_handler) | |
88 (err_id, "%s: nonconformant arguments (op1 is %s, op2 is %s)", | |
89 op, op1_dims_str.c_str (), op2_dims_str.c_str ()); | |
90 } | |
91 | |
92 void | |
93 gripe_index_out_of_range (int nd, int dim, octave_idx_type idx, | |
94 octave_idx_type ext) | |
95 { | |
96 const char *err_id = error_id_index_out_of_bounds; | |
97 | |
98 switch (nd) | |
99 { | |
100 case 1: | |
101 (*current_liboctave_error_with_id_handler) | |
102 (err_id, "A(I): index out of bounds; value %d out of bound %d", | |
103 idx, ext); | |
104 break; | |
105 | |
106 case 2: | |
107 (*current_liboctave_error_with_id_handler) | |
108 (err_id, "A(I,J): %s index out of bounds; value %d out of bound %d", | |
109 (dim == 1) ? "row" : "column", idx, ext); | |
110 break; | |
111 | |
112 default: | |
113 (*current_liboctave_error_with_id_handler) | |
114 (err_id, "A(I,J,...): index to dimension %d out of bounds; value %d out of bound %d", | |
115 dim, idx, ext); | |
116 break; | |
117 } | |
118 } | |
119 | |
120 void | |
121 gripe_del_index_out_of_range (bool is1d, octave_idx_type idx, | |
122 octave_idx_type ext) | |
123 { | |
124 const char *err_id = error_id_index_out_of_bounds; | |
125 | |
126 (*current_liboctave_error_with_id_handler) | |
127 (err_id, "A(%s) = []: index out of bounds; value %d out of bound %d", | |
128 is1d ? "I" : "..,I,..", idx, ext); | |
129 } | |
130 | |
131 void | |
132 gripe_invalid_index (void) | |
133 { | |
134 const char *err_id = error_id_invalid_index; | |
135 | |
136 (*current_liboctave_error_with_id_handler) | |
16779
8fce0ed4894a
Specialize is_empty and numel methods for sparse matrices (debian bug #706376)
David Bateman <dbateman@free.fr>
parents:
15271
diff
changeset
|
137 #ifdef USE_64_BIT_IDX_T |
8fce0ed4894a
Specialize is_empty and numel methods for sparse matrices (debian bug #706376)
David Bateman <dbateman@free.fr>
parents:
15271
diff
changeset
|
138 (err_id, "subscript indices must be either positive integers less than 2^63 or logicals"); |
8fce0ed4894a
Specialize is_empty and numel methods for sparse matrices (debian bug #706376)
David Bateman <dbateman@free.fr>
parents:
15271
diff
changeset
|
139 #else |
8fce0ed4894a
Specialize is_empty and numel methods for sparse matrices (debian bug #706376)
David Bateman <dbateman@free.fr>
parents:
15271
diff
changeset
|
140 (err_id, "subscript indices must be either positive integers less than 2^31 or logicals"); |
8fce0ed4894a
Specialize is_empty and numel methods for sparse matrices (debian bug #706376)
David Bateman <dbateman@free.fr>
parents:
15271
diff
changeset
|
141 #endif |
11135 | 142 } |
143 | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
144 // FIXME: the following is a common error message to resize, |
11135 | 145 // regardless of whether it's called from assign or elsewhere. It |
146 // seems OK to me, but eventually the gripe can be specialized. | |
147 // Anyway, propagating various error messages into procedure is, IMHO, | |
148 // a nonsense. If anything, we should change error handling here (and | |
149 // throughout liboctave) to allow custom handling of errors | |
150 | |
151 void | |
152 gripe_invalid_resize (void) | |
153 { | |
154 (*current_liboctave_error_with_id_handler) | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
155 ("Octave:invalid-resize", |
11590
4ced6b90fffb
style fixes for warning and error messages in source files
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
156 "Invalid resizing operation or ambiguous assignment to an out-of-bounds array element"); |
11135 | 157 } |
158 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
159 void |
11135 | 160 gripe_invalid_assignment_size (void) |
161 { | |
162 (*current_liboctave_error_handler) | |
163 ("A(I) = X: X must have the same size as I"); | |
164 } | |
165 | |
166 void | |
167 gripe_assignment_dimension_mismatch (void) | |
168 { | |
169 (*current_liboctave_error_handler) | |
170 ("A(I,J,...) = X: dimensions mismatch"); | |
171 } | |
172 | |
19605
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
173 void |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
174 gripe_singular_matrix (double rcond) |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
175 { |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
176 if (rcond == 0.0) |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
177 { |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
178 (*current_liboctave_warning_with_id_handler) |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
179 (warning_id_singular_matrix, |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
180 "matrix singular to machine precision"); |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
181 } |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
182 else |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
183 { |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
184 (*current_liboctave_warning_with_id_handler) |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
185 (warning_id_nearly_singular_matrix, |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
186 "matrix singular to machine precision, rcond = %g", rcond); |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
187 } |
a0c7001cf1a8
consistent messages and IDs for singular matrix warnings
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
188 } |