112 "real matrix",
"real scalar");
130 "real matrix",
"real scalar");
164 "real matrix",
"complex scalar");
184 "real matrix",
"complex scalar");
282 retval = mat.
diag (m, n);
285 error (
"diag: expecting vector argument");
417 ::warning (
"range error for conversion to character value");
422 chm (i) =
static_cast<char> (ival);
440 os <<
"# ndims: " << d.
length () <<
"\n";
442 for (
int i=0; i < d.
length (); i++)
451 os <<
"# rows: " <<
rows () <<
"\n"
452 <<
"# columns: " <<
columns () <<
"\n";
467 keywords[0] =
"ndims";
468 keywords[1] =
"rows";
477 int mdims =
static_cast<int> (val);
484 for (
int i = 0; i < mdims; i++)
497 error (
"load: failed to load matrix constant");
503 error (
"load: failed to read dimensions");
509 error (
"load: failed to extract number of dimensions");
513 else if (kw ==
"rows")
520 if (nr > 0 && nc > 0)
528 error (
"load: failed to load matrix constant");
532 else if (nr == 0 || nc == 0)
539 error (
"load: failed to extract number of rows and columns");
548 error (
"load: failed to extract number of rows and columns");
564 int32_t tmp = - d.
length ();
565 os.write (reinterpret_cast<char *> (&tmp), 4);
566 for (
int i = 0; i < d.
length (); i++)
569 os.write (reinterpret_cast<char *> (&tmp), 4);
578 warning (
"save: some values too large to save as floats --");
579 warning (
"save: saving as doubles instead");
584 else if (d.
numel () > 8192)
586 double max_val, min_val;
591 const double *mtmp = m.
data ();
603 if (! is.read (reinterpret_cast<char *> (&mdims), 4))
614 for (
int i = 0; i < mdims; i++)
616 if (! is.read (reinterpret_cast<char *> (&di), 4))
635 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
650 if (! is.read (reinterpret_cast<char *> (&nc), 4))
654 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
659 read_doubles (is, re, static_cast<save_type> (tmp), len, swap, fmt);
672 #if defined (HAVE_HDF5)
680 hid_t space_hid, data_hid;
681 space_hid = data_hid = -1;
687 for (
int i = 0; i < rank; i++)
688 hdims[i] = dv (rank-i-1);
690 space_hid = H5Screate_simple (rank, hdims, 0);
692 if (space_hid < 0)
return false;
694 hid_t save_type_hid = H5T_NATIVE_DOUBLE;
700 warning (
"save: some values too large to save as floats --");
701 warning (
"save: saving as doubles instead");
704 save_type_hid = H5T_NATIVE_FLOAT;
706 #if HAVE_HDF5_INT2FLOAT_CONVERSIONS
710 double max_val, min_val;
719 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
720 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
722 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
727 H5Sclose (space_hid);
732 retval = H5Dwrite (data_hid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL,
733 H5P_DEFAULT, mtmp) >= 0;
736 H5Sclose (space_hid);
750 #if defined (HAVE_HDF5)
760 hid_t data_hid = H5Dopen (loc_id, name, H5P_DEFAULT);
762 hid_t data_hid = H5Dopen (loc_id, name);
764 hid_t space_id = H5Dget_space (data_hid);
766 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
778 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
790 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
796 if (H5Dread (data_hid, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL,
797 H5P_DEFAULT, re) >= 0)
815 bool pr_as_read_syntax)
const
826 double *pr =
static_cast<double *
> (retval->
get_data ());
832 for (
mwIndex i = 0; i < nel; i++)
852 if (tmp.imag () == 0.0)
890 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
891 case umap_ ## UMAP: \
892 return octave_value (matrix.FCN ())
899 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
900 case umap_ ## UMAP: \
901 return octave_value (matrix.map<TYPE> (FCN))
903 #define RC_ARRAY_MAPPER(UMAP, TYPE, FCN) \
904 case umap_ ## UMAP: \
905 return do_rc_map (matrix, FCN)
975 DEFUN (
double, args, ,
977 @deftypefn {Built-in Function} {} double (@var{x})\n\
978 Convert @var{x} to double precision type.\n\
986 if (args.length () == 1)
988 if (args(0).is_perm_matrix ())
992 else if (args(0).is_diag_matrix ())
994 if (args(0).is_complex_type ())
1005 else if (args(0).is_sparse_type ())
1007 if (args(0).is_complex_type ())
1018 else if (args(0).is_complex_type ())
Matrix diag(octave_idx_type k=0) const
void gripe_implicit_conversion(const char *id, const char *from, const char *to)
Complex rc_asin(double x)
octave_value squeeze(void) const
NDArray array_value(bool=false) const
charNDArray char_array_value(bool=false) const
sortmode is_sorted(sortmode mode=UNSORTED) const
sortmode is_sorted(sortmode mode=UNSORTED) const
octave_idx_type columns(void) const
octave_value convert_to_str_internal(bool pad, bool force, char type) const
OCTINTERP_API void print_usage(void)
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
static octave_value do_rc_map(const NDArray &a, Complex(&fcn)(double))
save_type get_save_type(double, double)
Complex rc_acos(double x)
octave_value reshape(const dim_vector &new_dims) const
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
octave_idx_type numel(void) const
void resize(int n, int fill_value=0)
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
octave_value diag(octave_idx_type k=0) const
double double_value(bool=false) const
void * get_data(void) const
octave_value map(octave_base_value::unary_mapper_t umap) const
octave_value diag(octave_idx_type k=0) const
static octave_base_value * default_numeric_demotion_function(const octave_base_value &a)
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)
Matrix matrix_value(bool=false) const
bool any_element_is_nan(void) const
FloatMatrix float_matrix_value(bool=false) const
FloatComplexMatrix float_complex_matrix_value(bool=false) const
FloatComplex float_complex_value(bool=false) const
#define RC_ARRAY_MAPPER(UMAP, TYPE, FCN)
FloatComplexNDArray float_complex_array_value(bool=false) const
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
std::complex< double > erf(std::complex< double > z, double relerr=0)
type_conv_info numeric_demotion_function(void) const
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)
subroutine xgamma(x, result)
octave_idx_type nelem(void) const
Number of elements in the array.
octave_value map(unary_mapper_t umap) const
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
bool any_element_not_one_or_zero(void) const
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
octave_base_value * try_narrowing_conversion(void)
Complex rc_log1p(double x)
bool all_integers(double &max_val, double &min_val) const
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
void swap_bytes< 4 >(void *ptr)
Complex rc_lgamma(double x)
NDArray squeeze(void) const
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
boolNDArray bool_array_value(bool warn=false) const
void gripe_nan_to_logical_conversion(void)
std::complex< T > ceil(const std::complex< T > &x)
#define OCTAVE_TYPE_CONV_BODY3(NAME, MATRIX_RESULT_T, SCALAR_RESULT_T)
const T * data(void) const
void resize(const dim_vector &dv, const T &rfv)
Array< T > squeeze(void) const
Chop off leading singleton dimensions.
Complex rc_sqrt(double x)
#define panic_impossible()
void gripe_nan_to_character_conversion(void)
Complex rc_log2(double x)
std::complex< double > erfcx(std::complex< double > z, double relerr=0)
bool save_ascii(std::ostream &os)
octave_value reshape(const dim_vector &new_dims) const
Complex rc_atanh(double x)
Complex complex_value(bool=false) const
ComplexMatrix complex_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)
Complex rc_log10(double x)
Array< octave_idx_type > as_array(void) const
friend class octave_value
void warning(const char *fmt,...)
dim_vector dims(void) const
sortmode is_sorted(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
charNDArray max(char d, const charNDArray &m)
octave_idx_type extent(octave_idx_type n) const
This is a simple wrapper template that will subclass an Array type or any later type derived from ...
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
void gripe_logical_conversion(void)
Complex rc_acosh(double x)
void gripe_invalid_conversion(const std::string &from, const std::string &to)
int current_print_indent_level(void) const
bool save_binary(std::ostream &os, bool &save_as_floats)
void octave_print_internal(std::ostream &, char, bool)
bool load_binary(std::istream &is, bool swap, oct_mach_info::float_format fmt)
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
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
mxArray * as_mxArray(void) const
Array< T > reshape(octave_idx_type nr, octave_idx_type nc) const
float float_value(bool=false) const
static const pair_type keywords[]
Complex asin(const Complex &x)
static int static_type_id(void)
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
std::complex< float > FloatComplex
#define ARRAY_MAPPER(UMAP, TYPE, FCN)
std::complex< T > floor(const std::complex< T > &x)
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
std::complex< double > Complex
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
const T * fortran_vec(void) const
bool load_ascii(std::istream &is)
MArray< T > reshape(const dim_vector &new_dims) const
Complex acos(const Complex &x)
#define ARRAY_METHOD_MAPPER(UMAP, FCN)
ComplexNDArray complex_array_value(bool=false) const
virtual octave_value convert_to_str(bool pad=false, bool force=false, char type= '\'') const
Complex atan(const Complex &x)
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
octave_value squeeze(void) const
octave_idx_type columns(void) const
octave_idx_type rows(void) const
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
bool too_large_for_float(void) const
SparseMatrix sparse_matrix_value(bool=false) const
bool octave_is_NA(double x)
std::complex< double > erfc(std::complex< double > z, double relerr=0)