GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-cx-mat.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2018 John W. Eaton
4 Copyright (C) 2009-2010 VZLU Prague
5 
6 This file is part of Octave.
7 
8 Octave is free software: you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if ! defined (octave_ov_cx_mat_h)
25 #define octave_ov_cx_mat_h 1
26 
27 #include "octave-config.h"
28 
29 #include <cstdlib>
30 
31 #include <iosfwd>
32 #include <string>
33 
34 #include "mx-base.h"
35 #include "str-vec.h"
36 
37 #include "error.h"
38 #include "oct-stream.h"
39 #include "ov-base.h"
40 #include "ov-base-mat.h"
41 #include "ov-typeinfo.h"
42 
43 #include "MatrixType.h"
44 
45 class octave_value_list;
46 
47 // Complex matrix values.
48 
49 class
50 OCTINTERP_API
52 {
53 public:
54 
57 
60 
63 
66 
69 
72 
75 
78 
81 
82  ~octave_complex_matrix (void) = default;
83 
84  octave_base_value * clone (void) const
85  { return new octave_complex_matrix (*this); }
87  { return new octave_complex_matrix (); }
88 
89  type_conv_info numeric_demotion_function (void) const;
90 
91  octave_base_value * try_narrowing_conversion (void);
92 
93  builtin_type_t builtin_type (void) const { return btyp_complex; }
94 
95  bool is_complex_matrix (void) const { return true; }
96 
97  bool iscomplex (void) const { return true; }
98 
99  bool is_double_type (void) const { return true; }
100 
101  bool isfloat (void) const { return true; }
102 
103  double double_value (bool = false) const;
104 
105  float float_value (bool = false) const;
106 
107  double scalar_value (bool frc_str_conv = false) const
108  { return double_value (frc_str_conv); }
109 
110  float float_scalar_value (bool frc_str_conv = false) const
111  { return float_value (frc_str_conv); }
112 
113  NDArray array_value (bool = false) const;
114 
115  Matrix matrix_value (bool = false) const;
116 
117  FloatMatrix float_matrix_value (bool = false) const;
118 
119  Complex complex_value (bool = false) const;
120 
121  FloatComplex float_complex_value (bool = false) const;
122 
123  ComplexMatrix complex_matrix_value (bool = false) const;
124 
125  FloatComplexMatrix float_complex_matrix_value (bool = false) const;
126 
127  ComplexNDArray complex_array_value (bool = false) const { return matrix; }
128 
129  FloatComplexNDArray float_complex_array_value (bool = false) const;
130 
131  boolNDArray bool_array_value (bool warn = false) const;
132 
133  charNDArray char_array_value (bool frc_str_conv = false) const;
134 
135  SparseMatrix sparse_matrix_value (bool = false) const;
136 
137  SparseComplexMatrix sparse_complex_matrix_value (bool = false) const;
138 
139  octave_value as_double (void) const;
140  octave_value as_single (void) const;
141 
142  octave_value diag (octave_idx_type k = 0) const;
143 
144  octave_value diag (octave_idx_type m, octave_idx_type n) const;
145 
146  void increment (void) { matrix += Complex (1.0); }
147 
148  void decrement (void) { matrix -= Complex (1.0); }
149 
150  void changesign (void) { matrix.changesign (); }
151 
152  bool save_ascii (std::ostream& os);
153 
154  bool load_ascii (std::istream& is);
155 
156  bool save_binary (std::ostream& os, bool& save_as_floats);
157 
158  bool load_binary (std::istream& is, bool swap,
160 
161  bool save_hdf5 (octave_hdf5_id loc_id, const char *name, bool save_as_floats);
162 
163  bool load_hdf5 (octave_hdf5_id loc_id, const char *name);
164 
165  int write (octave::stream& os, int block_size,
166  oct_data_conv::data_type output_type, int skip,
168  {
169  // Yes, for compatibility, we drop the imaginary part here.
170  return os.write (matrix_value (true), block_size, output_type,
171  skip, flt_fmt);
172  }
173 
174  void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
175 
176  mxArray * as_mxArray (void) const;
177 
178  octave_value map (unary_mapper_t umap) const;
179 
180 private:
181 
183 };
184 
185 #endif
octave_idx_type write(const octave_value &data, octave_idx_type block_size, oct_data_conv::data_type output_type, octave_idx_type skip, mach_info::float_format flt_fmt)
Definition: oct-stream.cc:6704
void decrement(void)
Definition: ov-cx-mat.h:148
octave_base_value * clone(void) const
Definition: ov-cx-mat.h:84
characters Given a string matrix
Definition: hex2num.cc:155
ComplexNDArray complex_array_value(bool=false) const
Definition: ov-cx-mat.h:127
for large enough k
Definition: lu.cc:617
octave::mach_info::float_format flt_fmt
Definition: load-save.cc:736
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
Definition: ov-usr-fcn.cc:997
double scalar_value(bool frc_str_conv=false) const
Definition: ov-cx-mat.h:107
builtin_type_t
Definition: ov-base.h:71
octave_complex_matrix(const ComplexMatrix &m, const MatrixType &t)
Definition: ov-cx-mat.h:64
octave_complex_matrix(const ComplexRowVector &v)
Definition: ov-cx-mat.h:73
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
float float_scalar_value(bool frc_str_conv=false) const
Definition: ov-cx-mat.h:110
octave_complex_matrix(const Array< Complex > &m)
Definition: ov-cx-mat.h:67
static double as_double(time_t sec, long usec)
Definition: oct-time.h:34
bool swap
Definition: load-save.cc:738
bool is_complex_matrix(void) const
Definition: ov-cx-mat.h:95
#define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
Definition: ov-base.h:158
nd deftypefn *std::string name
Definition: sysdep.cc:647
octave_complex_matrix(const ComplexMatrix &m)
Definition: ov-cx-mat.h:61
int write(octave::stream &os, int block_size, oct_data_conv::data_type output_type, int skip, octave::mach_info::float_format flt_fmt) const
Definition: ov-cx-mat.h:165
Array< octave_value > array_value(void) const
Definition: ovl.h:86
bool save_as_floats
Definition: load-save.cc:1617
void increment(void)
Definition: ov-cx-mat.h:146
int64_t octave_hdf5_id
Definition: dMatrix.h:36
void changesign(void)
Definition: ov-cx-mat.h:150
octave_complex_matrix(const ComplexColumnVector &v)
Definition: ov-cx-mat.h:76
bool isfloat(void) const
Definition: ov-cx-mat.h:101
octave_complex_matrix(void)
Definition: ov-cx-mat.h:55
octave_map map(dims)
builtin_type_t builtin_type(void) const
Definition: ov-cx-mat.h:93
octave_base_value * empty_clone(void) const
Definition: ov-cx-mat.h:86
std::complex< float > FloatComplex
Definition: oct-cmplx.h:32
bool is_double_type(void) const
Definition: ov-cx-mat.h:99
octave_complex_matrix(const octave_complex_matrix &cm)
Definition: ov-cx-mat.h:79
std::complex< double > Complex
Definition: oct-cmplx.h:31
write the output to stdout if nargout is
Definition: load-save.cc:1612
octave_complex_matrix(const ComplexNDArray &m)
Definition: ov-cx-mat.h:58
octave_complex_matrix(const ComplexDiagMatrix &d)
Definition: ov-cx-mat.h:70
octave::stream os
Definition: file-io.cc:627
bool iscomplex(void) const
Definition: ov-cx-mat.h:97