64 "complex matrix",
"double");
107 if (! force_conversion)
109 "complex matrix",
"real scalar");
114 "complex matrix",
"real scalar");
129 if (! force_conversion)
131 "complex matrix",
"real scalar");
136 "complex matrix",
"real scalar");
151 if (! force_conversion)
153 "complex matrix",
"real matrix");
165 if (! force_conversion)
167 "complex matrix",
"real matrix");
179 if (! force_conversion)
181 "complex matrix",
"real matrix");
198 "complex matrix",
"complex scalar");
218 "complex matrix",
"complex scalar");
246 ||
real (
matrix).any_element_not_one_or_zero ()))
259 "complex matrix",
"string");
283 if (! force_conversion)
285 "complex matrix",
"real matrix");
321 retval = mat.
diag (m, n);
324 error (
"diag: expecting vector argument");
337 os <<
"# ndims: " << d.
length () <<
"\n";
339 for (
int i = 0; i < d.
length (); i++)
348 os <<
"# rows: " <<
rows () <<
"\n"
349 <<
"# columns: " <<
columns () <<
"\n";
364 keywords[0] =
"ndims";
365 keywords[1] =
"rows";
374 int mdims =
static_cast<int> (val);
381 for (
int i = 0; i < mdims; i++)
394 error (
"load: failed to load matrix constant");
400 error (
"load: failed to read dimensions");
406 error (
"load: failed to extract number of dimensions");
410 else if (kw ==
"rows")
417 if (nr > 0 && nc > 0)
425 error (
"load: failed to load matrix constant");
429 else if (nr == 0 || nc == 0)
436 error (
"load: failed to extract number of rows and columns");
445 error (
"load: failed to extract number of rows and columns");
460 int32_t tmp = - d.
length ();
461 os.write (reinterpret_cast<char *> (&tmp), 4);
462 for (
int i = 0; i < d.
length (); i++)
465 os.write (reinterpret_cast<char *> (&tmp), 4);
474 warning (
"save: some values too large to save as floats --");
475 warning (
"save: saving as doubles instead");
480 else if (d.
numel () > 4096)
482 double max_val, min_val;
489 write_doubles (os, reinterpret_cast<const double *> (mtmp), st,
501 if (! is.read (reinterpret_cast<char *> (&mdims), 4))
512 for (
int i = 0; i < mdims; i++)
514 if (! is.read (reinterpret_cast<char *> (&di), 4))
533 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
539 static_cast<save_type> (tmp), 2 * dv.
numel (), swap, fmt);
548 if (! is.read (reinterpret_cast<char *> (&nc), 4))
552 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
558 static_cast<save_type> (tmp), 2*len, swap, fmt);
570 #if defined (HAVE_HDF5)
578 hid_t space_hid, data_hid, type_hid;
579 space_hid = data_hid = type_hid = -1;
586 for (
int i = 0; i < rank; i++)
587 hdims[i] = dv (rank-i-1);
589 space_hid = H5Screate_simple (rank, hdims, 0);
590 if (space_hid < 0)
return false;
592 hid_t save_type_hid = H5T_NATIVE_DOUBLE;
598 warning (
"save: some values too large to save as floats --");
599 warning (
"save: saving as doubles instead");
602 save_type_hid = H5T_NATIVE_FLOAT;
604 #if HAVE_HDF5_INT2FLOAT_CONVERSIONS
608 double max_val, min_val;
619 H5Sclose (space_hid);
623 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid,
624 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
626 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid, H5P_DEFAULT);
630 H5Sclose (space_hid);
636 if (complex_type_hid < 0) retval =
false;
641 if (H5Dwrite (data_hid, complex_type_hid, H5S_ALL, H5S_ALL, H5P_DEFAULT,
644 H5Tclose (complex_type_hid);
649 H5Tclose (complex_type_hid);
652 H5Sclose (space_hid);
667 #if defined (HAVE_HDF5)
677 hid_t data_hid = H5Dopen (loc_id, name, H5P_DEFAULT);
679 hid_t data_hid = H5Dopen (loc_id, name);
681 hid_t type_hid = H5Dget_type (data_hid);
687 H5Tclose (complex_type);
692 hid_t space_id = H5Dget_space (data_hid);
694 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
698 H5Tclose (complex_type);
707 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
719 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
725 if (H5Dread (data_hid, complex_type, H5S_ALL, H5S_ALL, H5P_DEFAULT,
732 H5Tclose (complex_type);
745 bool pr_as_read_syntax)
const
756 double *pr =
static_cast<double *
> (retval->
get_data ());
757 double *pi =
static_cast<double *
> (retval->
get_imag_data ());
763 for (
mwIndex i = 0; i < nel; i++)
785 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
786 case umap_ ## UMAP: \
787 return octave_value (matrix.FCN ())
794 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
795 case umap_ ## UMAP: \
796 return octave_value (matrix.map<TYPE> (FCN))
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
void gripe_implicit_conversion(const char *id, const char *from, const char *to)
bool all_integers(double &max_val, double &min_val) const
float float_value(bool=false) const
bool hdf5_types_compatible(hid_t t1, hid_t t2)
bool load_binary(std::istream &is, bool swap, oct_mach_info::float_format fmt)
bool any_element_is_nan(void) const
type_conv_info numeric_demotion_function(void) const
octave_idx_type columns(void) const
static octave_base_value * default_numeric_demotion_function(const octave_base_value &a)
std::complex< double > erfi(std::complex< double > z, double relerr=0)
octave_idx_type numel(void) const
Number of elements in the array.
void gripe_load(const char *type) const
FloatComplexNDArray float_complex_array_value(bool=false) const
save_type get_save_type(double, double)
Matrix matrix_value(bool=false) const
Complex complex_value(bool=false) const
octave_value diag(octave_idx_type k=0) const
octave_idx_type numel(void) const
void resize(int n, int fill_value=0)
void error(const char *fmt,...)
void * get_data(void) const
bool save_ascii(std::ostream &os)
bool load_ascii(std::istream &is)
octave_value diag(octave_idx_type k=0) const
ComplexNDArray complex_array_value(bool=false) const
void write_doubles(std::ostream &os, const double *data, save_type type, octave_idx_type len)
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
void gripe_save(const char *type) const
T & elem(octave_idx_type n)
double lo_ieee_nan_value(void)
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
bool save_binary(std::ostream &os, bool &save_as_floats)
FloatComplexMatrix float_complex_matrix_value(bool=false) const
std::complex< double > erf(std::complex< double > z, double relerr=0)
octave_idx_type rows(void) const
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
F77_RET_T const double const double double * d
int load_hdf5_empty(hid_t loc_id, const char *name, dim_vector &d)
NDArray array_value(bool=false) const
bool too_large_for_float(void) const
octave_value map(unary_mapper_t umap) const
hid_t hdf5_make_complex_type(hid_t num_type)
ComplexColumnVector conj(const ComplexColumnVector &a)
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
void swap_bytes< 4 >(void *ptr)
FloatComplex float_complex_value(bool=false) const
bool all_elements_are_real(void) const
void gripe_nan_to_logical_conversion(void)
std::complex< T > ceil(const std::complex< T > &x)
octave_base_value * try_narrowing_conversion(void)
const T * data(void) const
void resize(const dim_vector &dv, const T &rfv)
#define panic_impossible()
std::complex< double > erfcx(std::complex< double > z, double relerr=0)
boolMatrix mx_el_ne(const boolMatrix &m1, const boolMatrix &m2)
SparseMatrix sparse_matrix_value(bool=false) const
void read_doubles(std::istream &is, double *data, save_type type, octave_idx_type len, bool swap, oct_mach_info::float_format fmt)
float lo_ieee_float_nan_value(void)
ComplexMatrix complex_matrix_value(bool=false) const
void warning(const char *fmt,...)
dim_vector dims(void) const
void gripe_logical_conversion(void)
void * get_imag_data(void) const
void gripe_invalid_conversion(const std::string &from, const std::string &to)
#define ARRAY_MAPPER(UMAP, TYPE, FCN)
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
double double_value(bool=false) const
int current_print_indent_level(void) const
#define ARRAY_METHOD_MAPPER(UMAP, FCN)
void octave_print_internal(std::ostream &, char, bool)
int save_hdf5_empty(hid_t loc_id, const char *name, const dim_vector d)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
virtual octave_value map(unary_mapper_t) const
FloatMatrix float_matrix_value(bool=false) const
mxArray * as_mxArray(void) const
static const pair_type keywords[]
Complex asin(const Complex &x)
ColumnVector imag(const ComplexColumnVector &a)
std::complex< float > FloatComplex
static int static_type_id(void)
std::complex< T > floor(const std::complex< T > &x)
ComplexMatrix diag(octave_idx_type k=0) const
std::complex< double > Complex
const T * fortran_vec(void) const
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
charNDArray char_array_value(bool frc_str_conv=false) const
Complex acos(const Complex &x)
ColumnVector real(const ComplexColumnVector &a)
boolNDArray bool_array_value(bool warn=false) const
Complex atan(const Complex &x)
octave_idx_type columns(void) const
octave_idx_type rows(void) const
bool octave_is_NA(double x)
std::complex< double > erfc(std::complex< double > z, double relerr=0)