2376
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
2376
|
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 #if defined (__GNUG__) |
|
24 #pragma implementation |
|
25 #endif |
|
26 |
|
27 #ifdef HAVE_CONFIG_H |
|
28 #include <config.h> |
|
29 #endif |
|
30 |
2901
|
31 #include <iostream.h> |
|
32 |
2376
|
33 #include "lo-ieee.h" |
|
34 #include "mx-base.h" |
|
35 |
3219
|
36 #include "ov-base.h" |
|
37 #include "ov-base-mat.h" |
|
38 #include "ov-base-mat.cc" |
2376
|
39 #include "ov-ch-mat.h" |
|
40 #include "gripes.h" |
|
41 #include "pr-output.h" |
|
42 |
3219
|
43 template class octave_base_matrix<charMatrix>; |
2376
|
44 |
3219
|
45 DEFINE_OCTAVE_ALLOCATOR (octave_char_matrix); |
2477
|
46 |
3219
|
47 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_char_matrix, "char matrix"); |
2376
|
48 |
|
49 bool |
|
50 octave_char_matrix::valid_as_scalar_index (void) const |
|
51 { |
3136
|
52 bool retval = false; |
|
53 error ("octave_char_matrix::valid_as_scalar_index(): not implemented"); |
|
54 return retval; |
2376
|
55 } |
|
56 |
|
57 bool |
|
58 octave_char_matrix::valid_as_zero_index (void) const |
|
59 { |
3136
|
60 bool retval = false; |
|
61 error ("octave_char_matrix::valid_as_zero_index(): not implemented"); |
|
62 return retval; |
2376
|
63 } |
|
64 |
|
65 bool |
|
66 octave_char_matrix::is_true (void) const |
|
67 { |
3136
|
68 bool retval = false; |
|
69 |
|
70 if (rows () == 0 || columns () == 0) |
|
71 { |
|
72 int flag = Vpropagate_empty_matrices; |
|
73 |
|
74 if (flag < 0) |
|
75 warning ("empty matrix used in conditional expression"); |
|
76 else if (flag == 0) |
|
77 error ("empty matrix used in conditional expression"); |
|
78 } |
|
79 else |
|
80 { |
|
81 Matrix m = (matrix.all ()) . all (); |
|
82 |
|
83 retval = (m.rows () == 1 && m.columns () == 1 && m (0, 0) != 0.0); |
|
84 } |
|
85 |
|
86 return retval; |
2376
|
87 } |
|
88 |
|
89 double |
|
90 octave_char_matrix::double_value (bool) const |
|
91 { |
|
92 double retval = octave_NaN; |
|
93 |
|
94 if ((rows () == 1 && columns () == 1) |
|
95 || (Vdo_fortran_indexing && rows () > 0 && columns () > 0)) |
|
96 retval = matrix (0, 0); |
|
97 else |
|
98 gripe_invalid_conversion ("character matrix", "real scalar"); |
|
99 |
|
100 return retval; |
|
101 } |
|
102 |
|
103 Complex |
|
104 octave_char_matrix::complex_value (bool) const |
|
105 { |
|
106 Complex retval (octave_NaN, octave_NaN); |
|
107 |
|
108 if ((rows () == 1 && columns () == 1) |
|
109 || (Vdo_fortran_indexing && rows () > 0 && columns () > 0)) |
|
110 retval = matrix (0, 0); |
|
111 else |
|
112 gripe_invalid_conversion ("character matrix", "complex scalar"); |
|
113 |
|
114 return retval; |
|
115 } |
|
116 |
|
117 /* |
|
118 ;;; Local Variables: *** |
|
119 ;;; mode: C++ *** |
|
120 ;;; End: *** |
|
121 */ |