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_map;
00047 class octave_value_list;
00048
00049 class tree_walker;
00050
00051 class
00052 OCTINTERP_API
00053 octave_sparse_matrix : public octave_base_sparse<SparseMatrix>
00054 {
00055 public:
00056
00057 octave_sparse_matrix (void)
00058 : octave_base_sparse<SparseMatrix> () { }
00059
00060 octave_sparse_matrix (const Matrix& m)
00061 : octave_base_sparse<SparseMatrix> (SparseMatrix (m)) { }
00062
00063 octave_sparse_matrix (const NDArray& m)
00064 : octave_base_sparse<SparseMatrix> (SparseMatrix (m)) { }
00065
00066 octave_sparse_matrix (const SparseMatrix& m)
00067 : octave_base_sparse<SparseMatrix> (m) { }
00068
00069 octave_sparse_matrix (const SparseMatrix& m, const MatrixType& t)
00070 : octave_base_sparse<SparseMatrix> (m, t) { }
00071
00072 octave_sparse_matrix (const MSparse<double>& m)
00073 : octave_base_sparse<SparseMatrix> (m) { }
00074
00075 octave_sparse_matrix (const MSparse<double>& m, const MatrixType& t)
00076 : octave_base_sparse<SparseMatrix> (m, t) { }
00077
00078 octave_sparse_matrix (const Sparse<double>& m)
00079 : octave_base_sparse<SparseMatrix> (SparseMatrix (m)) { }
00080
00081 octave_sparse_matrix (const Sparse<double>& m, const MatrixType& t)
00082 : octave_base_sparse<SparseMatrix> (SparseMatrix (m), t) { }
00083
00084 octave_sparse_matrix (const octave_sparse_matrix& m)
00085 : octave_base_sparse<SparseMatrix> (m) { }
00086
00087 ~octave_sparse_matrix (void) { }
00088
00089 octave_base_value *clone (void) const { return new octave_sparse_matrix (*this); }
00090 octave_base_value *empty_clone (void) const { return new octave_sparse_matrix (); }
00091
00092 octave_base_value *try_narrowing_conversion (void);
00093
00094 idx_vector index_vector (void) const;
00095
00096 builtin_type_t builtin_type (void) const { return btyp_double; }
00097
00098 bool is_real_matrix (void) const { return true; }
00099
00100 bool is_real_type (void) const { return true; }
00101
00102 bool is_double_type (void) const { return true; }
00103
00104 bool is_float_type (void) const { return true; }
00105
00106 double double_value (bool = false) const;
00107
00108 double scalar_value (bool frc_str_conv = false) const
00109 { return double_value (frc_str_conv); }
00110
00111 Matrix matrix_value (bool = false) const;
00112
00113 Complex complex_value (bool = false) const;
00114
00115 boolNDArray bool_array_value (bool warn = false) const;
00116
00117 charNDArray char_array_value (bool = false) const;
00118
00119 ComplexMatrix complex_matrix_value (bool = false) const;
00120
00121 ComplexNDArray complex_array_value (bool = false) const;
00122
00123 NDArray array_value (bool = false) const;
00124
00125 SparseMatrix sparse_matrix_value (bool = false) const
00126 { return matrix; }
00127
00128 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const
00129 { return SparseComplexMatrix (matrix); }
00130
00131 octave_value convert_to_str_internal (bool pad, bool force, char type) const;
00132
00133 #if 0
00134 int write (octave_stream& os, int block_size,
00135 oct_data_conv::data_type output_type, int skip,
00136 oct_mach_info::float_format flt_fmt) const
00137 { return os.write (matrix, block_size, output_type, skip, flt_fmt); }
00138 #endif
00139
00140 bool save_binary (std::ostream& os, bool& save_as_floats);
00141
00142 bool load_binary (std::istream& is, bool swap,
00143 oct_mach_info::float_format fmt);
00144
00145 #if defined (HAVE_HDF5)
00146 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats);
00147
00148 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug);
00149 #endif
00150
00151 mxArray *as_mxArray (void) const;
00152
00153 octave_value erf (void) const;
00154 octave_value erfc (void) const;
00155 octave_value gamma (void) const;
00156 octave_value lgamma (void) const;
00157 octave_value abs (void) const;
00158 octave_value acos (void) const;
00159 octave_value acosh (void) const;
00160 octave_value angle (void) const;
00161 octave_value arg (void) const;
00162 octave_value asin (void) const;
00163 octave_value asinh (void) const;
00164 octave_value atan (void) const;
00165 octave_value atanh (void) const;
00166 octave_value ceil (void) const;
00167 octave_value conj (void) const;
00168 octave_value cos (void) const;
00169 octave_value cosh (void) const;
00170 octave_value exp (void) const;
00171 octave_value expm1 (void) const;
00172 octave_value fix (void) const;
00173 octave_value floor (void) const;
00174 octave_value imag (void) const;
00175 octave_value log (void) const;
00176 octave_value log2 (void) const;
00177 octave_value log10 (void) const;
00178 octave_value log1p (void) const;
00179 octave_value real (void) const;
00180 octave_value round (void) const;
00181 octave_value roundb (void) const;
00182 octave_value signum (void) const;
00183 octave_value sin (void) const;
00184 octave_value sinh (void) const;
00185 octave_value sqrt (void) const;
00186 octave_value tan (void) const;
00187 octave_value tanh (void) const;
00188 octave_value finite (void) const;
00189 octave_value isinf (void) const;
00190 octave_value isna (void) const;
00191 octave_value isnan (void) const;
00192
00193 private:
00194 octave_value map (double (*fcn) (double)) const;
00195
00196 DECLARE_OCTAVE_ALLOCATOR
00197
00198 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
00199 };
00200
00201 #endif
00202
00203
00204
00205
00206
00207