GNU Octave  4.2.1
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-2017 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 "octave-config.h"
27 
28 #include "mx-base.h"
29 #include "str-vec.h"
30 
31 #include "ov-base.h"
32 #include "ov-typeinfo.h"
33 #include "ovl.h"
34 
35 class
38 {
39 public:
40  octave_perm_matrix (void) : matrix (), dense_cache () { }
41 
42  octave_perm_matrix (const PermMatrix& p) : matrix (p), dense_cache () { }
43 
44  octave_base_value *clone (void) const
45  { return new octave_perm_matrix (*this); }
47  { return new octave_perm_matrix (); }
48 
49  type_conv_info numeric_conversion_function (void) const;
50 
51  octave_base_value *try_narrowing_conversion (void);
52 
53  size_t byte_size (void) const { return matrix.byte_size (); }
54 
55  octave_value squeeze (void) const { return matrix; }
56 
57  octave_value full_value (void) const { return to_dense (); }
58 
60  const std::list<octave_value_list>& idx);
61 
63  const std::list<octave_value_list>& idx, int)
64  { return subsref (type, idx); }
65 
66  octave_value do_index_op (const octave_value_list& idx,
67  bool resize_ok = false);
68 
69  dim_vector dims (void) const { return matrix.dims (); }
70 
71  octave_idx_type nnz (void) const { return matrix.rows (); }
72 
73  octave_value reshape (const dim_vector& new_dims) const
74  { return to_dense ().reshape (new_dims); }
75 
76  octave_value permute (const Array<int>& vec, bool inv = false) const
77  { return to_dense ().permute (vec, inv); }
78 
79  octave_value resize (const dim_vector& dv, bool fill = false) const
80  { return to_dense ().resize (dv, fill); }
81 
82  octave_value all (int dim = 0) const { return to_dense ().all (dim); }
83  octave_value any (int dim = 0) const { return to_dense ().any (dim); }
84 
87  { return matrix_type (); }
88 
90  { return to_dense () .diag (k); }
91 
93  { return to_dense ().sort (dim, mode); }
95  sortmode mode = ASCENDING) const
96  { return to_dense ().sort (sidx, dim, mode); }
97 
99  { return to_dense ().is_sorted (mode); }
100 
102  { return to_dense ().sort_rows_idx (mode); }
103 
105  { return to_dense ().is_sorted_rows (mode); }
106 
107  builtin_type_t builtin_type (void) const { return btyp_double; }
108 
109  bool is_perm_matrix (void) const { return true; }
110 
111  bool is_matrix_type (void) const { return true; }
112 
113  bool is_numeric_type (void) const { return true; }
114 
115  bool is_defined (void) const { return true; }
116 
117  bool is_constant (void) const { return true; }
118 
119  bool is_real_matrix (void) const { return true; }
120 
121  bool is_real_type (void) const { return true; }
122 
123  bool is_double_type (void) const { return true; }
124 
125  bool is_float_type (void) const { return true; }
126 
127  bool is_true (void) const;
128 
129  double double_value (bool = false) const;
130 
131  float float_value (bool = false) const;
132 
133  double scalar_value (bool frc_str_conv = false) const
134  { return double_value (frc_str_conv); }
135 
136  idx_vector index_vector (bool require_integers = false) const;
137 
139  { return matrix; }
140 
141  Matrix matrix_value (bool = false) const;
142 
143  FloatMatrix float_matrix_value (bool = false) const;
144 
145  Complex complex_value (bool = false) const;
146 
147  FloatComplex float_complex_value (bool = false) const;
148 
149  ComplexMatrix complex_matrix_value (bool = false) const;
150 
151  FloatComplexMatrix float_complex_matrix_value (bool = false) const;
152 
153  ComplexNDArray complex_array_value (bool = false) const;
154 
155  FloatComplexNDArray float_complex_array_value (bool = false) const;
156 
157  boolNDArray bool_array_value (bool warn = false) const;
158 
159  charNDArray char_array_value (bool = false) const;
160 
161  NDArray array_value (bool = false) const;
162 
163  FloatNDArray float_array_value (bool = false) const;
164 
165  SparseMatrix sparse_matrix_value (bool = false) const;
166 
167  SparseBoolMatrix sparse_bool_matrix_value (bool = false) const;
168 
169  SparseComplexMatrix sparse_complex_matrix_value (bool = false) const;
170 
172  int8_array_value (void) const { return to_dense ().int8_array_value (); }
173 
175  int16_array_value (void) const { return to_dense ().int16_array_value (); }
176 
178  int32_array_value (void) const { return to_dense ().int32_array_value (); }
179 
181  int64_array_value (void) const { return to_dense ().int64_array_value (); }
182 
184  uint8_array_value (void) const { return to_dense ().uint8_array_value (); }
185 
187  uint16_array_value (void) const { return to_dense ().uint16_array_value (); }
188 
190  uint32_array_value (void) const { return to_dense ().uint32_array_value (); }
191 
193  uint64_array_value (void) const { return to_dense ().uint64_array_value (); }
194 
195  octave_value convert_to_str_internal (bool pad, bool force, char type) const;
196 
197  octave_value as_double (void) const;
198  octave_value as_single (void) const;
199 
200  octave_value as_int8 (void) const;
201  octave_value as_int16 (void) const;
202  octave_value as_int32 (void) const;
203  octave_value as_int64 (void) const;
204 
205  octave_value as_uint8 (void) const;
206  octave_value as_uint16 (void) const;
207  octave_value as_uint32 (void) const;
208  octave_value as_uint64 (void) const;
209 
210  void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
211 
212  bool save_ascii (std::ostream& os);
213 
214  bool load_ascii (std::istream& is);
215 
216  bool save_binary (std::ostream& os, bool& save_as_floats);
217 
218  bool load_binary (std::istream& is, bool swap,
220 
221  int write (octave_stream& os, int block_size,
222  oct_data_conv::data_type output_type, int skip,
224 
225  mxArray *as_mxArray (void) const;
226 
227  bool print_as_scalar (void) const;
228 
229  void print (std::ostream& os, bool pr_as_read_syntax = false);
230 
231  void print_info (std::ostream& os, const std::string& prefix) const;
232 
234  { return to_dense ().map (umap); }
235 
236  octave_value fast_elem_extract (octave_idx_type n) const;
237 
238 protected:
239 
241 
242  virtual octave_value to_dense (void) const;
243 
245 
246 private:
247 
249 };
250 
251 #endif
bool is_true(const std::string &s)
Definition: mkoctfile.cc:398
octave_value all(int dim=0) const
Definition: ov-perm.h:82
octave_value reshape(const dim_vector &dv) const
Definition: ov.h:515
octave_value permute(const Array< int > &vec, bool inv=false) const
Definition: ov.h:518
int8NDArray int8_array_value(void) const
Definition: ov-perm.h:172
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Sort by rows returns only indices.
Definition: Array.cc:2087
bool is_numeric_type(void) const
Definition: ov-perm.h:113
bool is_matrix_type(void) const
Definition: ov-perm.h:111
sortmode
Definition: oct-sort.h:105
double scalar_value(bool frc_str_conv=false) const
Definition: ov-perm.h:133
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
Definition: data.cc:6386
idx subsref(val, idx) esult
Definition: ov.cc:3080
octave_value diag(octave_idx_type k=0) const
Definition: ov.h:1311
for large enough k
Definition: lu.cc:606
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the then the first element defines the pivoting tolerance for the unsymmetric the values defined such that for full matrix
Definition: lu.cc:138
size_t byte_size(void) const
Definition: ov-perm.h:53
int32NDArray int32_array_value(void) const
Definition: ov-perm.h:178
octave_value map(octave_base_value::unary_mapper_t umap) const
Definition: ov.h:1413
octave::mach_info::float_format flt_fmt
Definition: load-save.cc:723
octave_value resize(const dim_vector &dv, bool fill=false) const
Definition: ov.h:524
PermMatrix perm_matrix_value(void) const
Definition: ov-perm.h:138
octave_base_value * empty_clone(void) const
Definition: ov-perm.h:46
octave_perm_matrix(const PermMatrix &p)
Definition: ov-perm.h:42
builtin_type_t
Definition: ov-base.h:61
octave_value resize(const dim_vector &dv, bool fill=false) const
Definition: ov-perm.h:79
int64NDArray int64_array_value(void) const
Definition: ov-perm.h:181
bool swap
Definition: load-save.cc:725
#define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
Definition: ov-base.h:148
octave_value any(int dim=0) const
Definition: ov.h:616
MatrixType matrix_type(const MatrixType &) const
Definition: ov-perm.h:86
uint64NDArray uint64_array_value(void) const
Definition: ov-perm.h:193
bool is_real_type(void) const
Definition: ov-perm.h:121
#define OCTINTERP_API
Definition: mexproto.h:69
bool is_float_type(void) const
Definition: ov-perm.h:125
octave_value permute(const Array< int > &vec, bool inv=false) const
Definition: ov-perm.h:76
uint8NDArray uint8_array_value(void) const
Definition: ov-perm.h:184
octave_value any(int dim=0) const
Definition: ov-perm.h:83
bool save_as_floats
Definition: load-save.cc:1581
octave_value_list subsref(const std::string &type, const std::list< octave_value_list > &idx, int)
Definition: ov-perm.h:62
idx type
Definition: ov.cc:3129
Definition: dMatrix.h:37
octave_value squeeze(void) const
Definition: ov-perm.h:55
octave_value all(int dim=0) const
Definition: ov.h:613
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
Definition: ov-perm.h:92
PermMatrix matrix
Definition: ov-perm.h:240
octave_value full_value(void) const
Definition: ov-perm.h:57
bool is_defined(void) const
Definition: ov-perm.h:115
uint16NDArray uint16_array_value(void) const
Definition: ov-perm.h:187
bool is_constant(void) const
Definition: ov-perm.h:117
octave_value dense_cache
Definition: ov-perm.h:244
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
Definition: ov.h:1317
MatrixType matrix_type(void) const
Definition: ov-perm.h:85
octave_idx_type nnz(void) const
Definition: ov-perm.h:71
bool is_double_type(void) const
Definition: ov-perm.h:123
p
Definition: lu.cc:138
octave_perm_matrix(void)
Definition: ov-perm.h:40
octave_value diag(octave_idx_type k=0) const
Definition: ov-perm.h:89
int16NDArray int16_array_value(void) const
Definition: ov-perm.h:175
sortmode is_sorted(sortmode mode=UNSORTED) const
Definition: ov-perm.h:98
octave_base_value * clone(void) const
Definition: ov-perm.h:44
std::complex< float > FloatComplex
Definition: oct-cmplx.h:32
octave_value sort(Array< octave_idx_type > &sidx, octave_idx_type dim=0, sortmode mode=ASCENDING) const
Definition: ov-perm.h:94
uint32NDArray uint32_array_value(void) const
Definition: ov-perm.h:190
bool is_real_matrix(void) const
Definition: ov-perm.h:119
std::complex< double > Complex
Definition: oct-cmplx.h:31
builtin_type_t builtin_type(void) const
Definition: ov-perm.h:107
write the output to stdout if nargout is
Definition: load-save.cc:1576
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Definition: ov-perm.h:104
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
octave_value reshape(const dim_vector &new_dims) const
Definition: ov-perm.h:73
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:854
dim_vector dv
Definition: sub2ind.cc:263
bool is_perm_matrix(void) const
Definition: ov-perm.h:109
octave_value map(unary_mapper_t umap) const
Definition: ov-perm.h:233
dim_vector dims(void) const
Definition: ov-perm.h:69
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Definition: ov-perm.h:101