2376
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006, |
|
4 2007 John W. Eaton |
2376
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
7016
|
10 Free Software Foundation; either version 3 of the License, or (at your |
|
11 option) any later version. |
2376
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
7016
|
19 along with Octave; see the file COPYING. If not, see |
|
20 <http://www.gnu.org/licenses/>. |
2376
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_matrix_h) |
|
25 #define octave_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" |
4649
|
34 #include "so-array.h" |
2376
|
35 #include "str-vec.h" |
|
36 |
|
37 #include "error.h" |
4944
|
38 #include "oct-stream.h" |
2376
|
39 #include "ov-base.h" |
3219
|
40 #include "ov-base-mat.h" |
2376
|
41 #include "ov-typeinfo.h" |
|
42 |
5785
|
43 #include "MatrixType.h" |
|
44 |
2376
|
45 class Octave_map; |
|
46 class octave_value_list; |
|
47 |
|
48 class tree_walker; |
|
49 |
|
50 // Real matrix values. |
|
51 |
|
52 class |
6153
|
53 OCTINTERP_API |
4513
|
54 octave_matrix : public octave_base_matrix<NDArray> |
2376
|
55 { |
|
56 public: |
|
57 |
|
58 octave_matrix (void) |
4513
|
59 : octave_base_matrix<NDArray> () { } |
2376
|
60 |
|
61 octave_matrix (const Matrix& m) |
4513
|
62 : octave_base_matrix<NDArray> (m) { } |
|
63 |
5785
|
64 octave_matrix (const Matrix& m, const MatrixType& t) |
|
65 : octave_base_matrix<NDArray> (m, t) { } |
|
66 |
4513
|
67 octave_matrix (const NDArray& nda) |
|
68 : octave_base_matrix<NDArray> (nda) { } |
2376
|
69 |
4911
|
70 octave_matrix (const ArrayN<double>& m) |
|
71 : octave_base_matrix<NDArray> (NDArray (m)) { } |
|
72 |
2376
|
73 octave_matrix (const DiagMatrix& d) |
4513
|
74 : octave_base_matrix<NDArray> (Matrix (d)) { } |
2376
|
75 |
3418
|
76 octave_matrix (const RowVector& v) |
4513
|
77 : octave_base_matrix<NDArray> (Matrix (v)) { } |
2376
|
78 |
3418
|
79 octave_matrix (const ColumnVector& v) |
4513
|
80 : octave_base_matrix<NDArray> (Matrix (v)) { } |
2376
|
81 |
|
82 octave_matrix (const octave_matrix& m) |
4513
|
83 : octave_base_matrix<NDArray> (m) { } |
2376
|
84 |
|
85 ~octave_matrix (void) { } |
|
86 |
5759
|
87 octave_base_value *clone (void) const { return new octave_matrix (*this); } |
|
88 octave_base_value *empty_clone (void) const { return new octave_matrix (); } |
2376
|
89 |
5759
|
90 octave_base_value *try_narrowing_conversion (void); |
2410
|
91 |
4650
|
92 idx_vector index_vector (void) const { return idx_vector (matrix); } |
2376
|
93 |
|
94 bool is_real_matrix (void) const { return true; } |
|
95 |
|
96 bool is_real_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 |
5533
|
102 int8NDArray |
|
103 int8_array_value (void) const { return int8NDArray (matrix); } |
|
104 |
|
105 int16NDArray |
|
106 int16_array_value (void) const { return int16NDArray (matrix); } |
|
107 |
|
108 int32NDArray |
|
109 int32_array_value (void) const { return int32NDArray (matrix); } |
|
110 |
|
111 int64NDArray |
|
112 int64_array_value (void) const { return int64NDArray (matrix); } |
|
113 |
|
114 uint8NDArray |
|
115 uint8_array_value (void) const { return uint8NDArray (matrix); } |
|
116 |
|
117 uint16NDArray |
|
118 uint16_array_value (void) const { return uint16NDArray (matrix); } |
|
119 |
|
120 uint32NDArray |
|
121 uint32_array_value (void) const { return uint32NDArray (matrix); } |
|
122 |
|
123 uint64NDArray |
|
124 uint64_array_value (void) const { return uint64NDArray (matrix); } |
|
125 |
2376
|
126 double double_value (bool = false) const; |
|
127 |
3145
|
128 double scalar_value (bool frc_str_conv = false) const |
|
129 { return double_value (frc_str_conv); } |
2916
|
130 |
4513
|
131 Matrix matrix_value (bool = false) const; |
2376
|
132 |
|
133 Complex complex_value (bool = false) const; |
|
134 |
4513
|
135 ComplexMatrix complex_matrix_value (bool = false) const; |
2376
|
136 |
4699
|
137 ComplexNDArray complex_array_value (bool = false) const; |
4758
|
138 |
5943
|
139 boolNDArray bool_array_value (bool warn = false) const; |
5898
|
140 |
4758
|
141 charNDArray char_array_value (bool = false) const; |
|
142 |
4550
|
143 NDArray array_value (bool = false) const { return matrix; } |
4505
|
144 |
5164
|
145 SparseMatrix sparse_matrix_value (bool = false) const; |
|
146 |
|
147 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const; |
|
148 |
4645
|
149 streamoff_array streamoff_array_value (void) const; |
|
150 |
2376
|
151 void increment (void) { matrix += 1.0; } |
|
152 |
|
153 void decrement (void) { matrix -= 1.0; } |
|
154 |
5279
|
155 octave_value convert_to_str_internal (bool pad, bool force, char type) const; |
2376
|
156 |
4643
|
157 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
|
158 |
6974
|
159 bool save_ascii (std::ostream& os); |
4687
|
160 |
|
161 bool load_ascii (std::istream& is); |
|
162 |
|
163 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
164 |
|
165 bool load_binary (std::istream& is, bool swap, |
|
166 oct_mach_info::float_format fmt); |
|
167 |
|
168 #if defined (HAVE_HDF5) |
|
169 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
170 |
|
171 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
172 #endif |
|
173 |
4944
|
174 int write (octave_stream& os, int block_size, |
|
175 oct_data_conv::data_type output_type, int skip, |
|
176 oct_mach_info::float_format flt_fmt) const |
|
177 { return os.write (matrix, block_size, output_type, skip, flt_fmt); } |
|
178 |
5900
|
179 mxArray *as_mxArray (void) const; |
|
180 |
2376
|
181 private: |
|
182 |
3219
|
183 DECLARE_OCTAVE_ALLOCATOR |
2477
|
184 |
3219
|
185 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
186 }; |
|
187 |
|
188 #endif |
|
189 |
|
190 /* |
|
191 ;;; Local Variables: *** |
|
192 ;;; mode: C++ *** |
|
193 ;;; End: *** |
|
194 */ |