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_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 |
|
43 class Octave_map; |
|
44 class octave_value_list; |
|
45 |
|
46 class tree_walker; |
|
47 |
|
48 // Real matrix values. |
|
49 |
|
50 class |
4513
|
51 octave_matrix : public octave_base_matrix<NDArray> |
2376
|
52 { |
|
53 public: |
|
54 |
|
55 octave_matrix (void) |
4513
|
56 : octave_base_matrix<NDArray> () { } |
2376
|
57 |
|
58 octave_matrix (const Matrix& m) |
4513
|
59 : octave_base_matrix<NDArray> (m) { } |
|
60 |
|
61 octave_matrix (const NDArray& nda) |
|
62 : octave_base_matrix<NDArray> (nda) { } |
2376
|
63 |
4911
|
64 octave_matrix (const ArrayN<double>& m) |
|
65 : octave_base_matrix<NDArray> (NDArray (m)) { } |
|
66 |
2376
|
67 octave_matrix (const DiagMatrix& d) |
4513
|
68 : octave_base_matrix<NDArray> (Matrix (d)) { } |
2376
|
69 |
3418
|
70 octave_matrix (const RowVector& v) |
4513
|
71 : octave_base_matrix<NDArray> (Matrix (v)) { } |
2376
|
72 |
3418
|
73 octave_matrix (const ColumnVector& v) |
4513
|
74 : octave_base_matrix<NDArray> (Matrix (v)) { } |
2376
|
75 |
|
76 octave_matrix (const octave_matrix& m) |
4513
|
77 : octave_base_matrix<NDArray> (m) { } |
2376
|
78 |
|
79 ~octave_matrix (void) { } |
|
80 |
3933
|
81 octave_value *clone (void) const { return new octave_matrix (*this); } |
|
82 octave_value *empty_clone (void) const { return new octave_matrix (); } |
2376
|
83 |
2410
|
84 octave_value *try_narrowing_conversion (void); |
|
85 |
4650
|
86 idx_vector index_vector (void) const { return idx_vector (matrix); } |
2376
|
87 |
|
88 bool is_real_matrix (void) const { return true; } |
|
89 |
|
90 bool is_real_type (void) const { return true; } |
|
91 |
|
92 bool valid_as_scalar_index (void) const; |
|
93 |
5533
|
94 int8NDArray |
|
95 int8_array_value (void) const { return int8NDArray (matrix); } |
|
96 |
|
97 int16NDArray |
|
98 int16_array_value (void) const { return int16NDArray (matrix); } |
|
99 |
|
100 int32NDArray |
|
101 int32_array_value (void) const { return int32NDArray (matrix); } |
|
102 |
|
103 int64NDArray |
|
104 int64_array_value (void) const { return int64NDArray (matrix); } |
|
105 |
|
106 uint8NDArray |
|
107 uint8_array_value (void) const { return uint8NDArray (matrix); } |
|
108 |
|
109 uint16NDArray |
|
110 uint16_array_value (void) const { return uint16NDArray (matrix); } |
|
111 |
|
112 uint32NDArray |
|
113 uint32_array_value (void) const { return uint32NDArray (matrix); } |
|
114 |
|
115 uint64NDArray |
|
116 uint64_array_value (void) const { return uint64NDArray (matrix); } |
|
117 |
2376
|
118 double double_value (bool = false) const; |
|
119 |
3145
|
120 double scalar_value (bool frc_str_conv = false) const |
|
121 { return double_value (frc_str_conv); } |
2916
|
122 |
4513
|
123 Matrix matrix_value (bool = false) const; |
2376
|
124 |
|
125 Complex complex_value (bool = false) const; |
|
126 |
4513
|
127 ComplexMatrix complex_matrix_value (bool = false) const; |
2376
|
128 |
4699
|
129 ComplexNDArray complex_array_value (bool = false) const; |
4758
|
130 |
|
131 charNDArray char_array_value (bool = false) const; |
|
132 |
4550
|
133 NDArray array_value (bool = false) const { return matrix; } |
4505
|
134 |
5164
|
135 SparseMatrix sparse_matrix_value (bool = false) const; |
|
136 |
|
137 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const; |
|
138 |
4645
|
139 streamoff_array streamoff_array_value (void) const; |
|
140 |
2376
|
141 void increment (void) { matrix += 1.0; } |
|
142 |
|
143 void decrement (void) { matrix -= 1.0; } |
|
144 |
5279
|
145 octave_value convert_to_str_internal (bool pad, bool force, char type) const; |
2376
|
146 |
4643
|
147 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
|
148 |
4687
|
149 bool save_ascii (std::ostream& os, bool& infnan_warned, |
|
150 bool strip_nan_and_inf); |
|
151 |
|
152 bool load_ascii (std::istream& is); |
|
153 |
|
154 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
155 |
|
156 bool load_binary (std::istream& is, bool swap, |
|
157 oct_mach_info::float_format fmt); |
|
158 |
|
159 #if defined (HAVE_HDF5) |
|
160 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
161 |
|
162 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
163 #endif |
|
164 |
4944
|
165 int write (octave_stream& os, int block_size, |
|
166 oct_data_conv::data_type output_type, int skip, |
|
167 oct_mach_info::float_format flt_fmt) const |
|
168 { return os.write (matrix, block_size, output_type, skip, flt_fmt); } |
|
169 |
2376
|
170 private: |
|
171 |
3219
|
172 DECLARE_OCTAVE_ALLOCATOR |
2477
|
173 |
3219
|
174 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
175 }; |
|
176 |
|
177 #endif |
|
178 |
|
179 /* |
|
180 ;;; Local Variables: *** |
|
181 ;;; mode: C++ *** |
|
182 ;;; End: *** |
|
183 */ |