GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ov-perm.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2008-2015 Jaroslav Hajek
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_ov_perm_h)
24 #define octave_ov_perm_h 1
25 
26 #include "mx-base.h"
27 #include "str-vec.h"
28 
29 #include "ov-base.h"
30 #include "ov-typeinfo.h"
31 #include "oct-obj.h"
32 
33 class
36 {
37 public:
38  octave_perm_matrix (void) : matrix (), dense_cache () { }
39 
40  octave_perm_matrix (const PermMatrix& p) : matrix (p), dense_cache () { }
41 
42  octave_base_value *clone (void) const
43  { return new octave_perm_matrix (*this); }
45  { return new octave_perm_matrix (); }
46 
47  type_conv_info numeric_conversion_function (void) const;
48 
49  octave_base_value *try_narrowing_conversion (void);
50 
51  size_t byte_size (void) const { return matrix.byte_size (); }
52 
53  octave_value squeeze (void) const { return matrix; }
54 
55  octave_value full_value (void) const { return to_dense (); }
56 
57  octave_value subsref (const std::string& type,
58  const std::list<octave_value_list>& idx);
59 
60  octave_value_list subsref (const std::string& type,
61  const std::list<octave_value_list>& idx, int)
62  { return subsref (type, idx); }
63 
64  octave_value do_index_op (const octave_value_list& idx,
65  bool resize_ok = false);
66 
67  dim_vector dims (void) const { return matrix.dims (); }
68 
69  octave_idx_type nnz (void) const { return matrix.rows (); }
70 
71  octave_value reshape (const dim_vector& new_dims) const
72  { return to_dense ().reshape (new_dims); }
73 
74  octave_value permute (const Array<int>& vec, bool inv = false) const
75  { return to_dense ().permute (vec, inv); }
76 
77  octave_value resize (const dim_vector& dv, bool fill = false) const
78  { return to_dense ().resize (dv, fill); }
79 
80  octave_value all (int dim = 0) const { return to_dense ().all (dim); }
81  octave_value any (int dim = 0) const { return to_dense ().any (dim); }
82 
85  { return matrix_type (); }
86 
88  { return to_dense () .diag (k); }
89 
91  { return to_dense ().sort (dim, mode); }
93  sortmode mode = ASCENDING) const
94  { return to_dense ().sort (sidx, dim, mode); }
95 
97  { return to_dense ().is_sorted (mode); }
98 
100  { return to_dense ().sort_rows_idx (mode); }
101 
103  { return to_dense ().is_sorted_rows (mode); }
104 
105  builtin_type_t builtin_type (void) const { return btyp_double; }
106 
107  bool is_perm_matrix (void) const { return true; }
108 
109  bool is_matrix_type (void) const { return true; }
110 
111  bool is_numeric_type (void) const { return true; }
112 
113  bool is_defined (void) const { return true; }
114 
115  bool is_constant (void) const { return true; }
116 
117  bool is_real_matrix (void) const { return true; }
118 
119  bool is_real_type (void) const { return true; }
120 
121  bool is_double_type (void) const { return true; }
122 
123  bool is_float_type (void) const { return true; }
124 
125  bool is_true (void) const;
126 
127  double double_value (bool = false) const;
128 
129  float float_value (bool = false) const;
130 
131  double scalar_value (bool frc_str_conv = false) const
132  { return double_value (frc_str_conv); }
133 
134  idx_vector index_vector (bool require_integers = false) const;
135 
137  { return matrix; }
138 
139  Matrix matrix_value (bool = false) const;
140 
141  FloatMatrix float_matrix_value (bool = false) const;
142 
143  Complex complex_value (bool = false) const;
144 
145  FloatComplex float_complex_value (bool = false) const;
146 
147  ComplexMatrix complex_matrix_value (bool = false) const;
148 
149  FloatComplexMatrix float_complex_matrix_value (bool = false) const;
150 
151  ComplexNDArray complex_array_value (bool = false) const;
152 
153  FloatComplexNDArray float_complex_array_value (bool = false) const;
154 
155  boolNDArray bool_array_value (bool warn = false) const;
156 
157  charNDArray char_array_value (bool = false) const;
158 
159  NDArray array_value (bool = false) const;
160 
161  FloatNDArray float_array_value (bool = false) const;
162 
163  SparseMatrix sparse_matrix_value (bool = false) const;
164 
165  SparseBoolMatrix sparse_bool_matrix_value (bool = false) const;
166 
167  SparseComplexMatrix sparse_complex_matrix_value (bool = false) const;
168 
170  int8_array_value (void) const { return to_dense ().int8_array_value (); }
171 
173  int16_array_value (void) const { return to_dense ().int16_array_value (); }
174 
176  int32_array_value (void) const { return to_dense ().int32_array_value (); }
177 
179  int64_array_value (void) const { return to_dense ().int64_array_value (); }
180 
182  uint8_array_value (void) const { return to_dense ().uint8_array_value (); }
183 
185  uint16_array_value (void) const { return to_dense ().uint16_array_value (); }
186 
188  uint32_array_value (void) const { return to_dense ().uint32_array_value (); }
189 
191  uint64_array_value (void) const { return to_dense ().uint64_array_value (); }
192 
193  octave_value convert_to_str_internal (bool pad, bool force, char type) const;
194 
195  void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
196 
197  bool save_ascii (std::ostream& os);
198 
199  bool load_ascii (std::istream& is);
200 
201  bool save_binary (std::ostream& os, bool& save_as_floats);
202 
203  bool load_binary (std::istream& is, bool swap,
205 
206  int write (octave_stream& os, int block_size,
207  oct_data_conv::data_type output_type, int skip,
208  oct_mach_info::float_format flt_fmt) const;
209 
210  mxArray *as_mxArray (void) const;
211 
212  bool print_as_scalar (void) const;
213 
214  void print (std::ostream& os, bool pr_as_read_syntax = false);
215 
216  void print_info (std::ostream& os, const std::string& prefix) const;
217 
219  { return to_dense ().map (umap); }
220 
221  octave_value fast_elem_extract (octave_idx_type n) const;
222 
223 protected:
224 
226 
227  virtual octave_value to_dense (void) const;
228 
230 
231 private:
232 
233 
235 };
236 
237 #endif
bool is_true(const std::string &s)
Definition: mkoctfile.cc:373
octave_value all(int dim=0) const
Definition: ov-perm.h:80
octave_value reshape(const dim_vector &dv) const
Definition: ov.h:498
octave_value permute(const Array< int > &vec, bool inv=false) const
Definition: ov.h:501
int8NDArray int8_array_value(void) const
Definition: ov-perm.h:170
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Sort by rows returns only indices.
Definition: Array.cc:2086
bool is_numeric_type(void) const
Definition: ov-perm.h:111
bool is_matrix_type(void) const
Definition: ov-perm.h:109
sortmode
Definition: oct-sort.h:103
double scalar_value(bool frc_str_conv=false) const
Definition: ov-perm.h:131
octave_value diag(octave_idx_type k=0) const
Definition: ov.h:1126
size_t byte_size(void) const
Definition: ov-perm.h:51
int32NDArray int32_array_value(void) const
Definition: ov-perm.h:176
octave_value map(octave_base_value::unary_mapper_t umap) const
Definition: ov.h:1226
octave_value resize(const dim_vector &dv, bool fill=false) const
Definition: ov.h:507
PermMatrix perm_matrix_value(void) const
Definition: ov-perm.h:136
octave_base_value * empty_clone(void) const
Definition: ov-perm.h:44
octave_perm_matrix(const PermMatrix &p)
Definition: ov-perm.h:40
builtin_type_t
Definition: ov-base.h:59
octave_value resize(const dim_vector &dv, bool fill=false) const
Definition: ov-perm.h:77
int64NDArray int64_array_value(void) const
Definition: ov-perm.h:179
#define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
Definition: ov-base.h:142
octave_value any(int dim=0) const
Definition: ov.h:600
MatrixType matrix_type(const MatrixType &) const
Definition: ov-perm.h:84
uint64NDArray uint64_array_value(void) const
Definition: ov-perm.h:191
bool is_real_type(void) const
Definition: ov-perm.h:119
#define OCTINTERP_API
Definition: mexproto.h:66
bool is_float_type(void) const
Definition: ov-perm.h:123
octave_value permute(const Array< int > &vec, bool inv=false) const
Definition: ov-perm.h:74
uint8NDArray uint8_array_value(void) const
Definition: ov-perm.h:182
octave_value any(int dim=0) const
Definition: ov-perm.h:81
octave_value_list subsref(const std::string &type, const std::list< octave_value_list > &idx, int)
Definition: ov-perm.h:60
Definition: dMatrix.h:35
octave_value squeeze(void) const
Definition: ov-perm.h:53
octave_value all(int dim=0) const
Definition: ov.h:597
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
Definition: ov-perm.h:90
PermMatrix matrix
Definition: ov-perm.h:225
octave_value full_value(void) const
Definition: ov-perm.h:55
bool is_defined(void) const
Definition: ov-perm.h:113
uint16NDArray uint16_array_value(void) const
Definition: ov-perm.h:185
bool is_constant(void) const
Definition: ov-perm.h:115
octave_value dense_cache
Definition: ov-perm.h:229
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
Definition: ov.h:1132
MatrixType matrix_type(void) const
Definition: ov-perm.h:83
octave_idx_type nnz(void) const
Definition: ov-perm.h:69
bool is_double_type(void) const
Definition: ov-perm.h:121
octave_perm_matrix(void)
Definition: ov-perm.h:38
octave_value diag(octave_idx_type k=0) const
Definition: ov-perm.h:87
int16NDArray int16_array_value(void) const
Definition: ov-perm.h:173
sortmode is_sorted(sortmode mode=UNSORTED) const
Definition: ov-perm.h:96
octave_base_value * clone(void) const
Definition: ov-perm.h:42
std::complex< float > FloatComplex
Definition: oct-cmplx.h:30
octave_value sort(Array< octave_idx_type > &sidx, octave_idx_type dim=0, sortmode mode=ASCENDING) const
Definition: ov-perm.h:92
uint32NDArray uint32_array_value(void) const
Definition: ov-perm.h:188
bool is_real_matrix(void) const
Definition: ov-perm.h:117
std::complex< double > Complex
Definition: oct-cmplx.h:29
builtin_type_t builtin_type(void) const
Definition: ov-perm.h:105
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Definition: ov-perm.h:102
octave_value reshape(const dim_vector &new_dims) const
Definition: ov-perm.h:71
bool is_perm_matrix(void) const
Definition: ov-perm.h:107
octave_value map(unary_mapper_t umap) const
Definition: ov-perm.h:218
dim_vector dims(void) const
Definition: ov-perm.h:67
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Definition: ov-perm.h:99