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_float_matrix_h)
00025 #define octave_float_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-base-mat.h"
00040 #include "ov-typeinfo.h"
00041
00042 #include "MatrixType.h"
00043
00044 class Octave_map;
00045 class octave_value_list;
00046
00047 class tree_walker;
00048
00049
00050
00051 class
00052 OCTINTERP_API
00053 octave_float_matrix : public octave_base_matrix<FloatNDArray>
00054 {
00055 public:
00056
00057 octave_float_matrix (void)
00058 : octave_base_matrix<FloatNDArray> () { }
00059
00060 octave_float_matrix (const FloatMatrix& m)
00061 : octave_base_matrix<FloatNDArray> (m) { }
00062
00063 octave_float_matrix (const FloatMatrix& m, const MatrixType& t)
00064 : octave_base_matrix<FloatNDArray> (m, t) { }
00065
00066 octave_float_matrix (const FloatNDArray& nda)
00067 : octave_base_matrix<FloatNDArray> (nda) { }
00068
00069 octave_float_matrix (const Array<float>& m)
00070 : octave_base_matrix<FloatNDArray> (FloatNDArray (m)) { }
00071
00072 octave_float_matrix (const FloatDiagMatrix& d)
00073 : octave_base_matrix<FloatNDArray> (FloatMatrix (d)) { }
00074
00075 octave_float_matrix (const FloatRowVector& v)
00076 : octave_base_matrix<FloatNDArray> (FloatMatrix (v)) { }
00077
00078 octave_float_matrix (const FloatColumnVector& v)
00079 : octave_base_matrix<FloatNDArray> (FloatMatrix (v)) { }
00080
00081 octave_float_matrix (const octave_float_matrix& m)
00082 : octave_base_matrix<FloatNDArray> (m) { }
00083
00084 ~octave_float_matrix (void) { }
00085
00086 octave_base_value *clone (void) const { return new octave_float_matrix (*this); }
00087 octave_base_value *empty_clone (void) const { return new octave_float_matrix (); }
00088
00089 octave_base_value *try_narrowing_conversion (void);
00090
00091 idx_vector index_vector (void) const
00092 { return idx_cache ? *idx_cache : set_idx_cache (idx_vector (matrix)); }
00093
00094 builtin_type_t builtin_type (void) const { return btyp_float; }
00095
00096 bool is_real_matrix (void) const { return true; }
00097
00098 bool is_real_type (void) const { return true; }
00099
00100 bool is_single_type (void) const { return true; }
00101
00102 bool is_float_type (void) const { return true; }
00103
00104 int8NDArray
00105 int8_array_value (void) const { return int8NDArray (matrix); }
00106
00107 int16NDArray
00108 int16_array_value (void) const { return int16NDArray (matrix); }
00109
00110 int32NDArray
00111 int32_array_value (void) const { return int32NDArray (matrix); }
00112
00113 int64NDArray
00114 int64_array_value (void) const { return int64NDArray (matrix); }
00115
00116 uint8NDArray
00117 uint8_array_value (void) const { return uint8NDArray (matrix); }
00118
00119 uint16NDArray
00120 uint16_array_value (void) const { return uint16NDArray (matrix); }
00121
00122 uint32NDArray
00123 uint32_array_value (void) const { return uint32NDArray (matrix); }
00124
00125 uint64NDArray
00126 uint64_array_value (void) const { return uint64NDArray (matrix); }
00127
00128 double double_value (bool = false) const;
00129
00130 float float_value (bool = false) const;
00131
00132 double scalar_value (bool frc_str_conv = false) const
00133 { return double_value (frc_str_conv); }
00134
00135 float float_scalar_value (bool frc_str_conv = false) const
00136 { return float_value (frc_str_conv); }
00137
00138 Matrix matrix_value (bool = false) const;
00139
00140 FloatMatrix float_matrix_value (bool = false) const;
00141
00142 Complex complex_value (bool = false) const;
00143
00144 FloatComplex float_complex_value (bool = false) const;
00145
00146 ComplexMatrix complex_matrix_value (bool = false) const;
00147
00148 FloatComplexMatrix float_complex_matrix_value (bool = false) const;
00149
00150 ComplexNDArray complex_array_value (bool = false) const;
00151
00152 FloatComplexNDArray float_complex_array_value (bool = false) const;
00153
00154 boolNDArray bool_array_value (bool warn = false) const;
00155
00156 charNDArray char_array_value (bool = false) const;
00157
00158 NDArray array_value (bool = false) const;
00159
00160 FloatNDArray float_array_value (bool = false) const { return matrix; }
00161
00162 SparseMatrix sparse_matrix_value (bool = false) const;
00163
00164 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const;
00165
00166 octave_value diag (octave_idx_type k = 0) const;
00167
00168
00169 void increment (void) { matrix_ref () += 1.0; }
00170
00171 void decrement (void) { matrix_ref () -= 1.0; }
00172
00173 void changesign (void) { matrix_ref ().changesign (); }
00174
00175 octave_value convert_to_str_internal (bool pad, bool force, char type) const;
00176
00177 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
00178
00179 bool save_ascii (std::ostream& os);
00180
00181 bool load_ascii (std::istream& is);
00182
00183 bool save_binary (std::ostream& os, bool& save_as_floats);
00184
00185 bool load_binary (std::istream& is, bool swap,
00186 oct_mach_info::float_format fmt);
00187
00188 #if defined (HAVE_HDF5)
00189 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats);
00190
00191 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug);
00192 #endif
00193
00194 int write (octave_stream& os, int block_size,
00195 oct_data_conv::data_type output_type, int skip,
00196 oct_mach_info::float_format flt_fmt) const
00197 { return os.write (matrix, block_size, output_type, skip, flt_fmt); }
00198
00199
00200
00201 void *mex_get_data (void) const { return matrix.mex_get_data (); }
00202
00203 mxArray *as_mxArray (void) const;
00204
00205 octave_value erf (void) const;
00206 octave_value erfc (void) const;
00207 octave_value gamma (void) const;
00208 octave_value lgamma (void) const;
00209 octave_value abs (void) const;
00210 octave_value acos (void) const;
00211 octave_value acosh (void) const;
00212 octave_value angle (void) const;
00213 octave_value arg (void) const;
00214 octave_value asin (void) const;
00215 octave_value asinh (void) const;
00216 octave_value atan (void) const;
00217 octave_value atanh (void) const;
00218 octave_value ceil (void) const;
00219 octave_value conj (void) const;
00220 octave_value cos (void) const;
00221 octave_value cosh (void) const;
00222 octave_value exp (void) const;
00223 octave_value expm1 (void) const;
00224 octave_value fix (void) const;
00225 octave_value floor (void) const;
00226 octave_value imag (void) const;
00227 octave_value log (void) const;
00228 octave_value log2 (void) const;
00229 octave_value log10 (void) const;
00230 octave_value log1p (void) const;
00231 octave_value real (void) const;
00232 octave_value round (void) const;
00233 octave_value roundb (void) const;
00234 octave_value signum (void) const;
00235 octave_value sin (void) const;
00236 octave_value sinh (void) const;
00237 octave_value sqrt (void) const;
00238 octave_value tan (void) const;
00239 octave_value tanh (void) const;
00240 octave_value finite (void) const;
00241 octave_value isinf (void) const;
00242 octave_value isna (void) const;
00243 octave_value isnan (void) const;
00244
00245 private:
00246 DECLARE_OCTAVE_ALLOCATOR
00247
00248 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
00249 };
00250
00251 #endif
00252
00253
00254
00255
00256
00257