GNU Octave  3.8.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-cx-mat.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2013 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 the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 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 <http://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 <cstdlib>
28 
29 #include <iosfwd>
30 #include <string>
31 
32 #include "mx-base.h"
33 #include "oct-alloc.h"
34 #include "str-vec.h"
35 
36 #include "error.h"
37 #include "oct-stream.h"
38 #include "ov-base.h"
39 #include "ov-base-mat.h"
40 #include "ov-typeinfo.h"
41 
42 #include "MatrixType.h"
43 
44 class octave_value_list;
45 
46 class tree_walker;
47 
48 // Complex matrix values.
49 
50 class
53 {
54 public:
55 
58 
61 
64 
67 
70 
73 
76 
79 
82 
84 
85  octave_base_value *clone (void) const
86  { return new octave_complex_matrix (*this); }
87  octave_base_value *empty_clone (void) const
88  { return new octave_complex_matrix (); }
89 
90  type_conv_info numeric_demotion_function (void) const;
91 
92  octave_base_value *try_narrowing_conversion (void);
93 
94  builtin_type_t builtin_type (void) const { return btyp_complex; }
95 
96  bool is_complex_matrix (void) const { return true; }
97 
98  bool is_complex_type (void) const { return true; }
99 
100  bool is_double_type (void) const { return true; }
101 
102  bool is_float_type (void) const { return true; }
103 
104  double double_value (bool = false) const;
105 
106  float float_value (bool = false) const;
107 
108  double scalar_value (bool frc_str_conv = false) const
109  { return double_value (frc_str_conv); }
110 
111  float float_scalar_value (bool frc_str_conv = false) const
112  { return float_value (frc_str_conv); }
113 
114  Matrix matrix_value (bool = false) const;
115 
116  FloatMatrix float_matrix_value (bool = false) const;
117 
118  Complex complex_value (bool = false) const;
119 
120  FloatComplex float_complex_value (bool = false) const;
121 
122  ComplexMatrix complex_matrix_value (bool = false) const;
123 
124  FloatComplexMatrix float_complex_matrix_value (bool = false) const;
125 
126  ComplexNDArray complex_array_value (bool = false) const { return matrix; }
127 
128  FloatComplexNDArray float_complex_array_value (bool = false) const;
129 
130  boolNDArray bool_array_value (bool warn = false) const;
131 
132  charNDArray char_array_value (bool frc_str_conv = false) const;
133 
134  SparseMatrix sparse_matrix_value (bool = false) const;
135 
136  SparseComplexMatrix sparse_complex_matrix_value (bool = false) const;
137 
138  octave_value diag (octave_idx_type k = 0) const;
139 
140  octave_value diag (octave_idx_type m, octave_idx_type n) const;
141 
142  void increment (void) { matrix += Complex (1.0); }
143 
144  void decrement (void) { matrix -= Complex (1.0); }
145 
146  void changesign (void) { matrix.changesign (); }
147 
148  bool save_ascii (std::ostream& os);
149 
150  bool load_ascii (std::istream& is);
151 
152  bool save_binary (std::ostream& os, bool& save_as_floats);
153 
154  bool load_binary (std::istream& is, bool swap,
156 
157 #if defined (HAVE_HDF5)
158  bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats);
159 
160  bool load_hdf5 (hid_t loc_id, const char *name);
161 #endif
162 
163  int write (octave_stream& os, int block_size,
164  oct_data_conv::data_type output_type, int skip,
165  oct_mach_info::float_format flt_fmt) const
166  {
167  // Yes, for compatibility, we drop the imaginary part here.
168  return os.write (matrix_value (true), block_size, output_type,
169  skip, flt_fmt);
170  }
171 
172  void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
173 
174  mxArray *as_mxArray (void) const;
175 
176  octave_value map (unary_mapper_t umap) const;
177 
178 private:
179 
181 
183 };
184 
185 #endif