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