2871
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
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 |
4192
|
23 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
2871
|
24 #pragma implementation |
|
25 #endif |
|
26 |
|
27 #ifdef HAVE_CONFIG_H |
|
28 #include <config.h> |
|
29 #endif |
|
30 |
3503
|
31 #include <iostream> |
2901
|
32 |
2871
|
33 #include "lo-ieee.h" |
|
34 #include "mx-base.h" |
|
35 |
|
36 #include "gripes.h" |
|
37 #include "oct-obj.h" |
|
38 #include "ops.h" |
3219
|
39 #include "ov-base.h" |
|
40 #include "ov-base-mat.h" |
|
41 #include "ov-base-mat.cc" |
2871
|
42 #include "ov-bool.h" |
|
43 #include "ov-bool-mat.h" |
|
44 #include "ov-re-mat.h" |
|
45 #include "pr-output.h" |
|
46 |
3219
|
47 template class octave_base_matrix<boolMatrix>; |
2871
|
48 |
3219
|
49 DEFINE_OCTAVE_ALLOCATOR (octave_bool_matrix); |
2871
|
50 |
3219
|
51 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_bool_matrix, "bool matrix"); |
2871
|
52 |
|
53 static octave_value * |
|
54 default_numeric_conversion_function (const octave_value& a) |
|
55 { |
|
56 CAST_CONV_ARG (const octave_bool_matrix&); |
|
57 |
|
58 return new octave_matrix (Matrix (v.bool_matrix_value ())); |
|
59 } |
|
60 |
|
61 type_conv_fcn |
|
62 octave_bool_matrix::numeric_conversion_function (void) const |
|
63 { |
|
64 return default_numeric_conversion_function; |
|
65 } |
|
66 |
|
67 octave_value * |
|
68 octave_bool_matrix::try_narrowing_conversion (void) |
|
69 { |
|
70 octave_value *retval = 0; |
|
71 |
|
72 int nr = matrix.rows (); |
|
73 int nc = matrix.cols (); |
|
74 |
|
75 if (nr == 1 && nc == 1) |
|
76 retval = new octave_bool (matrix (0, 0)); |
|
77 |
|
78 return retval; |
|
79 } |
|
80 |
|
81 bool |
|
82 octave_bool_matrix::valid_as_scalar_index (void) const |
|
83 { |
|
84 // XXX FIXME XXX |
|
85 return false; |
|
86 } |
|
87 |
|
88 double |
|
89 octave_bool_matrix::double_value (bool) const |
|
90 { |
4102
|
91 double retval = lo_ieee_nan_value (); |
2871
|
92 |
|
93 if ((rows () == 1 && columns () == 1) |
|
94 || (Vdo_fortran_indexing && rows () > 0 && columns () > 0)) |
|
95 retval = matrix (0, 0); |
|
96 else |
|
97 gripe_invalid_conversion ("bool matrix", "real scalar"); |
|
98 |
|
99 return retval; |
|
100 } |
|
101 |
|
102 Complex |
|
103 octave_bool_matrix::complex_value (bool) const |
|
104 { |
4102
|
105 double tmp = lo_ieee_nan_value (); |
|
106 |
|
107 Complex retval (tmp, tmp); |
2871
|
108 |
|
109 if ((rows () == 1 && columns () == 1) |
|
110 || (Vdo_fortran_indexing && rows () > 0 && columns () > 0)) |
|
111 retval = matrix (0, 0); |
|
112 else |
|
113 gripe_invalid_conversion ("bool matrix", "complex scalar"); |
|
114 |
|
115 return retval; |
|
116 } |
|
117 |
|
118 /* |
|
119 ;;; Local Variables: *** |
|
120 ;;; mode: C++ *** |
|
121 ;;; End: *** |
|
122 */ |