00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_perm_matrix_h)
00024 #define octave_perm_matrix_h 1
00025
00026 #include "mx-base.h"
00027 #include "str-vec.h"
00028
00029 #include "ov-base.h"
00030 #include "ov-typeinfo.h"
00031 #include "oct-obj.h"
00032
00033 class
00034 OCTINTERP_API
00035 octave_perm_matrix : public octave_base_value
00036 {
00037 public:
00038 octave_perm_matrix (void) : matrix () { }
00039
00040 octave_perm_matrix (const PermMatrix& p) : matrix (p) { }
00041
00042 octave_base_value *clone (void) const { return new octave_perm_matrix (*this); }
00043 octave_base_value *empty_clone (void) const { return new octave_perm_matrix (); }
00044
00045 type_conv_info numeric_conversion_function (void) const;
00046
00047 octave_base_value *try_narrowing_conversion (void);
00048
00049 size_t byte_size (void) const { return matrix.byte_size (); }
00050
00051 octave_value squeeze (void) const { return matrix; }
00052
00053 octave_value full_value (void) const { return to_dense (); }
00054
00055 octave_value subsref (const std::string& type,
00056 const std::list<octave_value_list>& idx);
00057
00058 octave_value_list subsref (const std::string& type,
00059 const std::list<octave_value_list>& idx, int)
00060 { return subsref (type, idx); }
00061
00062 octave_value do_index_op (const octave_value_list& idx,
00063 bool resize_ok = false);
00064
00065 dim_vector dims (void) const { return matrix.dims (); }
00066
00067 octave_idx_type nnz (void) const { return matrix.rows (); }
00068
00069 octave_value reshape (const dim_vector& new_dims) const
00070 { return to_dense ().reshape (new_dims); }
00071
00072 octave_value permute (const Array<int>& vec, bool inv = false) const
00073 { return to_dense ().permute (vec, inv); }
00074
00075 octave_value resize (const dim_vector& dv, bool fill = false) const
00076 { return to_dense ().resize (dv, fill); }
00077
00078 octave_value all (int dim = 0) const { return to_dense ().all (dim); }
00079 octave_value any (int dim = 0) const { return to_dense ().any (dim); }
00080
00081 MatrixType matrix_type (void) const { return MatrixType::Permuted_Diagonal; }
00082 MatrixType matrix_type (const MatrixType&) const
00083 { return matrix_type (); }
00084
00085 octave_value diag (octave_idx_type k = 0) const
00086 { return to_dense () .diag (k); }
00087
00088 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const
00089 { return to_dense ().sort (dim, mode); }
00090 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0,
00091 sortmode mode = ASCENDING) const
00092 { return to_dense ().sort (sidx, dim, mode); }
00093
00094 sortmode is_sorted (sortmode mode = UNSORTED) const
00095 { return to_dense ().is_sorted (mode); }
00096
00097 Array<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const
00098 { return to_dense ().sort_rows_idx (mode); }
00099
00100 sortmode is_sorted_rows (sortmode mode = UNSORTED) const
00101 { return to_dense ().is_sorted_rows (mode); }
00102
00103 bool is_perm_matrix (void) const { return true; }
00104
00105 bool is_matrix_type (void) const { return true; }
00106
00107 bool is_numeric_type (void) const { return true; }
00108
00109 bool is_defined (void) const { return true; }
00110
00111 bool is_constant (void) const { return true; }
00112
00113 bool is_real_matrix (void) const { return true; }
00114
00115 bool is_real_type (void) const { return true; }
00116
00117 bool is_double_type (void) const { return true; }
00118
00119 bool is_float_type (void) const { return true; }
00120
00121 bool is_true (void) const;
00122
00123 double double_value (bool = false) const;
00124
00125 float float_value (bool = false) const;
00126
00127 double scalar_value (bool frc_str_conv = false) const
00128 { return double_value (frc_str_conv); }
00129
00130 idx_vector index_vector (void) const;
00131
00132 PermMatrix perm_matrix_value (void) const
00133 { return matrix; }
00134
00135 Matrix matrix_value (bool = false) const;
00136
00137 FloatMatrix float_matrix_value (bool = false) const;
00138
00139 Complex complex_value (bool = false) const;
00140
00141 FloatComplex float_complex_value (bool = false) const;
00142
00143 ComplexMatrix complex_matrix_value (bool = false) const;
00144
00145 FloatComplexMatrix float_complex_matrix_value (bool = false) const;
00146
00147 ComplexNDArray complex_array_value (bool = false) const;
00148
00149 FloatComplexNDArray float_complex_array_value (bool = false) const;
00150
00151 boolNDArray bool_array_value (bool warn = false) const;
00152
00153 charNDArray char_array_value (bool = false) const;
00154
00155 NDArray array_value (bool = false) const;
00156
00157 FloatNDArray float_array_value (bool = false) const;
00158
00159 SparseMatrix sparse_matrix_value (bool = false) const;
00160
00161 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const;
00162
00163 int8NDArray
00164 int8_array_value (void) const { return to_dense ().int8_array_value (); }
00165
00166 int16NDArray
00167 int16_array_value (void) const { return to_dense ().int16_array_value (); }
00168
00169 int32NDArray
00170 int32_array_value (void) const { return to_dense ().int32_array_value (); }
00171
00172 int64NDArray
00173 int64_array_value (void) const { return to_dense ().int64_array_value (); }
00174
00175 uint8NDArray
00176 uint8_array_value (void) const { return to_dense ().uint8_array_value (); }
00177
00178 uint16NDArray
00179 uint16_array_value (void) const { return to_dense ().uint16_array_value (); }
00180
00181 uint32NDArray
00182 uint32_array_value (void) const { return to_dense ().uint32_array_value (); }
00183
00184 uint64NDArray
00185 uint64_array_value (void) const { return to_dense ().uint64_array_value (); }
00186
00187 octave_value convert_to_str_internal (bool pad, bool force, char type) const;
00188
00189 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
00190
00191 bool save_ascii (std::ostream& os);
00192
00193 bool load_ascii (std::istream& is);
00194
00195 bool save_binary (std::ostream& os, bool& save_as_floats);
00196
00197 bool load_binary (std::istream& is, bool swap,
00198 oct_mach_info::float_format fmt);
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
00204 mxArray *as_mxArray (void) const;
00205
00206 bool print_as_scalar (void) const;
00207
00208 void print (std::ostream& os, bool pr_as_read_syntax = false) const;
00209
00210 void print_info (std::ostream& os, const std::string& prefix) const;
00211
00212 octave_value erf (void) const;
00213 octave_value erfc (void) const;
00214 octave_value gamma (void) const;
00215 octave_value lgamma (void) const;
00216 octave_value abs (void) const;
00217 octave_value acos (void) const;
00218 octave_value acosh (void) const;
00219 octave_value angle (void) const;
00220 octave_value arg (void) const;
00221 octave_value asin (void) const;
00222 octave_value asinh (void) const;
00223 octave_value atan (void) const;
00224 octave_value atanh (void) const;
00225 octave_value ceil (void) const;
00226 octave_value conj (void) const;
00227 octave_value cos (void) const;
00228 octave_value cosh (void) const;
00229 octave_value exp (void) const;
00230 octave_value expm1 (void) const;
00231 octave_value fix (void) const;
00232 octave_value floor (void) const;
00233 octave_value imag (void) const;
00234 octave_value log (void) const;
00235 octave_value log2 (void) const;
00236 octave_value log10 (void) const;
00237 octave_value log1p (void) const;
00238 octave_value real (void) const;
00239 octave_value round (void) const;
00240 octave_value roundb (void) const;
00241 octave_value signum (void) const;
00242 octave_value sin (void) const;
00243 octave_value sinh (void) const;
00244 octave_value sqrt (void) const;
00245 octave_value tan (void) const;
00246 octave_value tanh (void) const;
00247 octave_value finite (void) const;
00248 octave_value isinf (void) const;
00249 octave_value isna (void) const;
00250 octave_value isnan (void) const;
00251
00252 protected:
00253
00254 PermMatrix matrix;
00255
00256 virtual octave_value to_dense (void) const;
00257
00258 mutable octave_value dense_cache;
00259
00260 private:
00261
00262 DECLARE_OCTAVE_ALLOCATOR
00263
00264 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
00265 };
00266
00267 #endif