26#if defined (HAVE_CONFIG_H)
56 "complex scalar",
"double");
66 complex_index_exception (
const std::string& value)
73 OCTAVE_DEFAULT_COPY_MOVE (complex_index_exception)
75 ~complex_index_exception () =
default;
80 +
": subscripts must be real (forgot to initialize i or j?)");
84 const char *
err_id ()
const
86 return "Octave:invalid-index";
91 complex_index_exception *retval =
new complex_index_exception {*
this};
92 retval->set_identifier (retval->err_id ());
97OCTAVE_END_NAMESPACE(octave)
120 double im =
scalar.imag ();
143 return tmp.
index_op (idx, resize_ok);
150 std::ostringstream buf;
152 octave::complex_index_exception cie (buf.str ());
160 if (! force_conversion)
162 "complex scalar",
"real scalar");
170 if (! force_conversion)
172 "complex scalar",
"real scalar");
182 if (! force_conversion)
184 "complex scalar",
"real matrix");
196 if (! force_conversion)
198 "complex scalar",
"real matrix");
210 if (! force_conversion)
212 "complex scalar",
"real matrix");
224 if (! force_conversion)
226 "complex scalar",
"real matrix");
316 octave::write_value<Complex> (os, c);
326 scalar = octave::read_value<Complex> (is);
329 error (
"load: failed to load complex scalar constant");
337 char tmp =
static_cast<char> (
LS_DOUBLE);
338 os.write (
reinterpret_cast<char *
> (&tmp), 1);
340 os.write (
reinterpret_cast<char *
> (&ctmp), 16);
347 octave::mach_info::float_format fmt)
350 if (! is.read (
reinterpret_cast<char *
> (&tmp), 1))
355 static_cast<save_type> (tmp), 2, swap, fmt);
370#if defined (HAVE_HDF5)
372 hsize_t dimens[3] = {0};
373 hid_t space_hid, type_hid, data_hid;
374 space_hid = type_hid = data_hid = -1;
376 space_hid = H5Screate_simple (0, dimens,
nullptr);
383 H5Sclose (space_hid);
386#if defined (HAVE_HDF5_18)
387 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid,
395 H5Sclose (space_hid);
406 H5Sclose (space_hid);
409 octave_unused_parameter (loc_id);
410 octave_unused_parameter (name);
423#if defined (HAVE_HDF5)
425#if defined (HAVE_HDF5_18)
428 hid_t data_hid = H5Dopen (loc_id, name);
430 hid_t type_hid = H5Dget_type (data_hid);
436 H5Tclose (complex_type);
441 hid_t space_id = H5Dget_space (data_hid);
442 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
446 H5Tclose (complex_type);
461 H5Tclose (complex_type);
466 octave_unused_parameter (loc_id);
467 octave_unused_parameter (name);
478 mxArray *retval =
new mxArray (interleaved, mxDOUBLE_CLASS, 1, 1, mxCOMPLEX);
485 pd[0].real =
scalar.real ();
486 pd[0].imag =
scalar.imag ();
490 mxDouble *pr =
static_cast<mxDouble *
> (retval->
get_data ());
491 mxDouble *pi =
static_cast<mxDouble *
> (retval->
get_imag_data ());
505#define SCALAR_MAPPER(UMAP, FCN) \
506 case umap_ ## UMAP: \
507 return octave_value (FCN (scalar))
ComplexColumnVector conj(const ComplexColumnVector &a)
N Dimensional Array with copy-on-write semantics.
Vector representing the dimensions (size) of an Array.
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
std::string expression() const
virtual index_exception * dup()=0
virtual const char * err_id() const =0
virtual void update_message()
mxComplexDouble * get_complex_doubles() const
void * get_imag_data() const
virtual octave_value map(unary_mapper_t) const
void warn_load(const char *type) const
void warn_save(const char *type) const
float float_value(bool=false) const
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
bool save_binary(std::ostream &os, bool save_as_floats)
FloatComplex float_complex_value(bool=false) const
NDArray array_value(bool=false) const
FloatComplexMatrix float_complex_matrix_value(bool=false) const
octave_value diag(octave_idx_type m, octave_idx_type n) const
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
mxArray * as_mxArray(bool interleaved) const
ComplexMatrix complex_matrix_value(bool=false) const
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
bool save_ascii(std::ostream &os)
octave_value map(unary_mapper_t umap) const
octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)
octave_value as_single() const
octave_base_value * try_narrowing_conversion()
FloatNDArray float_array_value(bool=false) const
octave::idx_vector index_vector(bool=false) const
octave_value resize(const dim_vector &dv, bool fill=false) const
FloatMatrix float_matrix_value(bool=false) const
type_conv_info numeric_demotion_function() const
bool load_ascii(std::istream &is)
ComplexNDArray complex_array_value(bool=false) const
FloatComplexNDArray float_complex_array_value(bool=false) const
Matrix matrix_value(bool=false) const
octave_value as_double() const
double double_value(bool=false) const
Complex complex_value(bool=false) const
static int static_type_id()
octave_value index_op(const octave_value_list &idx, bool resize_ok=false)
octave_value real() const
octave_value imag() const
const octave_hdf5_id octave_H5P_DEFAULT
const octave_hdf5_id octave_H5S_ALL
ColumnVector real(const ComplexColumnVector &a)
ColumnVector imag(const ComplexColumnVector &a)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void read_doubles(std::istream &is, double *data, save_type type, octave_idx_type len, bool swap, octave::mach_info::float_format fmt)
void error(const char *fmt,...)
void warn_implicit_conversion(const char *id, const char *from, const char *to)
Complex log2(const Complex &x)
Complex asin(const Complex &x)
Complex acos(const Complex &x)
std::complex< T > ceil(const std::complex< T > &x)
Complex atan(const Complex &x)
std::complex< T > floor(const std::complex< T > &x)
Complex erf(const Complex &x)
Complex expm1(const Complex &x)
Complex log1p(const Complex &x)
Complex erfc(const Complex &x)
octave_hdf5_id hdf5_make_complex_type(octave_hdf5_id num_type)
bool hdf5_types_compatible(octave_hdf5_id t1, octave_hdf5_id t2)
std::complex< double > Complex
std::complex< float > FloatComplex
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
#define SCALAR_MAPPER(UMAP, FCN)
template int8_t abs(int8_t)