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 |
5785
|
42 #include "MatrixType.h" |
|
43 |
2376
|
44 class Octave_map; |
|
45 class octave_value_list; |
|
46 |
|
47 class tree_walker; |
|
48 |
2477
|
49 // Complex matrix values. |
2376
|
50 |
|
51 class |
4513
|
52 octave_complex_matrix : public octave_base_matrix<ComplexNDArray> |
2376
|
53 { |
|
54 public: |
|
55 |
|
56 octave_complex_matrix (void) |
4513
|
57 : octave_base_matrix<ComplexNDArray> () { } |
|
58 |
|
59 octave_complex_matrix (const ComplexNDArray& m) |
|
60 : octave_base_matrix<ComplexNDArray> (m) { } |
2376
|
61 |
|
62 octave_complex_matrix (const ComplexMatrix& m) |
4513
|
63 : octave_base_matrix<ComplexNDArray> (m) { } |
2376
|
64 |
5785
|
65 octave_complex_matrix (const ComplexMatrix& m, const MatrixType& t) |
|
66 : octave_base_matrix<ComplexNDArray> (m, t) { } |
|
67 |
4911
|
68 octave_complex_matrix (const ArrayN<Complex>& m) |
|
69 : octave_base_matrix<ComplexNDArray> (ComplexNDArray (m)) { } |
|
70 |
2376
|
71 octave_complex_matrix (const ComplexDiagMatrix& d) |
4513
|
72 : octave_base_matrix<ComplexNDArray> (ComplexMatrix (d)) { } |
2376
|
73 |
3418
|
74 octave_complex_matrix (const ComplexRowVector& v) |
4513
|
75 : octave_base_matrix<ComplexNDArray> (ComplexMatrix (v)) { } |
2376
|
76 |
3418
|
77 octave_complex_matrix (const ComplexColumnVector& v) |
4513
|
78 : octave_base_matrix<ComplexNDArray> (ComplexMatrix (v)) { } |
2376
|
79 |
|
80 octave_complex_matrix (const octave_complex_matrix& cm) |
4513
|
81 : octave_base_matrix<ComplexNDArray> (cm) { } |
2376
|
82 |
|
83 ~octave_complex_matrix (void) { } |
|
84 |
5759
|
85 octave_base_value *clone (void) const { return new octave_complex_matrix (*this); } |
|
86 octave_base_value *empty_clone (void) const { return new octave_complex_matrix (); } |
2376
|
87 |
5759
|
88 octave_base_value *try_narrowing_conversion (void); |
2410
|
89 |
4686
|
90 void assign (const octave_value_list& idx, const ComplexNDArray& rhs); |
2376
|
91 |
4686
|
92 void assign (const octave_value_list& idx, const NDArray& rhs); |
2376
|
93 |
|
94 bool is_complex_matrix (void) const { return true; } |
|
95 |
|
96 bool is_complex_type (void) const { return true; } |
|
97 |
5895
|
98 bool is_double_type (void) const { return true; } |
|
99 |
2376
|
100 bool valid_as_scalar_index (void) const; |
|
101 |
3145
|
102 double double_value (bool = false) const; |
2376
|
103 |
3145
|
104 double scalar_value (bool frc_str_conv = false) const |
|
105 { return double_value (frc_str_conv); } |
2916
|
106 |
2376
|
107 Matrix matrix_value (bool = false) const; |
|
108 |
|
109 Complex complex_value (bool = false) const; |
|
110 |
|
111 ComplexMatrix complex_matrix_value (bool = false) const; |
|
112 |
4550
|
113 ComplexNDArray complex_array_value (bool = false) const { return matrix; } |
4543
|
114 |
5164
|
115 SparseMatrix sparse_matrix_value (bool = false) const; |
|
116 |
|
117 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const; |
|
118 |
3107
|
119 void increment (void) { matrix += Complex (1.0); } |
2376
|
120 |
3107
|
121 void decrement (void) { matrix -= Complex (1.0); } |
2376
|
122 |
4687
|
123 bool save_ascii (std::ostream& os, bool& infnan_warned, |
|
124 bool strip_nan_and_inf); |
|
125 |
|
126 bool load_ascii (std::istream& is); |
|
127 |
|
128 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
129 |
|
130 bool load_binary (std::istream& is, bool swap, |
|
131 oct_mach_info::float_format fmt); |
|
132 |
|
133 #if defined (HAVE_HDF5) |
|
134 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
135 |
|
136 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
137 #endif |
|
138 |
4944
|
139 int write (octave_stream& os, int block_size, |
|
140 oct_data_conv::data_type output_type, int skip, |
|
141 oct_mach_info::float_format flt_fmt) const |
|
142 { |
|
143 // Yes, for compatibility, we drop the imaginary part here. |
|
144 return os.write (matrix_value (true), block_size, output_type, |
|
145 skip, flt_fmt); |
|
146 } |
|
147 |
4643
|
148 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
|
149 |
5900
|
150 mxArray *as_mxArray (void) const; |
|
151 |
2376
|
152 private: |
|
153 |
3219
|
154 DECLARE_OCTAVE_ALLOCATOR |
2477
|
155 |
3219
|
156 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
157 }; |
|
158 |
|
159 #endif |
|
160 |
|
161 /* |
|
162 ;;; Local Variables: *** |
|
163 ;;; mode: C++ *** |
|
164 ;;; End: *** |
|
165 */ |