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-flt-complex.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2017 John W. Eaton
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_flt_complex_h)
24 #define octave_ov_flt_complex_h 1
25 
26 #include "octave-config.h"
27 
28 #include <cstdlib>
29 
30 #include <iosfwd>
31 #include <string>
32 
33 #include "lo-ieee.h"
34 #include "mx-base.h"
35 #include "str-vec.h"
36 
37 #include "errwarn.h"
38 #include "error.h"
39 #include "ov-base.h"
40 #include "ov-flt-cx-mat.h"
41 #include "ov-base-scalar.h"
42 #include "ov-typeinfo.h"
43 
44 class octave_value_list;
45 
46 class tree_walker;
47 
48 // Complex scalar values.
49 
50 class
53 {
54 public:
55 
58 
61 
64 
66 
67  octave_base_value *clone (void) const
68  { return new octave_float_complex (*this); }
69 
70  // We return an octave_float_complex_matrix object here instead of an
71  // octave_float_complex object so that in expressions like A(2,2,2) = 2
72  // (for A previously undefined), A will be empty instead of a 1x1
73  // object.
75  { return new octave_float_complex_matrix (); }
76 
77  octave_base_value *try_narrowing_conversion (void);
78 
79  octave_value do_index_op (const octave_value_list& idx,
80  bool resize_ok = false);
81 
82  octave_value any (int = 0) const
83  {
84  return (scalar != FloatComplex (0, 0)
85  && ! (lo_ieee_isnan (scalar.real ())
86  || lo_ieee_isnan (scalar.imag ())));
87  }
88 
90 
91  bool is_complex_scalar (void) const { return true; }
92 
93  bool is_complex_type (void) const { return true; }
94 
95  bool is_single_type (void) const { return true; }
96 
97  bool is_float_type (void) const { return true; }
98 
99  double double_value (bool = false) const;
100 
101  float float_value (bool = false) const;
102 
103  double scalar_value (bool frc_str_conv = false) const
104  { return double_value (frc_str_conv); }
105 
106  float float_scalar_value (bool frc_str_conv = false) const
107  { return float_value (frc_str_conv); }
108 
109  Matrix matrix_value (bool = false) const;
110 
111  FloatMatrix float_matrix_value (bool = false) const;
112 
113  NDArray array_value (bool = false) const;
114 
115  FloatNDArray float_array_value (bool = false) const;
116 
117  SparseMatrix sparse_matrix_value (bool = false) const
118  { return SparseMatrix (matrix_value ()); }
119 
121  { return SparseComplexMatrix (complex_matrix_value ()); }
122 
123  octave_value resize (const dim_vector& dv, bool fill = false) const;
124 
125  Complex complex_value (bool = false) const;
126 
127  FloatComplex float_complex_value (bool = false) const;
128 
129  ComplexMatrix complex_matrix_value (bool = false) const;
130 
131  FloatComplexMatrix float_complex_matrix_value (bool = false) const;
132 
133  ComplexNDArray complex_array_value (bool = false) const;
134 
135  FloatComplexNDArray float_complex_array_value (bool = false) const;
136 
137  bool bool_value (bool warn = false) const
138  {
141  if (warn && scalar != 0.0f && scalar != 1.0f)
143 
144  return scalar != 0.0f;
145  }
146 
147  boolNDArray bool_array_value (bool warn = false) const
148  {
151  if (warn && scalar != 0.0f && scalar != 1.0f)
153 
154  return boolNDArray (dim_vector (1, 1), scalar != 1.0f);
155  }
156 
157  octave_value as_double (void) const;
158  octave_value as_single (void) const;
159 
161 
162  void increment (void) { scalar += 1.0; }
163 
164  void decrement (void) { scalar -= 1.0; }
165 
166  bool save_ascii (std::ostream& os);
167 
168  bool load_ascii (std::istream& is);
169 
170  bool save_binary (std::ostream& os, bool& save_as_floats);
171 
172  bool load_binary (std::istream& is, bool swap,
174 
175  bool save_hdf5 (octave_hdf5_id loc_id, const char *name, bool save_as_floats);
176 
177  bool load_hdf5 (octave_hdf5_id loc_id, const char *name);
178 
179  int write (octave_stream& os, int block_size,
180  oct_data_conv::data_type output_type, int skip,
182  {
183  // Yes, for compatibility, we drop the imaginary part here.
184  return os.write (array_value (true), block_size, output_type,
185  skip, flt_fmt);
186  }
187 
188  mxArray *as_mxArray (void) const;
189 
190  octave_value map (unary_mapper_t umap) const;
191 
192 private:
193 
195 };
196 
198 
199 #endif
float float_scalar_value(bool frc_str_conv=false) const
nd group nd example oindent but is performed more efficiently If only and it is a scalar
Definition: data.cc:5342
octave_idx_type write(const octave_value &data, octave_idx_type block_size, oct_data_conv::data_type output_type, octave_idx_type skip, octave::mach_info::float_format flt_fmt)
Definition: oct-stream.cc:6647
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
void warn_logical_conversion(void)
Definition: errwarn.cc:353
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &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 F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE * f
bool isnan(double x)
Definition: lo-mappers.cc:347
octave_base_value * empty_clone(void) const
bool is_single_type(void) const
octave::mach_info::float_format flt_fmt
Definition: load-save.cc:723
builtin_type_t
Definition: ov-base.h:61
void err_nan_to_logical_conversion(void)
boolNDArray bool_array_value(bool warn=false) const
#define lo_ieee_isnan(x)
Definition: lo-ieee.h:103
bool swap
Definition: load-save.cc:725
octave_base_value * clone(void) const
#define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
Definition: ov-base.h:148
octave_value any(int=0) const
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an so it may be a literal a variable name
Definition: input.cc:871
double scalar_value(bool frc_str_conv=false) const
#define OCTINTERP_API
Definition: mexproto.h:69
bool bool_value(bool warn=false) const
octave_float_complex(const octave_float_complex &c)
nd deftypefn *octave_map m
Definition: ov-struct.cc:2058
bool is_complex_type(void) const
bool is_complex_scalar(void) const
octave_float_complex(const FloatComplex &c)
bool save_as_floats
Definition: load-save.cc:1581
int64_t octave_hdf5_id
Definition: dMatrix.h:37
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
builtin_type_t builtin_type(void) const
bool is_float_type(void) const
octave_map map(dims)
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
octave_float_complex octave_float_complex_scalar
std::complex< float > FloatComplex
Definition: oct-cmplx.h:32
SparseMatrix sparse_matrix_value(bool=false) const
std::complex< double > Complex
Definition: oct-cmplx.h:31
write the output to stdout if nargout is
Definition: load-save.cc:1576
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
dim_vector dv
Definition: sub2ind.cc:263