Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined (octave_sparse_matrix_h)
00025 #define octave_sparse_matrix_h 1
00026
00027 #include <cstdlib>
00028
00029 #include <iosfwd>
00030 #include <string>
00031
00032 #include "mx-base.h"
00033 #include "oct-alloc.h"
00034 #include "str-vec.h"
00035
00036 #include "error.h"
00037 #include "oct-stream.h"
00038 #include "ov-base.h"
00039 #include "ov-typeinfo.h"
00040
00041 #include "dSparse.h"
00042 #include "MatrixType.h"
00043 #include "ov-base-sparse.h"
00044 #include "ov-cx-sparse.h"
00045
00046 class octave_value_list;
00047
00048 class tree_walker;
00049
00050 class
00051 OCTINTERP_API
00052 octave_sparse_matrix : public octave_base_sparse<SparseMatrix>
00053 {
00054 public:
00055
00056 octave_sparse_matrix (void)
00057 : octave_base_sparse<SparseMatrix> () { }
00058
00059 octave_sparse_matrix (const Matrix& m)
00060 : octave_base_sparse<SparseMatrix> (SparseMatrix (m)) { }
00061
00062 octave_sparse_matrix (const NDArray& m)
00063 : octave_base_sparse<SparseMatrix> (SparseMatrix (m)) { }
00064
00065 octave_sparse_matrix (const SparseMatrix& m)
00066 : octave_base_sparse<SparseMatrix> (m) { }
00067
00068 octave_sparse_matrix (const SparseMatrix& m, const MatrixType& t)
00069 : octave_base_sparse<SparseMatrix> (m, t) { }
00070
00071 octave_sparse_matrix (const MSparse<double>& m)
00072 : octave_base_sparse<SparseMatrix> (m) { }
00073
00074 octave_sparse_matrix (const MSparse<double>& m, const MatrixType& t)
00075 : octave_base_sparse<SparseMatrix> (m, t) { }
00076
00077 octave_sparse_matrix (const Sparse<double>& m)
00078 : octave_base_sparse<SparseMatrix> (SparseMatrix (m)) { }
00079
00080 octave_sparse_matrix (const Sparse<double>& m, const MatrixType& t)
00081 : octave_base_sparse<SparseMatrix> (SparseMatrix (m), t) { }
00082
00083 octave_sparse_matrix (const octave_sparse_matrix& m)
00084 : octave_base_sparse<SparseMatrix> (m) { }
00085
00086 ~octave_sparse_matrix (void) { }
00087
00088 octave_base_value *clone (void) const { return new octave_sparse_matrix (*this); }
00089 octave_base_value *empty_clone (void) const { return new octave_sparse_matrix (); }
00090
00091 octave_base_value *try_narrowing_conversion (void);
00092
00093 idx_vector index_vector (void) const;
00094
00095 builtin_type_t builtin_type (void) const { return btyp_double; }
00096
00097 bool is_real_matrix (void) const { return true; }
00098
00099 bool is_real_type (void) const { return true; }
00100
00101 bool is_double_type (void) const { return true; }
00102
00103 bool is_float_type (void) const { return true; }
00104
00105 double double_value (bool = false) const;
00106
00107 double scalar_value (bool frc_str_conv = false) const
00108 { return double_value (frc_str_conv); }
00109
00110 Matrix matrix_value (bool = false) const;
00111
00112 Complex complex_value (bool = false) const;
00113
00114 boolNDArray bool_array_value (bool warn = false) const;
00115
00116 charNDArray char_array_value (bool = false) const;
00117
00118 ComplexMatrix complex_matrix_value (bool = false) const;
00119
00120 ComplexNDArray complex_array_value (bool = false) const;
00121
00122 NDArray array_value (bool = false) const;
00123
00124 SparseMatrix sparse_matrix_value (bool = false) const
00125 { return matrix; }
00126
00127 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const
00128 { return SparseComplexMatrix (matrix); }
00129
00130 SparseBoolMatrix sparse_bool_matrix_value (bool warn = false) const;
00131
00132 octave_value convert_to_str_internal (bool pad, bool force, char type) const;
00133
00134 #if 0
00135 int write (octave_stream& os, int block_size,
00136 oct_data_conv::data_type output_type, int skip,
00137 oct_mach_info::float_format flt_fmt) const
00138 { return os.write (matrix, block_size, output_type, skip, flt_fmt); }
00139 #endif
00140
00141 bool save_binary (std::ostream& os, bool& save_as_floats);
00142
00143 bool load_binary (std::istream& is, bool swap,
00144 oct_mach_info::float_format fmt);
00145
00146 #if defined (HAVE_HDF5)
00147 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats);
00148
00149 bool load_hdf5 (hid_t loc_id, const char *name);
00150 #endif
00151
00152 mxArray *as_mxArray (void) const;
00153
00154 octave_value map (unary_mapper_t umap) const;
00155
00156 private:
00157 octave_value map (double (*fcn) (double)) const;
00158
00159 DECLARE_OCTAVE_ALLOCATOR
00160
00161 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
00162 };
00163
00164 #endif