5164
|
1 /* |
|
2 |
|
3 Copyright (C) 2004 David Bateman |
|
4 Copyright (C) 1998-2004 Andy Adler |
|
5 |
|
6 Octave is free software; you can redistribute it and/or modify it |
|
7 under the terms of the GNU General Public License as published by the |
|
8 Free Software Foundation; either version 2, or (at your option) any |
|
9 later version. |
|
10 |
|
11 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 for more details. |
|
15 |
|
16 You should have received a copy of the GNU General Public License |
5307
|
17 along with this program; see the file COPYING. If not, write to the |
|
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
19 Boston, MA 02110-1301, USA. |
5164
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_sparse_matrix_h) |
|
24 #define octave_sparse_matrix_h 1 |
|
25 |
|
26 #include <cstdlib> |
|
27 |
|
28 #include <iostream> |
|
29 #include <string> |
|
30 |
|
31 #include "mx-base.h" |
|
32 #include "oct-alloc.h" |
|
33 #include "so-array.h" |
|
34 #include "str-vec.h" |
|
35 |
|
36 #include "error.h" |
|
37 #include "oct-stream.h" |
|
38 #include "ov-base.h" |
|
39 #include "ov-typeinfo.h" |
|
40 |
|
41 #include "dSparse.h" |
5785
|
42 #include "MatrixType.h" |
5164
|
43 #include "ov-base-sparse.h" |
|
44 #include "ov-bool-sparse.h" |
|
45 #include "ov-cx-sparse.h" |
|
46 |
|
47 class Octave_map; |
|
48 class octave_value_list; |
|
49 |
|
50 class tree_walker; |
|
51 |
|
52 class |
6109
|
53 OCTINTERP_API |
5164
|
54 octave_sparse_matrix : public octave_base_sparse<SparseMatrix> |
|
55 { |
|
56 public: |
|
57 |
|
58 octave_sparse_matrix (void) |
|
59 : octave_base_sparse<SparseMatrix> () { } |
|
60 |
|
61 octave_sparse_matrix (const Matrix& m) |
|
62 : octave_base_sparse<SparseMatrix> (SparseMatrix (m)) { } |
|
63 |
|
64 octave_sparse_matrix (const NDArray& m) |
|
65 : octave_base_sparse<SparseMatrix> (SparseMatrix (m)) { } |
|
66 |
|
67 octave_sparse_matrix (const SparseMatrix& m) |
|
68 : octave_base_sparse<SparseMatrix> (m) { } |
|
69 |
5785
|
70 octave_sparse_matrix (const SparseMatrix& m, const MatrixType& t) |
5164
|
71 : octave_base_sparse<SparseMatrix> (m, t) { } |
|
72 |
|
73 octave_sparse_matrix (const MSparse<double>& m) |
|
74 : octave_base_sparse<SparseMatrix> (m) { } |
|
75 |
6863
|
76 octave_sparse_matrix (const MSparse<double>& m, const MatrixType& t) |
|
77 : octave_base_sparse<SparseMatrix> (m, t) { } |
|
78 |
|
79 octave_sparse_matrix (const Sparse<double>& m) |
|
80 : octave_base_sparse<SparseMatrix> (SparseMatrix (m)) { } |
|
81 |
|
82 octave_sparse_matrix (const Sparse<double>& m, const MatrixType& t) |
|
83 : octave_base_sparse<SparseMatrix> (SparseMatrix (m), t) { } |
|
84 |
5164
|
85 octave_sparse_matrix (const octave_sparse_matrix& m) |
|
86 : octave_base_sparse<SparseMatrix> (m) { } |
|
87 |
|
88 ~octave_sparse_matrix (void) { } |
|
89 |
5759
|
90 octave_base_value *clone (void) const { return new octave_sparse_matrix (*this); } |
|
91 octave_base_value *empty_clone (void) const { return new octave_sparse_matrix (); } |
5164
|
92 |
5759
|
93 octave_base_value *try_narrowing_conversion (void); |
5164
|
94 |
5282
|
95 idx_vector index_vector (void) const; |
5164
|
96 |
|
97 bool is_real_matrix (void) const { return true; } |
|
98 |
|
99 bool is_real_type (void) const { return true; } |
|
100 |
5895
|
101 bool is_double_type (void) const { return true; } |
|
102 |
5164
|
103 bool valid_as_scalar_index (void) const; |
|
104 |
|
105 double double_value (bool = false) const; |
|
106 |
|
107 double scalar_value (bool frc_str_conv = false) const |
|
108 { return double_value (frc_str_conv); } |
|
109 |
|
110 Matrix matrix_value (bool = false) const; |
|
111 |
|
112 Complex complex_value (bool = false) const; |
|
113 |
5943
|
114 boolNDArray bool_array_value (bool warn = false) const; |
5898
|
115 |
5164
|
116 ComplexMatrix complex_matrix_value (bool = false) const; |
|
117 |
|
118 ComplexNDArray complex_array_value (bool = false) const; |
|
119 |
|
120 NDArray array_value (bool = false) const; |
|
121 |
|
122 SparseMatrix sparse_matrix_value (bool = false) const |
|
123 { return matrix; } |
|
124 |
|
125 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const |
|
126 { return SparseComplexMatrix (matrix); } |
|
127 |
|
128 streamoff_array streamoff_array_value (void) const; |
|
129 |
5322
|
130 octave_value convert_to_str_internal (bool pad, bool force, char type) const; |
5282
|
131 |
5164
|
132 #if 0 |
|
133 int write (octave_stream& os, int block_size, |
|
134 oct_data_conv::data_type output_type, int skip, |
|
135 oct_mach_info::float_format flt_fmt) const |
|
136 { return os.write (matrix, block_size, output_type, skip, flt_fmt); } |
|
137 #endif |
|
138 |
|
139 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
140 |
|
141 bool load_binary (std::istream& is, bool swap, |
|
142 oct_mach_info::float_format fmt); |
|
143 |
|
144 #if defined (HAVE_HDF5) |
|
145 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
146 |
|
147 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
148 #endif |
|
149 |
5900
|
150 mxArray *as_mxArray (void) const; |
|
151 |
5164
|
152 private: |
|
153 |
|
154 DECLARE_OCTAVE_ALLOCATOR |
|
155 |
|
156 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
|
157 }; |
|
158 |
|
159 #endif |
|
160 |
|
161 /* |
|
162 ;;; Local Variables: *** |
|
163 ;;; mode: C++ *** |
|
164 ;;; End: *** |
|
165 */ |