GNU Octave  6.2.0
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-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_ov_cx_mat_h)
27 #define octave_ov_cx_mat_h 1
28 
29 #include "octave-config.h"
30 
31 #include <cstdlib>
32 
33 #include <iosfwd>
34 #include <string>
35 
36 #include "mx-base.h"
37 #include "str-vec.h"
38 
39 #include "error.h"
40 #include "oct-stream.h"
41 #include "ov-base.h"
42 #include "ov-base-mat.h"
43 #include "ov-typeinfo.h"
44 
45 #include "MatrixType.h"
46 
47 class octave_value_list;
48 
49 // Complex matrix values.
50 
51 class
52 OCTINTERP_API
54 {
55 public:
56 
59 
62 
65 
68 
71 
74 
77 
80 
83 
84  ~octave_complex_matrix (void) = default;
85 
86  octave_base_value * clone (void) const
87  { return new octave_complex_matrix (*this); }
89  { return new octave_complex_matrix (); }
90 
91  type_conv_info numeric_demotion_function (void) const;
92 
93  octave_base_value * try_narrowing_conversion (void);
94 
95  builtin_type_t builtin_type (void) const { return btyp_complex; }
96 
97  bool is_complex_matrix (void) const { return true; }
98 
99  bool iscomplex (void) const { return true; }
100 
101  bool is_double_type (void) const { return true; }
102 
103  bool isfloat (void) const { return true; }
104 
105  double double_value (bool = false) const;
106 
107  float float_value (bool = false) const;
108 
109  double scalar_value (bool frc_str_conv = false) const
110  { return double_value (frc_str_conv); }
111 
112  float float_scalar_value (bool frc_str_conv = false) const
113  { return float_value (frc_str_conv); }
114 
115  NDArray array_value (bool = false) const;
116 
117  Matrix matrix_value (bool = false) const;
118 
119  FloatMatrix float_matrix_value (bool = false) const;
120 
121  Complex complex_value (bool = false) const;
122 
123  FloatComplex float_complex_value (bool = false) const;
124 
125  ComplexMatrix complex_matrix_value (bool = false) const;
126 
127  FloatComplexMatrix float_complex_matrix_value (bool = false) const;
128 
129  ComplexNDArray complex_array_value (bool = false) const { return matrix; }
130 
131  FloatComplexNDArray float_complex_array_value (bool = false) const;
132 
133  boolNDArray bool_array_value (bool warn = false) const;
134 
135  charNDArray char_array_value (bool frc_str_conv = false) const;
136 
137  SparseMatrix sparse_matrix_value (bool = false) const;
138 
139  SparseComplexMatrix sparse_complex_matrix_value (bool = false) const;
140 
141  octave_value as_double (void) const;
142  octave_value as_single (void) const;
143 
144  octave_value diag (octave_idx_type k = 0) const;
145 
147 
148  void increment (void) { matrix += Complex (1.0); }
149 
150  void decrement (void) { matrix -= Complex (1.0); }
151 
152  void changesign (void) { matrix.changesign (); }
153 
154  bool save_ascii (std::ostream& os);
155 
156  bool load_ascii (std::istream& is);
157 
158  bool save_binary (std::ostream& os, bool save_as_floats);
159 
160  bool load_binary (std::istream& is, bool swap,
162 
163  bool save_hdf5 (octave_hdf5_id loc_id, const char *name, bool save_as_floats);
164 
165  bool load_hdf5 (octave_hdf5_id loc_id, const char *name);
166 
167  int write (octave::stream& os, int block_size,
168  oct_data_conv::data_type output_type, int skip,
169  octave::mach_info::float_format flt_fmt) const
170  {
171  // Yes, for compatibility, we drop the imaginary part here.
172  return os.write (matrix_value (true), block_size, output_type,
173  skip, flt_fmt);
174  }
175 
176  void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
177 
178  mxArray * as_mxArray (void) const;
179 
180  octave_value map (unary_mapper_t umap) const;
181 
182 private:
183 
185 };
186 
187 #endif
N Dimensional Array with copy-on-write semantics.
Definition: Array.h:128
Definition: dMatrix.h:42
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:6777
octave_complex_matrix(const ComplexMatrix &m, const MatrixType &t)
Definition: ov-cx-mat.h:66
void increment(void)
Definition: ov-cx-mat.h:148
octave_complex_matrix(const ComplexRowVector &v)
Definition: ov-cx-mat.h:75
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:167
octave_base_value * clone(void) const
Definition: ov-cx-mat.h:86
octave_complex_matrix(void)
Definition: ov-cx-mat.h:57
ComplexNDArray complex_array_value(bool=false) const
Definition: ov-cx-mat.h:129
octave_complex_matrix(const ComplexDiagMatrix &d)
Definition: ov-cx-mat.h:72
octave_complex_matrix(const ComplexMatrix &m)
Definition: ov-cx-mat.h:63
octave_complex_matrix(const octave_complex_matrix &cm)
Definition: ov-cx-mat.h:81
void changesign(void)
Definition: ov-cx-mat.h:152
octave_complex_matrix(const Array< Complex > &m)
Definition: ov-cx-mat.h:69
bool iscomplex(void) const
Definition: ov-cx-mat.h:99
octave_base_value * empty_clone(void) const
Definition: ov-cx-mat.h:88
bool is_complex_matrix(void) const
Definition: ov-cx-mat.h:97
float float_scalar_value(bool frc_str_conv=false) const
Definition: ov-cx-mat.h:112
octave_complex_matrix(const ComplexColumnVector &v)
Definition: ov-cx-mat.h:78
~octave_complex_matrix(void)=default
bool isfloat(void) const
Definition: ov-cx-mat.h:103
bool is_double_type(void) const
Definition: ov-cx-mat.h:101
double scalar_value(bool frc_str_conv=false) const
Definition: ov-cx-mat.h:109
octave_complex_matrix(const ComplexNDArray &m)
Definition: ov-cx-mat.h:60
void decrement(void)
Definition: ov-cx-mat.h:150
builtin_type_t builtin_type(void) const
Definition: ov-cx-mat.h:95
Array< octave_value > array_value(void) const
Definition: ovl.h:90
QString name
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
T octave_idx_type m
Definition: mx-inlines.cc:773
octave_idx_type n
Definition: mx-inlines.cc:753
std::complex< double > Complex
Definition: oct-cmplx.h:33
std::complex< float > FloatComplex
Definition: oct-cmplx.h:34
int64_t octave_hdf5_id
static double as_double(time_t sec, long usec)
Definition: oct-time.h:37
#define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
Definition: ov-base.h:158
builtin_type_t
Definition: ov-base.h:72
@ btyp_complex
Definition: ov-base.h:75