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 |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
2376
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_complex_matrix_h) |
|
25 #define octave_complex_matrix_h 1 |
|
26 |
|
27 #include <cstdlib> |
|
28 |
3503
|
29 #include <iostream> |
2376
|
30 #include <string> |
|
31 |
|
32 #include "mx-base.h" |
2477
|
33 #include "oct-alloc.h" |
2376
|
34 #include "str-vec.h" |
|
35 |
|
36 #include "error.h" |
4944
|
37 #include "oct-stream.h" |
2376
|
38 #include "ov-base.h" |
3219
|
39 #include "ov-base-mat.h" |
2376
|
40 #include "ov-typeinfo.h" |
|
41 |
|
42 class Octave_map; |
|
43 class octave_value_list; |
|
44 |
|
45 class tree_walker; |
|
46 |
2477
|
47 // Complex matrix values. |
2376
|
48 |
|
49 class |
4513
|
50 octave_complex_matrix : public octave_base_matrix<ComplexNDArray> |
2376
|
51 { |
|
52 public: |
|
53 |
|
54 octave_complex_matrix (void) |
4513
|
55 : octave_base_matrix<ComplexNDArray> () { } |
|
56 |
|
57 octave_complex_matrix (const ComplexNDArray& m) |
|
58 : octave_base_matrix<ComplexNDArray> (m) { } |
2376
|
59 |
|
60 octave_complex_matrix (const ComplexMatrix& m) |
4513
|
61 : octave_base_matrix<ComplexNDArray> (m) { } |
2376
|
62 |
4911
|
63 octave_complex_matrix (const ArrayN<Complex>& m) |
|
64 : octave_base_matrix<ComplexNDArray> (ComplexNDArray (m)) { } |
|
65 |
2376
|
66 octave_complex_matrix (const ComplexDiagMatrix& d) |
4513
|
67 : octave_base_matrix<ComplexNDArray> (ComplexMatrix (d)) { } |
2376
|
68 |
3418
|
69 octave_complex_matrix (const ComplexRowVector& v) |
4513
|
70 : octave_base_matrix<ComplexNDArray> (ComplexMatrix (v)) { } |
2376
|
71 |
3418
|
72 octave_complex_matrix (const ComplexColumnVector& v) |
4513
|
73 : octave_base_matrix<ComplexNDArray> (ComplexMatrix (v)) { } |
2376
|
74 |
|
75 octave_complex_matrix (const octave_complex_matrix& cm) |
4513
|
76 : octave_base_matrix<ComplexNDArray> (cm) { } |
2376
|
77 |
|
78 ~octave_complex_matrix (void) { } |
|
79 |
3933
|
80 octave_value *clone (void) const { return new octave_complex_matrix (*this); } |
|
81 octave_value *empty_clone (void) const { return new octave_complex_matrix (); } |
2376
|
82 |
2410
|
83 octave_value *try_narrowing_conversion (void); |
|
84 |
4686
|
85 void assign (const octave_value_list& idx, const ComplexNDArray& rhs); |
2376
|
86 |
4686
|
87 void assign (const octave_value_list& idx, const NDArray& rhs); |
2376
|
88 |
|
89 bool is_complex_matrix (void) const { return true; } |
|
90 |
|
91 bool is_complex_type (void) const { return true; } |
|
92 |
|
93 bool valid_as_scalar_index (void) const; |
|
94 |
3145
|
95 double double_value (bool = false) const; |
2376
|
96 |
3145
|
97 double scalar_value (bool frc_str_conv = false) const |
|
98 { return double_value (frc_str_conv); } |
2916
|
99 |
2376
|
100 Matrix matrix_value (bool = false) const; |
|
101 |
|
102 Complex complex_value (bool = false) const; |
|
103 |
|
104 ComplexMatrix complex_matrix_value (bool = false) const; |
|
105 |
4550
|
106 ComplexNDArray complex_array_value (bool = false) const { return matrix; } |
4543
|
107 |
5164
|
108 SparseMatrix sparse_matrix_value (bool = false) const; |
|
109 |
|
110 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const; |
|
111 |
3107
|
112 void increment (void) { matrix += Complex (1.0); } |
2376
|
113 |
3107
|
114 void decrement (void) { matrix -= Complex (1.0); } |
2376
|
115 |
4687
|
116 bool save_ascii (std::ostream& os, bool& infnan_warned, |
|
117 bool strip_nan_and_inf); |
|
118 |
|
119 bool load_ascii (std::istream& is); |
|
120 |
|
121 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
122 |
|
123 bool load_binary (std::istream& is, bool swap, |
|
124 oct_mach_info::float_format fmt); |
|
125 |
|
126 #if defined (HAVE_HDF5) |
|
127 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
128 |
|
129 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
130 #endif |
|
131 |
4944
|
132 int write (octave_stream& os, int block_size, |
|
133 oct_data_conv::data_type output_type, int skip, |
|
134 oct_mach_info::float_format flt_fmt) const |
|
135 { |
|
136 // Yes, for compatibility, we drop the imaginary part here. |
|
137 return os.write (matrix_value (true), block_size, output_type, |
|
138 skip, flt_fmt); |
|
139 } |
|
140 |
4643
|
141 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
|
142 |
2376
|
143 private: |
|
144 |
3219
|
145 DECLARE_OCTAVE_ALLOCATOR |
2477
|
146 |
3219
|
147 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
148 }; |
|
149 |
|
150 #endif |
|
151 |
|
152 /* |
|
153 ;;; Local Variables: *** |
|
154 ;;; mode: C++ *** |
|
155 ;;; End: *** |
|
156 */ |