00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined (octave_float_complex_h)
00025 #define octave_float_complex_h 1
00026
00027 #include <cstdlib>
00028
00029 #include <iosfwd>
00030 #include <string>
00031
00032 #include "lo-ieee.h"
00033 #include "mx-base.h"
00034 #include "oct-alloc.h"
00035 #include "str-vec.h"
00036
00037 #include "error.h"
00038 #include "ov-base.h"
00039 #include "ov-flt-cx-mat.h"
00040 #include "ov-base-scalar.h"
00041 #include "ov-typeinfo.h"
00042
00043 class Octave_map;
00044 class octave_value_list;
00045
00046 class tree_walker;
00047
00048
00049
00050 class
00051 OCTINTERP_API
00052 octave_float_complex : public octave_base_scalar<FloatComplex>
00053 {
00054 public:
00055
00056 octave_float_complex (void)
00057 : octave_base_scalar<FloatComplex> () { }
00058
00059 octave_float_complex (const FloatComplex& c)
00060 : octave_base_scalar<FloatComplex> (c) { }
00061
00062 octave_float_complex (const octave_float_complex& c)
00063 : octave_base_scalar<FloatComplex> (c) { }
00064
00065 ~octave_float_complex (void) { }
00066
00067 octave_base_value *clone (void) const { return new octave_float_complex (*this); }
00068
00069
00070
00071
00072
00073 octave_base_value *empty_clone (void) const
00074 { return new octave_float_complex_matrix (); }
00075
00076 octave_base_value *try_narrowing_conversion (void);
00077
00078 octave_value do_index_op (const octave_value_list& idx,
00079 bool resize_ok = false);
00080
00081 octave_value any (int = 0) const
00082 {
00083 return (scalar != FloatComplex (0, 0)
00084 && ! (lo_ieee_isnan (std::real (scalar))
00085 || lo_ieee_isnan (std::imag (scalar))));
00086 }
00087
00088 builtin_type_t builtin_type (void) const { return btyp_float_complex; }
00089
00090 bool is_complex_scalar (void) const { return true; }
00091
00092 bool is_complex_type (void) const { return true; }
00093
00094 bool is_single_type (void) const { return true; }
00095
00096 bool is_float_type (void) const { return true; }
00097
00098 double double_value (bool = false) const;
00099
00100 float float_value (bool = false) const;
00101
00102 double scalar_value (bool frc_str_conv = false) const
00103 { return double_value (frc_str_conv); }
00104
00105 float float_scalar_value (bool frc_str_conv = false) const
00106 { return float_value (frc_str_conv); }
00107
00108 Matrix matrix_value (bool = false) const;
00109
00110 FloatMatrix float_matrix_value (bool = false) const;
00111
00112 NDArray array_value (bool = false) const;
00113
00114 FloatNDArray float_array_value (bool = false) const;
00115
00116 SparseMatrix sparse_matrix_value (bool = false) const
00117 { return SparseMatrix (matrix_value ()); }
00118
00119 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const
00120 { return SparseComplexMatrix (complex_matrix_value ()); }
00121
00122 octave_value resize (const dim_vector& dv, bool fill = false) const;
00123
00124 Complex complex_value (bool = false) const;
00125
00126 FloatComplex float_complex_value (bool = false) const;
00127
00128 ComplexMatrix complex_matrix_value (bool = false) const;
00129
00130 FloatComplexMatrix float_complex_matrix_value (bool = false) const;
00131
00132 ComplexNDArray complex_array_value (bool = false) const;
00133
00134 FloatComplexNDArray float_complex_array_value (bool = false) const;
00135
00136 void increment (void) { scalar += 1.0; }
00137
00138 void decrement (void) { scalar -= 1.0; }
00139
00140 bool save_ascii (std::ostream& os);
00141
00142 bool load_ascii (std::istream& is);
00143
00144 bool save_binary (std::ostream& os, bool& save_as_floats);
00145
00146 bool load_binary (std::istream& is, bool swap,
00147 oct_mach_info::float_format fmt);
00148
00149 #if defined (HAVE_HDF5)
00150 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats);
00151
00152 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug);
00153 #endif
00154
00155 int write (octave_stream& os, int block_size,
00156 oct_data_conv::data_type output_type, int skip,
00157 oct_mach_info::float_format flt_fmt) const
00158 {
00159
00160 return os.write (array_value (true), block_size, output_type,
00161 skip, flt_fmt);
00162 }
00163
00164 mxArray *as_mxArray (void) const;
00165
00166 octave_value erf (void) const;
00167 octave_value erfc (void) const;
00168 octave_value gamma (void) const;
00169 octave_value lgamma (void) const;
00170 octave_value abs (void) const;
00171 octave_value acos (void) const;
00172 octave_value acosh (void) const;
00173 octave_value angle (void) const;
00174 octave_value arg (void) const;
00175 octave_value asin (void) const;
00176 octave_value asinh (void) const;
00177 octave_value atan (void) const;
00178 octave_value atanh (void) const;
00179 octave_value ceil (void) const;
00180 octave_value conj (void) const;
00181 octave_value cos (void) const;
00182 octave_value cosh (void) const;
00183 octave_value exp (void) const;
00184 octave_value expm1 (void) const;
00185 octave_value fix (void) const;
00186 octave_value floor (void) const;
00187 octave_value imag (void) const;
00188 octave_value log (void) const;
00189 octave_value log2 (void) const;
00190 octave_value log10 (void) const;
00191 octave_value log1p (void) const;
00192 octave_value real (void) const;
00193 octave_value round (void) const;
00194 octave_value roundb (void) const;
00195 octave_value signum (void) const;
00196 octave_value sin (void) const;
00197 octave_value sinh (void) const;
00198 octave_value sqrt (void) const;
00199 octave_value tan (void) const;
00200 octave_value tanh (void) const;
00201 octave_value finite (void) const;
00202 octave_value isinf (void) const;
00203 octave_value isna (void) const;
00204 octave_value isnan (void) const;
00205
00206 private:
00207
00208 DECLARE_OCTAVE_ALLOCATOR
00209
00210 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
00211 };
00212
00213 typedef octave_float_complex octave_float_complex_scalar;
00214
00215 #endif
00216
00217
00218
00219
00220
00221