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