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 (octave_complex_h) |
|
24 #define octave_complex_h 1 |
|
25 |
4192
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
2376
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <cstdlib> |
|
31 |
3503
|
32 #include <iostream> |
2376
|
33 #include <string> |
|
34 |
|
35 #include "mx-base.h" |
2477
|
36 #include "oct-alloc.h" |
2376
|
37 #include "str-vec.h" |
|
38 |
|
39 #include "error.h" |
|
40 #include "ov-base.h" |
4749
|
41 #include "ov-cx-mat.h" |
3223
|
42 #include "ov-base-scalar.h" |
2376
|
43 #include "ov-typeinfo.h" |
|
44 |
|
45 class Octave_map; |
|
46 class octave_value_list; |
|
47 |
|
48 class tree_walker; |
|
49 |
2477
|
50 // Complex scalar values. |
2376
|
51 |
|
52 class |
3223
|
53 octave_complex : public octave_base_scalar<Complex> |
2376
|
54 { |
|
55 public: |
|
56 |
|
57 octave_complex (void) |
3223
|
58 : octave_base_scalar<Complex> () { } |
2376
|
59 |
|
60 octave_complex (const Complex& c) |
3223
|
61 : octave_base_scalar<Complex> (c) { } |
2376
|
62 |
|
63 octave_complex (const octave_complex& c) |
3223
|
64 : octave_base_scalar<Complex> (c) { } |
2376
|
65 |
|
66 ~octave_complex (void) { } |
|
67 |
3933
|
68 octave_value *clone (void) const { return new octave_complex (*this); } |
4749
|
69 |
|
70 // We return an octave_complex_matrix object here instead of an |
|
71 // octave_complex object so that in expressions like A(2,2,2) = 2 |
|
72 // (for A previously undefined), A will be empty instead of a 1x1 |
|
73 // object. |
|
74 octave_value *empty_clone (void) const |
|
75 { return new octave_complex_matrix (); } |
2376
|
76 |
2410
|
77 octave_value *try_narrowing_conversion (void); |
|
78 |
3933
|
79 octave_value do_index_op (const octave_value_list& idx, int resize_ok); |
2376
|
80 |
|
81 bool is_complex_scalar (void) const { return true; } |
|
82 |
|
83 bool is_complex_type (void) const { return true; } |
|
84 |
|
85 // XXX FIXME XXX ??? |
|
86 bool valid_as_scalar_index (void) const { return false; } |
|
87 bool valid_as_zero_index (void) const { return false; } |
|
88 |
|
89 double double_value (bool = false) const; |
|
90 |
3145
|
91 double scalar_value (bool frc_str_conv = false) const |
|
92 { return double_value (frc_str_conv); } |
2916
|
93 |
2376
|
94 Matrix matrix_value (bool = false) const; |
|
95 |
4569
|
96 NDArray array_value (bool = false) const; |
|
97 |
4915
|
98 octave_value resize (const dim_vector& dv) const |
|
99 { ComplexNDArray retval (dv); if (dv.numel()) retval(0) = scalar; return retval; } |
|
100 |
2376
|
101 Complex complex_value (bool = false) const; |
|
102 |
|
103 ComplexMatrix complex_matrix_value (bool = false) const; |
|
104 |
4569
|
105 ComplexNDArray complex_array_value (bool = false) const; |
|
106 |
2376
|
107 void increment (void) { scalar += 1.0; } |
|
108 |
|
109 void decrement (void) { scalar -= 1.0; } |
|
110 |
4687
|
111 bool save_ascii (std::ostream& os, bool& infnan_warned, |
|
112 bool strip_nan_and_inf); |
|
113 |
|
114 bool load_ascii (std::istream& is); |
|
115 |
|
116 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
117 |
|
118 bool load_binary (std::istream& is, bool swap, |
|
119 oct_mach_info::float_format fmt); |
|
120 |
|
121 #if defined (HAVE_HDF5) |
|
122 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
123 |
|
124 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
125 #endif |
|
126 |
2376
|
127 private: |
|
128 |
4612
|
129 DECLARE_OCTAVE_ALLOCATOR |
2477
|
130 |
4612
|
131 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
132 }; |
|
133 |
|
134 #endif |
|
135 |
|
136 /* |
|
137 ;;; Local Variables: *** |
|
138 ;;; mode: C++ *** |
|
139 ;;; End: *** |
|
140 */ |