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 #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 (), dense_cache () { }
00039
00040 octave_perm_matrix (const PermMatrix& p) : matrix (p), dense_cache () { }
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 builtin_type_t builtin_type (void) const { return btyp_double; }
00104
00105 bool is_perm_matrix (void) const { return true; }
00106
00107 bool is_matrix_type (void) const { return true; }
00108
00109 bool is_numeric_type (void) const { return true; }
00110
00111 bool is_defined (void) const { return true; }
00112
00113 bool is_constant (void) const { return true; }
00114
00115 bool is_real_matrix (void) const { return true; }
00116
00117 bool is_real_type (void) const { return true; }
00118
00119 bool is_double_type (void) const { return true; }
00120
00121 bool is_float_type (void) const { return true; }
00122
00123 bool is_true (void) const;
00124
00125 double double_value (bool = false) const;
00126
00127 float float_value (bool = false) const;
00128
00129 double scalar_value (bool frc_str_conv = false) const
00130 { return double_value (frc_str_conv); }
00131
00132 idx_vector index_vector (void) const;
00133
00134 PermMatrix perm_matrix_value (void) const
00135 { return matrix; }
00136
00137 Matrix matrix_value (bool = false) const;
00138
00139 FloatMatrix float_matrix_value (bool = false) const;
00140
00141 Complex complex_value (bool = false) const;
00142
00143 FloatComplex float_complex_value (bool = false) const;
00144
00145 ComplexMatrix complex_matrix_value (bool = false) const;
00146
00147 FloatComplexMatrix float_complex_matrix_value (bool = false) const;
00148
00149 ComplexNDArray complex_array_value (bool = false) const;
00150
00151 FloatComplexNDArray float_complex_array_value (bool = false) const;
00152
00153 boolNDArray bool_array_value (bool warn = false) const;
00154
00155 charNDArray char_array_value (bool = false) const;
00156
00157 NDArray array_value (bool = false) const;
00158
00159 FloatNDArray float_array_value (bool = false) const;
00160
00161 SparseMatrix sparse_matrix_value (bool = false) const;
00162
00163 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const;
00164
00165 int8NDArray
00166 int8_array_value (void) const { return to_dense ().int8_array_value (); }
00167
00168 int16NDArray
00169 int16_array_value (void) const { return to_dense ().int16_array_value (); }
00170
00171 int32NDArray
00172 int32_array_value (void) const { return to_dense ().int32_array_value (); }
00173
00174 int64NDArray
00175 int64_array_value (void) const { return to_dense ().int64_array_value (); }
00176
00177 uint8NDArray
00178 uint8_array_value (void) const { return to_dense ().uint8_array_value (); }
00179
00180 uint16NDArray
00181 uint16_array_value (void) const { return to_dense ().uint16_array_value (); }
00182
00183 uint32NDArray
00184 uint32_array_value (void) const { return to_dense ().uint32_array_value (); }
00185
00186 uint64NDArray
00187 uint64_array_value (void) const { return to_dense ().uint64_array_value (); }
00188
00189 octave_value convert_to_str_internal (bool pad, bool force, char type) const;
00190
00191 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
00192
00193 bool save_ascii (std::ostream& os);
00194
00195 bool load_ascii (std::istream& is);
00196
00197 bool save_binary (std::ostream& os, bool& save_as_floats);
00198
00199 bool load_binary (std::istream& is, bool swap,
00200 oct_mach_info::float_format fmt);
00201
00202 int write (octave_stream& os, int block_size,
00203 oct_data_conv::data_type output_type, int skip,
00204 oct_mach_info::float_format flt_fmt) const;
00205
00206 mxArray *as_mxArray (void) const;
00207
00208 bool print_as_scalar (void) const;
00209
00210 void print (std::ostream& os, bool pr_as_read_syntax = false) const;
00211
00212 void print_info (std::ostream& os, const std::string& prefix) const;
00213
00214 octave_value map (unary_mapper_t umap) const
00215 { return to_dense ().map (umap); }
00216
00217 protected:
00218
00219 PermMatrix matrix;
00220
00221 virtual octave_value to_dense (void) const;
00222
00223 mutable octave_value dense_cache;
00224
00225 private:
00226
00227 DECLARE_OCTAVE_ALLOCATOR
00228
00229 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
00230 };
00231
00232 #endif