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 |
|
36 #include "ov-ch-mat.h" |
|
37 #include "gripes.h" |
|
38 #include "pr-output.h" |
|
39 |
2477
|
40 octave_allocator |
|
41 octave_char_matrix::allocator (sizeof (octave_char_matrix)); |
2376
|
42 |
2477
|
43 int |
|
44 octave_char_matrix::t_id (-1); |
|
45 |
|
46 const string |
|
47 octave_char_matrix::t_name ("char matrix"); |
2376
|
48 |
|
49 bool |
|
50 octave_char_matrix::valid_as_scalar_index (void) const |
|
51 { |
|
52 // XXX FIXME XXX |
|
53 return false; |
|
54 } |
|
55 |
|
56 bool |
|
57 octave_char_matrix::valid_as_zero_index (void) const |
|
58 { |
|
59 // XXX FIXME XXX |
|
60 return false; |
|
61 } |
|
62 |
|
63 bool |
|
64 octave_char_matrix::is_true (void) const |
|
65 { |
|
66 // XXX FIXME XXX |
|
67 return false; |
|
68 } |
|
69 |
|
70 double |
|
71 octave_char_matrix::double_value (bool) const |
|
72 { |
|
73 double retval = octave_NaN; |
|
74 |
|
75 if ((rows () == 1 && columns () == 1) |
|
76 || (Vdo_fortran_indexing && rows () > 0 && columns () > 0)) |
|
77 retval = matrix (0, 0); |
|
78 else |
|
79 gripe_invalid_conversion ("character matrix", "real scalar"); |
|
80 |
|
81 return retval; |
|
82 } |
|
83 |
|
84 Complex |
|
85 octave_char_matrix::complex_value (bool) const |
|
86 { |
|
87 Complex retval (octave_NaN, octave_NaN); |
|
88 |
|
89 if ((rows () == 1 && columns () == 1) |
|
90 || (Vdo_fortran_indexing && rows () > 0 && columns () > 0)) |
|
91 retval = matrix (0, 0); |
|
92 else |
|
93 gripe_invalid_conversion ("character matrix", "complex scalar"); |
|
94 |
|
95 return retval; |
|
96 } |
|
97 |
|
98 void |
2901
|
99 octave_char_matrix::print (ostream& os, bool pr_as_read_syntax) const |
|
100 { |
|
101 print_raw (os, pr_as_read_syntax); |
|
102 newline (os); |
|
103 } |
|
104 |
|
105 void |
|
106 octave_char_matrix::print_raw (ostream& os, bool pr_as_read_syntax) const |
|
107 { |
|
108 octave_print_internal (os, matrix, pr_as_read_syntax, false, |
|
109 current_print_indent_level ()); |
|
110 } |
|
111 |
|
112 bool |
|
113 octave_char_matrix::print_name_tag (ostream& os, const string& name) const |
2376
|
114 { |
2901
|
115 bool retval = false; |
|
116 |
|
117 int nr = rows (); |
|
118 int nc = columns (); |
|
119 |
|
120 indent (os); |
|
121 |
|
122 if (nr == 1 && nc == 1 || (nr == 0 || nc == 0)) |
|
123 os << name << " = "; |
|
124 else |
|
125 { |
|
126 os << name << " ="; |
|
127 newline (os); |
|
128 newline (os); |
|
129 retval = true; |
|
130 } |
|
131 |
|
132 return retval; |
2376
|
133 } |
|
134 |
|
135 /* |
|
136 ;;; Local Variables: *** |
|
137 ;;; mode: C++ *** |
|
138 ;;; End: *** |
|
139 */ |