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