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" |
|
41 #include "ov-base.h" |
3219
|
42 #include "ov-base-mat.h" |
2376
|
43 #include "ov-typeinfo.h" |
|
44 |
|
45 class Octave_map; |
|
46 class octave_value_list; |
|
47 |
|
48 class tree_walker; |
|
49 |
|
50 // Real matrix values. |
|
51 |
|
52 class |
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 |
|
63 octave_matrix (const NDArray& nda) |
|
64 : octave_base_matrix<NDArray> (nda) { } |
2376
|
65 |
|
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 |
2376
|
136 private: |
|
137 |
3219
|
138 DECLARE_OCTAVE_ALLOCATOR |
2477
|
139 |
3219
|
140 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
141 }; |
|
142 |
|
143 #endif |
|
144 |
|
145 /* |
|
146 ;;; Local Variables: *** |
|
147 ;;; mode: C++ *** |
|
148 ;;; End: *** |
|
149 */ |