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 |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_matrix_h) |
|
24 #define octave_matrix_h 1 |
|
25 |
4192
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
2376
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <cstdlib> |
|
31 |
3503
|
32 #include <iostream> |
2376
|
33 #include <string> |
|
34 |
|
35 #include "mx-base.h" |
2477
|
36 #include "oct-alloc.h" |
4649
|
37 #include "so-array.h" |
2376
|
38 #include "str-vec.h" |
|
39 |
|
40 #include "error.h" |
4944
|
41 #include "oct-stream.h" |
2376
|
42 #include "ov-base.h" |
3219
|
43 #include "ov-base-mat.h" |
2376
|
44 #include "ov-typeinfo.h" |
|
45 |
|
46 class Octave_map; |
|
47 class octave_value_list; |
|
48 |
|
49 class tree_walker; |
|
50 |
|
51 // Real matrix values. |
|
52 |
|
53 class |
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 |
|
64 octave_matrix (const NDArray& nda) |
|
65 : octave_base_matrix<NDArray> (nda) { } |
2376
|
66 |
4911
|
67 octave_matrix (const ArrayN<double>& m) |
|
68 : octave_base_matrix<NDArray> (NDArray (m)) { } |
|
69 |
2376
|
70 octave_matrix (const DiagMatrix& d) |
4513
|
71 : octave_base_matrix<NDArray> (Matrix (d)) { } |
2376
|
72 |
3418
|
73 octave_matrix (const RowVector& v) |
4513
|
74 : octave_base_matrix<NDArray> (Matrix (v)) { } |
2376
|
75 |
3418
|
76 octave_matrix (const ColumnVector& v) |
4513
|
77 : octave_base_matrix<NDArray> (Matrix (v)) { } |
2376
|
78 |
|
79 octave_matrix (const octave_matrix& m) |
4513
|
80 : octave_base_matrix<NDArray> (m) { } |
2376
|
81 |
|
82 ~octave_matrix (void) { } |
|
83 |
3933
|
84 octave_value *clone (void) const { return new octave_matrix (*this); } |
|
85 octave_value *empty_clone (void) const { return new octave_matrix (); } |
2376
|
86 |
2410
|
87 octave_value *try_narrowing_conversion (void); |
|
88 |
4650
|
89 idx_vector index_vector (void) const { return idx_vector (matrix); } |
2376
|
90 |
|
91 bool is_real_matrix (void) const { return true; } |
|
92 |
|
93 bool is_real_type (void) const { return true; } |
|
94 |
|
95 bool valid_as_scalar_index (void) const; |
|
96 |
|
97 double double_value (bool = false) const; |
|
98 |
3145
|
99 double scalar_value (bool frc_str_conv = false) const |
|
100 { return double_value (frc_str_conv); } |
2916
|
101 |
4513
|
102 Matrix matrix_value (bool = false) const; |
2376
|
103 |
|
104 Complex complex_value (bool = false) const; |
|
105 |
4513
|
106 ComplexMatrix complex_matrix_value (bool = false) const; |
2376
|
107 |
4699
|
108 ComplexNDArray complex_array_value (bool = false) const; |
4758
|
109 |
|
110 charNDArray char_array_value (bool = false) const; |
|
111 |
4550
|
112 NDArray array_value (bool = false) const { return matrix; } |
4505
|
113 |
4645
|
114 streamoff_array streamoff_array_value (void) const; |
|
115 |
2376
|
116 void increment (void) { matrix += 1.0; } |
|
117 |
|
118 void decrement (void) { matrix -= 1.0; } |
|
119 |
4457
|
120 octave_value convert_to_str_internal (bool pad, bool force) const; |
2376
|
121 |
4643
|
122 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
|
123 |
4687
|
124 bool save_ascii (std::ostream& os, bool& infnan_warned, |
|
125 bool strip_nan_and_inf); |
|
126 |
|
127 bool load_ascii (std::istream& is); |
|
128 |
|
129 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
130 |
|
131 bool load_binary (std::istream& is, bool swap, |
|
132 oct_mach_info::float_format fmt); |
|
133 |
|
134 #if defined (HAVE_HDF5) |
|
135 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
136 |
|
137 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
138 #endif |
|
139 |
4944
|
140 int write (octave_stream& os, int block_size, |
|
141 oct_data_conv::data_type output_type, int skip, |
|
142 oct_mach_info::float_format flt_fmt) const |
|
143 { return os.write (matrix, block_size, output_type, skip, flt_fmt); } |
|
144 |
2376
|
145 private: |
|
146 |
3219
|
147 DECLARE_OCTAVE_ALLOCATOR |
2477
|
148 |
3219
|
149 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
150 }; |
|
151 |
|
152 #endif |
|
153 |
|
154 /* |
|
155 ;;; Local Variables: *** |
|
156 ;;; mode: C++ *** |
|
157 ;;; End: *** |
|
158 */ |