2376
|
1 /* |
|
2 |
|
3 Copyright (C) 1996 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 |
|
23 #if !defined (octave_complex_h) |
|
24 #define octave_complex_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <cstdlib> |
|
31 |
|
32 #include <string> |
|
33 |
|
34 class ostream; |
|
35 |
|
36 #include "mx-base.h" |
|
37 #include "str-vec.h" |
|
38 |
|
39 #include "error.h" |
|
40 #include "ov-base.h" |
|
41 #include "ov-typeinfo.h" |
|
42 |
|
43 class Octave_map; |
|
44 class octave_value_list; |
|
45 |
|
46 class tree_walker; |
|
47 |
|
48 // Real scalar values. |
|
49 |
|
50 class |
|
51 octave_complex : public octave_base_value |
|
52 { |
|
53 public: |
|
54 |
|
55 octave_complex (void) |
|
56 : octave_base_value () { } |
|
57 |
|
58 octave_complex (const Complex& c) |
|
59 : octave_base_value (), scalar (c) { } |
|
60 |
|
61 octave_complex (const octave_complex& c) |
|
62 : octave_base_value (), scalar (c.scalar) { } |
|
63 |
|
64 ~octave_complex (void) { } |
|
65 |
|
66 octave_value *clone (void) { return new octave_complex (*this); } |
|
67 |
|
68 #if 0 |
|
69 void *operator new (size_t size); |
|
70 void operator delete (void *p, size_t size); |
|
71 #endif |
|
72 |
|
73 octave_value index (const octave_value_list& idx) const; |
|
74 |
|
75 int rows (void) const { return 1; } |
|
76 int columns (void) const { return 1; } |
|
77 |
|
78 bool is_defined (void) const { return true; } |
|
79 |
|
80 bool is_complex_scalar (void) const { return true; } |
|
81 |
|
82 octave_value all (void) const { return (scalar != 0.0); } |
|
83 octave_value any (void) const { return (scalar != 0.0); } |
|
84 |
|
85 bool is_complex_type (void) const { return true; } |
|
86 |
|
87 bool is_scalar_type (void) const { return true; } |
|
88 |
|
89 bool is_numeric_type (void) const { return true; } |
|
90 |
|
91 // XXX FIXME XXX ??? |
|
92 bool valid_as_scalar_index (void) const { return false; } |
|
93 bool valid_as_zero_index (void) const { return false; } |
|
94 |
|
95 bool is_true (void) const { return (scalar != 0.0); } |
|
96 |
|
97 bool is_empty (void) const { return (rows () == 0 && columns () == 0); } |
|
98 |
|
99 double double_value (bool = false) const; |
|
100 |
|
101 Matrix matrix_value (bool = false) const; |
|
102 |
|
103 Complex complex_value (bool = false) const; |
|
104 |
|
105 ComplexMatrix complex_matrix_value (bool = false) const; |
|
106 |
|
107 octave_value not (void) const { return octave_value (scalar == 0.0); } |
|
108 |
|
109 octave_value uminus (void) const { return octave_value (- scalar); } |
|
110 |
|
111 octave_value transpose (void) const { return octave_value (scalar); } |
|
112 |
|
113 octave_value hermitian (void) const { return octave_value (conj (scalar)); } |
|
114 |
|
115 void increment (void) { scalar += 1.0; } |
|
116 |
|
117 void decrement (void) { scalar -= 1.0; } |
|
118 |
|
119 void print (ostream& os); |
|
120 |
|
121 int type_id (void) const { return t_id; } |
|
122 |
|
123 string type_name (void) const { return t_name; } |
|
124 |
|
125 static int static_type_id (void) { return t_id; } |
|
126 |
|
127 static void register_type (void) |
|
128 { t_id = octave_value_typeinfo::register_type (t_name); } |
|
129 |
|
130 private: |
|
131 |
|
132 Complex scalar; |
|
133 |
|
134 static int t_id; |
|
135 |
|
136 static const string t_name; |
|
137 }; |
|
138 |
|
139 #endif |
|
140 |
|
141 /* |
|
142 ;;; Local Variables: *** |
|
143 ;;; mode: C++ *** |
|
144 ;;; End: *** |
|
145 */ |