1741
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1741
|
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 2, or (at your option) any |
|
10 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, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
3503
|
27 #include <iostream> |
1741
|
28 |
2172
|
29 #include "defun.h" |
1741
|
30 #include "error.h" |
|
31 #include "oct-obj.h" |
2982
|
32 #include "pt-arg-list.h" |
3770
|
33 #include "pt-bp.h" |
1741
|
34 #include "pt-exp.h" |
|
35 #include "pt-mat.h" |
2124
|
36 #include "pt-walk.h" |
2201
|
37 #include "utils.h" |
2371
|
38 #include "ov.h" |
|
39 #include "variables.h" |
1741
|
40 |
4460
|
41 // If TRUE, print a warning message for empty elements in a matrix list. |
|
42 static bool Vwarn_empty_list_elements; |
2172
|
43 |
2254
|
44 // The character to fill with when creating string arrays. |
3836
|
45 char Vstring_fill_char = ' '; |
2254
|
46 |
1741
|
47 // General matrices. This list type is much more work to handle than |
|
48 // constant matrices, but it allows us to construct matrices from |
|
49 // other matrices, variables, and functions. |
|
50 |
1827
|
51 // But first, some internal classes that make our job much easier. |
1741
|
52 |
1827
|
53 class |
|
54 tm_row_const |
1741
|
55 { |
1827
|
56 private: |
|
57 |
|
58 class |
4219
|
59 tm_row_const_rep : public octave_base_list<octave_value> |
1827
|
60 { |
|
61 public: |
|
62 |
|
63 tm_row_const_rep (void) |
4765
|
64 : count (1), dv (), |
3110
|
65 all_str (false), some_str (false), is_cmplx (false), |
|
66 all_mt (true), ok (false) { } |
1827
|
67 |
2971
|
68 tm_row_const_rep (const tree_argument_list& row) |
4765
|
69 : count (1), dv (), |
3110
|
70 all_str (false), some_str (false), is_cmplx (false), |
|
71 all_mt (true), ok (false) |
|
72 { init (row); } |
1827
|
73 |
|
74 ~tm_row_const_rep (void) { } |
|
75 |
|
76 int count; |
|
77 |
4765
|
78 dim_vector dv; |
1741
|
79 |
1827
|
80 bool all_str; |
3110
|
81 bool some_str; |
1827
|
82 bool is_cmplx; |
2602
|
83 bool all_mt; |
1827
|
84 |
|
85 bool ok; |
|
86 |
4501
|
87 bool do_init_element (tree_expression *, const octave_value&, bool&); |
|
88 |
2971
|
89 void init (const tree_argument_list&); |
1827
|
90 |
|
91 private: |
|
92 |
|
93 tm_row_const_rep (const tm_row_const_rep&); |
|
94 |
2971
|
95 tm_row_const_rep& operator = (const tm_row_const_rep&); |
2419
|
96 |
3661
|
97 void eval_error (const char *msg, int l, int c, |
|
98 int x = -1, int y = -1) const; |
2419
|
99 |
|
100 void eval_warning (const char *msg, int l, int c) const; |
1827
|
101 }; |
|
102 |
|
103 public: |
|
104 |
4219
|
105 typedef tm_row_const_rep::iterator iterator; |
|
106 typedef tm_row_const_rep::const_iterator const_iterator; |
|
107 |
2990
|
108 tm_row_const (void) |
|
109 : rep (0) { } |
1827
|
110 |
2971
|
111 tm_row_const (const tree_argument_list& row) |
|
112 : rep (new tm_row_const_rep (row)) { } |
1827
|
113 |
2990
|
114 tm_row_const (const tm_row_const& x) |
|
115 : rep (x.rep) |
|
116 { |
|
117 if (rep) |
|
118 rep->count++; |
|
119 } |
1827
|
120 |
|
121 tm_row_const& operator = (const tm_row_const& x) |
2990
|
122 { |
|
123 if (this != &x && rep != x.rep) |
|
124 { |
|
125 if (rep && --rep->count == 0) |
|
126 delete rep; |
1741
|
127 |
2990
|
128 rep = x.rep; |
1827
|
129 |
2990
|
130 if (rep) |
|
131 rep->count++; |
|
132 } |
1741
|
133 |
2990
|
134 return *this; |
|
135 } |
1827
|
136 |
|
137 ~tm_row_const (void) |
2990
|
138 { |
|
139 if (rep && --rep->count == 0) |
|
140 delete rep; |
|
141 } |
1741
|
142 |
4765
|
143 int rows (void) |
|
144 { return (rep->dv.length () > 0 ? rep->dv(0) : 0); } |
|
145 |
|
146 int cols (void) |
|
147 { return (rep->dv.length () > 1 ? rep->dv(1) : 0); } |
|
148 |
|
149 dim_vector dims (void) { return rep->dv; } |
1827
|
150 |
2868
|
151 bool all_strings_p (void) const { return rep->all_str; } |
3110
|
152 bool some_strings_p (void) const { return rep->some_str; } |
2868
|
153 bool complex_p (void) const { return rep->is_cmplx; } |
|
154 bool all_empty_p (void) const { return rep->all_mt; } |
1827
|
155 |
4219
|
156 operator bool () const { return (rep && rep->ok); } |
1827
|
157 |
4219
|
158 iterator begin (void) { return rep->begin (); } |
|
159 const_iterator begin (void) const { return rep->begin (); } |
|
160 |
|
161 iterator end (void) { return rep->end (); } |
|
162 const_iterator end (void) const { return rep->end (); } |
1827
|
163 |
|
164 private: |
|
165 |
|
166 tm_row_const_rep *rep; |
|
167 }; |
|
168 |
4501
|
169 bool |
|
170 tm_row_const::tm_row_const_rep::do_init_element (tree_expression *elt, |
|
171 const octave_value& val, |
|
172 bool& first_elem) |
|
173 { |
|
174 int this_elt_nr = val.rows (); |
|
175 int this_elt_nc = val.columns (); |
|
176 |
4765
|
177 dim_vector this_elt_dv = val.dims (); |
|
178 |
|
179 if (!this_elt_dv.all_zero ()) |
4501
|
180 { |
|
181 all_mt = false; |
|
182 |
|
183 if (first_elem) |
|
184 { |
|
185 first_elem = false; |
|
186 |
4765
|
187 dv.resize (this_elt_dv.length ()); |
|
188 for (int i = 2; i < dv.length (); i++) |
|
189 dv.elem (i) = this_elt_dv.elem (i); |
|
190 |
|
191 dv.elem (0) = this_elt_nr; |
|
192 |
|
193 dv.elem (1) = 0; |
4501
|
194 } |
4765
|
195 else |
4501
|
196 { |
5045
|
197 int len = (this_elt_dv.length () < dv.length () |
|
198 ? this_elt_dv.length () : dv.length ()); |
|
199 |
4765
|
200 if (this_elt_nr != dv (0)) |
|
201 { |
|
202 eval_error ("number of rows must match", |
|
203 elt->line (), elt->column (), this_elt_nr, dv (0)); |
|
204 return false; |
|
205 } |
5045
|
206 for (int i = 2; i < len; i++) |
4765
|
207 { |
|
208 if (this_elt_dv (i) != dv (i)) |
|
209 { |
|
210 eval_error ("dimensions mismatch", elt->line (), elt->column (), this_elt_dv (i), dv (i)); |
|
211 return false; |
|
212 } |
|
213 } |
5045
|
214 |
|
215 if (this_elt_dv.length () > len) |
|
216 for (int i = len; i < this_elt_dv.length (); i++) |
|
217 if (this_elt_dv (i) != 1) |
|
218 { |
|
219 eval_error ("dimensions mismatch", elt->line (), elt->column (), this_elt_dv (i), 1); |
|
220 return false; |
|
221 } |
|
222 |
|
223 if (dv.length () > len) |
|
224 for (int i = len; i < dv.length (); i++) |
|
225 if (dv (i) != 1) |
|
226 { |
|
227 eval_error ("dimensions mismatch", elt->line (), elt->column (), 1, dv (i)); |
|
228 return false; |
|
229 } |
4501
|
230 } |
4765
|
231 dv.elem (1) = dv.elem (1) + this_elt_nc; |
4501
|
232 |
|
233 } |
|
234 else if (Vwarn_empty_list_elements) |
|
235 eval_warning ("empty matrix found in matrix list", |
|
236 elt->line (), elt->column ()); |
|
237 |
4915
|
238 append (val); |
|
239 |
4501
|
240 if (all_str && ! val.is_string ()) |
|
241 all_str = false; |
|
242 |
|
243 if (! some_str && val.is_string ()) |
|
244 some_str = true; |
|
245 |
|
246 if (! is_cmplx && val.is_complex_type ()) |
|
247 is_cmplx = true; |
|
248 |
|
249 return true; |
|
250 } |
|
251 |
1827
|
252 void |
2971
|
253 tm_row_const::tm_row_const_rep::init (const tree_argument_list& row) |
1827
|
254 { |
|
255 all_str = true; |
|
256 |
|
257 bool first_elem = true; |
|
258 |
4219
|
259 for (tree_argument_list::const_iterator p = row.begin (); |
|
260 p != row.end (); |
|
261 p++) |
1827
|
262 { |
4219
|
263 tree_expression *elt = *p; |
1827
|
264 |
2971
|
265 octave_value tmp = elt->rvalue (); |
1827
|
266 |
|
267 if (error_state || tmp.is_undefined ()) |
|
268 break; |
|
269 else |
|
270 { |
4501
|
271 if (tmp.is_cs_list ()) |
1827
|
272 { |
4587
|
273 octave_value_list tlst = tmp.list_value (); |
2602
|
274 |
4587
|
275 for (int i = 0; i < tlst.length (); i++) |
1827
|
276 { |
4587
|
277 if (! do_init_element (elt, tlst(i), first_elem)) |
4501
|
278 goto done; |
1827
|
279 } |
|
280 } |
4501
|
281 else |
|
282 { |
|
283 if (! do_init_element (elt, tmp, first_elem)) |
|
284 goto done; |
|
285 } |
1827
|
286 } |
|
287 } |
|
288 |
4501
|
289 done: |
|
290 |
1827
|
291 ok = ! error_state; |
1741
|
292 } |
|
293 |
2419
|
294 void |
|
295 tm_row_const::tm_row_const_rep::eval_error (const char *msg, int l, |
3661
|
296 int c, int x, int y) const |
2419
|
297 { |
|
298 if (l == -1 && c == -1) |
3661
|
299 { |
|
300 if (x == -1 || y == -1) |
|
301 ::error ("%s", msg); |
|
302 else |
|
303 ::error ("%s (%d != %d)", msg, x, y); |
|
304 } |
2419
|
305 else |
3661
|
306 { |
|
307 if (x == -1 || y == -1) |
|
308 ::error ("%s near line %d, column %d", msg, l, c); |
|
309 else |
|
310 ::error ("%s (%d != %d) near line %d, column %d", msg, x, y, l, c); |
|
311 } |
2419
|
312 } |
|
313 |
|
314 void |
|
315 tm_row_const::tm_row_const_rep::eval_warning (const char *msg, int l, |
|
316 int c) const |
|
317 { |
|
318 if (l == -1 && c == -1) |
|
319 ::warning ("%s", msg); |
|
320 else |
|
321 ::warning ("%s near line %d, column %d", msg, l, c); |
|
322 } |
|
323 |
1827
|
324 class |
4219
|
325 tm_const : public octave_base_list<tm_row_const> |
1827
|
326 { |
|
327 public: |
|
328 |
|
329 tm_const (const tree_matrix& tm) |
4765
|
330 : dv (), all_str (false), some_str (false), is_cmplx (false), |
3110
|
331 all_mt (true), ok (false) |
1827
|
332 { init (tm); } |
|
333 |
|
334 ~tm_const (void) { } |
|
335 |
4765
|
336 int rows (void) const { return (dv.length () > 0 ? dv.elem (0) : 0); } |
|
337 int cols (void) const { return (dv.length () > 1 ? dv.elem (1) : 0); } |
|
338 |
|
339 dim_vector dims (void) const { return dv; } |
1827
|
340 |
2868
|
341 bool all_strings_p (void) const { return all_str; } |
3110
|
342 bool some_strings_p (void) const { return some_str; } |
2868
|
343 bool complex_p (void) const { return is_cmplx; } |
|
344 bool all_empty_p (void) const { return all_mt; } |
1827
|
345 |
3145
|
346 operator bool () const { return ok; } |
1827
|
347 |
|
348 private: |
|
349 |
4765
|
350 dim_vector dv; |
1827
|
351 |
|
352 bool all_str; |
3110
|
353 bool some_str; |
1827
|
354 bool is_cmplx; |
2602
|
355 bool all_mt; |
1827
|
356 |
|
357 bool ok; |
|
358 |
|
359 tm_const (void); |
|
360 |
|
361 tm_const (const tm_const&); |
|
362 |
|
363 tm_const& operator = (const tm_const&); |
|
364 |
|
365 void init (const tree_matrix& tm); |
|
366 }; |
|
367 |
|
368 void |
|
369 tm_const::init (const tree_matrix& tm) |
1741
|
370 { |
1827
|
371 all_str = true; |
|
372 |
|
373 bool first_elem = true; |
|
374 |
|
375 // Just eval and figure out if what we have is complex or all |
|
376 // strings. We can't check columns until we know that this is a |
|
377 // numeric matrix -- collections of strings can have elements of |
|
378 // different lengths. |
|
379 |
4219
|
380 for (tree_matrix::const_iterator p = tm.begin (); p != tm.end (); p++) |
1827
|
381 { |
4219
|
382 tree_argument_list *elt = *p; |
1827
|
383 |
|
384 tm_row_const tmp (*elt); |
|
385 |
|
386 if (tmp) |
|
387 { |
2868
|
388 if (all_str && ! tmp.all_strings_p ()) |
1827
|
389 all_str = false; |
|
390 |
3110
|
391 if (! some_str && tmp.some_strings_p ()) |
|
392 some_str = true; |
|
393 |
2868
|
394 if (! is_cmplx && tmp.complex_p ()) |
1827
|
395 is_cmplx = true; |
|
396 |
2868
|
397 if (all_mt && ! tmp.all_empty_p ()) |
2602
|
398 all_mt = false; |
|
399 |
1827
|
400 append (tmp); |
|
401 } |
|
402 else |
|
403 break; |
|
404 } |
|
405 |
|
406 if (! error_state) |
|
407 { |
4219
|
408 for (iterator p = begin (); p != end (); p++) |
1827
|
409 { |
4219
|
410 tm_row_const elt = *p; |
1827
|
411 |
|
412 int this_elt_nr = elt.rows (); |
|
413 int this_elt_nc = elt.cols (); |
|
414 |
4765
|
415 dim_vector this_elt_dv = elt.dims (); |
|
416 |
|
417 if (!this_elt_dv.all_zero ()) |
1827
|
418 { |
2602
|
419 all_mt = false; |
|
420 |
1827
|
421 if (first_elem) |
|
422 { |
|
423 first_elem = false; |
|
424 |
4765
|
425 dv.resize (this_elt_dv.length ()); |
|
426 for (int i = 2; i < dv.length (); i++) |
|
427 dv.elem (i) = this_elt_dv.elem (i); |
|
428 |
|
429 dv.elem (0) = 0; |
|
430 |
|
431 dv.elem (1) = this_elt_nc; |
1827
|
432 } |
|
433 else if (all_str) |
|
434 { |
4765
|
435 if (this_elt_nc > cols ()) |
|
436 dv.elem (1) = this_elt_nc; |
1827
|
437 } |
4765
|
438 else |
1827
|
439 { |
4765
|
440 bool get_out = false; |
5045
|
441 int len = (this_elt_dv.length () < dv.length () |
|
442 ? this_elt_dv.length () : dv.length ()); |
4765
|
443 |
5045
|
444 for (int i = 1; i < len; i++) |
4765
|
445 { |
|
446 if (i == 1 && this_elt_nc != dv (1)) |
|
447 { |
|
448 ::error ("number of columns must match (%d != %d)", |
|
449 this_elt_nc, dv (1)); |
|
450 get_out = true; |
|
451 break; |
|
452 } |
|
453 else if (this_elt_dv (i) != dv (i)) |
|
454 { |
|
455 ::error ("dimensions mismatch (dim = %i, %d != %d)", i+1, this_elt_dv (i), dv (i)); |
|
456 get_out = true; |
|
457 break; |
|
458 } |
|
459 } |
|
460 |
5045
|
461 if (this_elt_dv.length () > len) |
|
462 for (int i = len; i < this_elt_dv.length (); i++) |
|
463 if (this_elt_dv (i) != 1) |
|
464 { |
|
465 ::error ("dimensions mismatch (dim = %i, %d != %d)", i+1, this_elt_dv (i), 1); |
|
466 get_out = true; |
|
467 break; |
|
468 } |
|
469 |
|
470 if (dv.length () > len) |
|
471 for (int i = len; i < dv.length (); i++) |
|
472 if (dv (i) != 1) |
|
473 { |
|
474 ::error ("dimensions mismatch (dim = %i, %d != %d)", i+1, 1, dv(i)); |
|
475 get_out = true; |
|
476 break; |
|
477 } |
|
478 |
4765
|
479 if (get_out) |
|
480 break; |
1827
|
481 } |
4765
|
482 dv.elem (0) = dv.elem (0) + this_elt_nr; |
1827
|
483 } |
4460
|
484 else if (Vwarn_empty_list_elements) |
|
485 warning ("empty matrix found in matrix list"); |
1827
|
486 } |
|
487 } |
|
488 |
|
489 ok = ! error_state; |
1741
|
490 } |
|
491 |
2990
|
492 tree_matrix::~tree_matrix (void) |
|
493 { |
4219
|
494 while (! empty ()) |
2990
|
495 { |
4219
|
496 iterator p = begin (); |
|
497 delete *p; |
|
498 erase (p); |
2990
|
499 } |
|
500 } |
|
501 |
1827
|
502 bool |
4267
|
503 tree_matrix::has_magic_end (void) const |
|
504 { |
|
505 for (const_iterator p = begin (); p != end (); p++) |
|
506 { |
|
507 tree_argument_list *elt = *p; |
|
508 |
|
509 if (elt && elt->has_magic_end ()) |
|
510 return true; |
|
511 } |
|
512 |
|
513 return false; |
|
514 } |
|
515 |
|
516 bool |
2529
|
517 tree_matrix::all_elements_are_constant (void) const |
1827
|
518 { |
4219
|
519 for (const_iterator p = begin (); p != end (); p++) |
1827
|
520 { |
4219
|
521 tree_argument_list *elt = *p; |
1827
|
522 |
2529
|
523 if (! elt->all_elements_are_constant ()) |
1827
|
524 return false; |
|
525 } |
|
526 |
|
527 return true; |
|
528 } |
|
529 |
2971
|
530 octave_value_list |
|
531 tree_matrix::rvalue (int nargout) |
|
532 { |
|
533 octave_value_list retval; |
|
534 |
3770
|
535 MAYBE_DO_BREAKPOINT; |
|
536 |
2971
|
537 if (nargout > 1) |
|
538 error ("invalid number of output arguments for matrix list"); |
|
539 else |
|
540 retval = rvalue (); |
|
541 |
|
542 return retval; |
|
543 } |
|
544 |
2086
|
545 octave_value |
2971
|
546 tree_matrix::rvalue (void) |
1741
|
547 { |
2086
|
548 octave_value retval; |
1741
|
549 |
4915
|
550 bool all_strings_p = false; |
|
551 bool all_empty_p = false; |
|
552 bool frc_str_conv = false; |
1741
|
553 |
4915
|
554 tm_const tmp (*this); |
3110
|
555 |
1827
|
556 if (tmp) |
|
557 { |
4765
|
558 dim_vector dv = tmp.dims (); |
4915
|
559 all_strings_p = tmp.all_strings_p (); |
|
560 all_empty_p = tmp.all_empty_p (); |
|
561 frc_str_conv = tmp.some_strings_p (); |
1741
|
562 |
4915
|
563 // XXX FIXME XX |
|
564 // The previous version of this code obtained the return type and |
|
565 // initialized an array of the correct type. However the return type |
|
566 // is now built-up from the return types of do_cat_op. Should we special |
|
567 // case the situation where there are only NDArray and ComplexNDArray |
|
568 // elements, or things like boolMatrix that widen to them, and do the |
|
569 // correct initialization? How to do this? Will it be faster? Check against |
|
570 // version 2.1.57 |
|
571 |
|
572 |
|
573 // The line below might seem crazy, since we take a copy |
|
574 // of the first argument, resize it to be empty and then resize |
|
575 // it to be full. This is done since it means that there is no |
|
576 // recopying of data, as would happen if we used a single resize. |
|
577 // It should be noted that resize operation is also significantly |
|
578 // slower than the do_cat_op function, so it makes sense to have an |
|
579 // empty matrix and copy all data. |
|
580 // |
|
581 // We might also start with a empty octave_value using |
|
582 // ctmp = octave_value_typeinfo::lookup_type |
|
583 // (tmp.begin() -> begin() -> type_name()); |
|
584 // and then directly resize. However, for some types there might be |
|
585 // some additional setup needed, and so this should be avoided. |
|
586 |
|
587 octave_value ctmp; |
|
588 if (all_strings_p) |
|
589 if (all_empty_p) |
|
590 ctmp = octave_value (charNDArray (), true); |
|
591 else |
|
592 ctmp = octave_value (charNDArray (dv, Vstring_fill_char), true); |
|
593 else |
|
594 { |
|
595 if (all_empty_p) |
|
596 ctmp = (*(tmp.begin() -> begin())); |
|
597 else |
|
598 ctmp = (*(tmp.begin() -> begin())).resize (dim_vector (0,0)).resize (dv); |
|
599 } |
|
600 |
|
601 if (error_state) |
|
602 goto done; |
1741
|
603 |
1827
|
604 // Now, extract the values from the individual elements and |
|
605 // insert them in the result matrix. |
5144
|
606 int dv_len = dv.length (); |
|
607 Array<int> ra_idx (dv_len > 1 ? dv_len : 2, 0); |
4219
|
608 for (tm_const::iterator p = tmp.begin (); p != tmp.end (); p++) |
1827
|
609 { |
4219
|
610 tm_row_const row = *p; |
|
611 for (tm_row_const::iterator q = row.begin (); q != row.end (); q++) |
1827
|
612 { |
4219
|
613 octave_value elt = *q; |
1741
|
614 |
4915
|
615 ctmp = do_cat_op (ctmp, elt, ra_idx); |
|
616 if (error_state) |
|
617 goto done; |
|
618 ra_idx (1) += elt.columns (); |
1741
|
619 } |
4915
|
620 ra_idx (0) += row.rows (); |
|
621 ra_idx (1) = 0; |
1741
|
622 } |
4915
|
623 retval = ctmp; |
|
624 if (frc_str_conv && ! retval.is_string ()) |
|
625 retval = retval.convert_to_str (); |
1741
|
626 } |
|
627 |
1827
|
628 done: |
1741
|
629 return retval; |
|
630 } |
|
631 |
|
632 void |
2124
|
633 tree_matrix::accept (tree_walker& tw) |
1741
|
634 { |
2124
|
635 tw.visit_matrix (*this); |
1741
|
636 } |
|
637 |
2172
|
638 static int |
4460
|
639 warn_empty_list_elements (void) |
2172
|
640 { |
4460
|
641 Vwarn_empty_list_elements = check_preference ("warn_empty_list_elements"); |
2172
|
642 |
|
643 return 0; |
|
644 } |
|
645 |
2254
|
646 static int |
|
647 string_fill_char (void) |
|
648 { |
|
649 int status = 0; |
|
650 |
3523
|
651 std::string s = builtin_string_variable ("string_fill_char"); |
2254
|
652 |
|
653 switch (s.length ()) |
|
654 { |
|
655 case 1: |
|
656 Vstring_fill_char = s[0]; |
|
657 break; |
|
658 |
|
659 case 0: |
|
660 Vstring_fill_char = '\0'; |
|
661 break; |
|
662 |
|
663 default: |
|
664 warning ("string_fill_char must be a single character"); |
|
665 status = -1; |
|
666 break; |
|
667 } |
|
668 |
|
669 return status; |
|
670 } |
|
671 |
2172
|
672 void |
|
673 symbols_of_pt_mat (void) |
|
674 { |
3258
|
675 DEFVAR (string_fill_char, " ", string_fill_char, |
3361
|
676 "-*- texinfo -*-\n\ |
|
677 @defvr {Built-in Variable} string_fill_char\n\ |
|
678 The value of this variable is used to pad all strings in a string matrix\n\ |
|
679 to the same length. It should be a single character. The default value\n\ |
|
680 is @code{\" \"} (a single space). For example,\n\ |
|
681 \n\ |
|
682 @example\n\ |
|
683 @group\n\ |
|
684 string_fill_char = \"X\";\n\ |
|
685 [ \"these\"; \"are\"; \"strings\" ]\n\ |
|
686 @result{} \"theseXX\"\n\ |
|
687 \"areXXXX\"\n\ |
|
688 \"strings\"\n\ |
|
689 @end group\n\ |
|
690 @end example\n\ |
3363
|
691 @end defvr"); |
4460
|
692 |
|
693 DEFVAR (warn_empty_list_elements, false, warn_empty_list_elements, |
|
694 "-*- texinfo -*-\n\ |
|
695 @defvr {Built-in Variable} warn_empty_list_elements\n\ |
|
696 If the value of @code{warn_empty_list_elements} is nonzero, print a\n\ |
|
697 warning when an empty matrix is found in a matrix list. For example,\n\ |
|
698 \n\ |
|
699 @example\n\ |
|
700 a = [1, [], 3, [], 5]\n\ |
|
701 @end example\n\ |
|
702 \n\ |
|
703 @noindent\n\ |
|
704 The default value is 0.\n\ |
|
705 @end defvr"); |
|
706 |
2172
|
707 } |
|
708 |
1741
|
709 /* |
|
710 ;;; Local Variables: *** |
|
711 ;;; mode: C++ *** |
|
712 ;;; End: *** |
|
713 */ |