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 |
7016
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
2376
|
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 |
7016
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
2376
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_matrix_h) |
|
24 #define octave_matrix_h 1 |
|
25 |
|
26 #include <cstdlib> |
|
27 |
3503
|
28 #include <iostream> |
2376
|
29 #include <string> |
|
30 |
|
31 #include "mx-base.h" |
2477
|
32 #include "oct-alloc.h" |
4649
|
33 #include "so-array.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 |
|
49 // Real matrix values. |
|
50 |
|
51 class |
6153
|
52 OCTINTERP_API |
4513
|
53 octave_matrix : public octave_base_matrix<NDArray> |
2376
|
54 { |
|
55 public: |
|
56 |
|
57 octave_matrix (void) |
4513
|
58 : octave_base_matrix<NDArray> () { } |
2376
|
59 |
|
60 octave_matrix (const Matrix& m) |
4513
|
61 : octave_base_matrix<NDArray> (m) { } |
|
62 |
5785
|
63 octave_matrix (const Matrix& m, const MatrixType& t) |
|
64 : octave_base_matrix<NDArray> (m, t) { } |
|
65 |
4513
|
66 octave_matrix (const NDArray& nda) |
|
67 : octave_base_matrix<NDArray> (nda) { } |
2376
|
68 |
4911
|
69 octave_matrix (const ArrayN<double>& m) |
|
70 : octave_base_matrix<NDArray> (NDArray (m)) { } |
|
71 |
2376
|
72 octave_matrix (const DiagMatrix& d) |
4513
|
73 : octave_base_matrix<NDArray> (Matrix (d)) { } |
2376
|
74 |
3418
|
75 octave_matrix (const RowVector& v) |
4513
|
76 : octave_base_matrix<NDArray> (Matrix (v)) { } |
2376
|
77 |
3418
|
78 octave_matrix (const ColumnVector& v) |
4513
|
79 : octave_base_matrix<NDArray> (Matrix (v)) { } |
2376
|
80 |
|
81 octave_matrix (const octave_matrix& m) |
4513
|
82 : octave_base_matrix<NDArray> (m) { } |
2376
|
83 |
|
84 ~octave_matrix (void) { } |
|
85 |
5759
|
86 octave_base_value *clone (void) const { return new octave_matrix (*this); } |
|
87 octave_base_value *empty_clone (void) const { return new octave_matrix (); } |
2376
|
88 |
5759
|
89 octave_base_value *try_narrowing_conversion (void); |
2410
|
90 |
4650
|
91 idx_vector index_vector (void) const { return idx_vector (matrix); } |
2376
|
92 |
|
93 bool is_real_matrix (void) const { return true; } |
|
94 |
|
95 bool is_real_type (void) const { return true; } |
|
96 |
5895
|
97 bool is_double_type (void) const { return true; } |
|
98 |
2376
|
99 bool valid_as_scalar_index (void) const; |
|
100 |
5533
|
101 int8NDArray |
|
102 int8_array_value (void) const { return int8NDArray (matrix); } |
|
103 |
|
104 int16NDArray |
|
105 int16_array_value (void) const { return int16NDArray (matrix); } |
|
106 |
|
107 int32NDArray |
|
108 int32_array_value (void) const { return int32NDArray (matrix); } |
|
109 |
|
110 int64NDArray |
|
111 int64_array_value (void) const { return int64NDArray (matrix); } |
|
112 |
|
113 uint8NDArray |
|
114 uint8_array_value (void) const { return uint8NDArray (matrix); } |
|
115 |
|
116 uint16NDArray |
|
117 uint16_array_value (void) const { return uint16NDArray (matrix); } |
|
118 |
|
119 uint32NDArray |
|
120 uint32_array_value (void) const { return uint32NDArray (matrix); } |
|
121 |
|
122 uint64NDArray |
|
123 uint64_array_value (void) const { return uint64NDArray (matrix); } |
|
124 |
2376
|
125 double double_value (bool = false) const; |
|
126 |
3145
|
127 double scalar_value (bool frc_str_conv = false) const |
|
128 { return double_value (frc_str_conv); } |
2916
|
129 |
4513
|
130 Matrix matrix_value (bool = false) const; |
2376
|
131 |
|
132 Complex complex_value (bool = false) const; |
|
133 |
4513
|
134 ComplexMatrix complex_matrix_value (bool = false) const; |
2376
|
135 |
4699
|
136 ComplexNDArray complex_array_value (bool = false) const; |
4758
|
137 |
5943
|
138 boolNDArray bool_array_value (bool warn = false) const; |
5898
|
139 |
4758
|
140 charNDArray char_array_value (bool = false) const; |
|
141 |
4550
|
142 NDArray array_value (bool = false) const { return matrix; } |
4505
|
143 |
5164
|
144 SparseMatrix sparse_matrix_value (bool = false) const; |
|
145 |
|
146 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const; |
|
147 |
4645
|
148 streamoff_array streamoff_array_value (void) const; |
|
149 |
2376
|
150 void increment (void) { matrix += 1.0; } |
|
151 |
|
152 void decrement (void) { matrix -= 1.0; } |
|
153 |
5279
|
154 octave_value convert_to_str_internal (bool pad, bool force, char type) const; |
2376
|
155 |
4643
|
156 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
|
157 |
6974
|
158 bool save_ascii (std::ostream& os); |
4687
|
159 |
|
160 bool load_ascii (std::istream& is); |
|
161 |
|
162 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
163 |
|
164 bool load_binary (std::istream& is, bool swap, |
|
165 oct_mach_info::float_format fmt); |
|
166 |
|
167 #if defined (HAVE_HDF5) |
|
168 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
169 |
|
170 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
171 #endif |
|
172 |
4944
|
173 int write (octave_stream& os, int block_size, |
|
174 oct_data_conv::data_type output_type, int skip, |
|
175 oct_mach_info::float_format flt_fmt) const |
|
176 { return os.write (matrix, block_size, output_type, skip, flt_fmt); } |
|
177 |
5900
|
178 mxArray *as_mxArray (void) const; |
|
179 |
2376
|
180 private: |
|
181 |
3219
|
182 DECLARE_OCTAVE_ALLOCATOR |
2477
|
183 |
3219
|
184 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
185 }; |
|
186 |
|
187 #endif |
|
188 |
|
189 /* |
|
190 ;;; Local Variables: *** |
|
191 ;;; mode: C++ *** |
|
192 ;;; End: *** |
|
193 */ |