58 "bool matrix",
"logical");
87 if (nr == 1 && nc == 1)
102 "bool matrix",
"real scalar");
120 "bool matrix",
"real scalar");
140 "bool matrix",
"complex scalar");
160 "bool matrix",
"complex scalar");
180 bool pr_as_read_syntax)
const
193 os <<
"# ndims: " << d.
length () <<
"\n";
195 for (
int i = 0; i < d.
length (); i++)
204 os <<
"# rows: " <<
rows () <<
"\n"
205 <<
"# columns: " <<
columns () <<
"\n";
222 keywords[0] =
"ndims";
223 keywords[1] =
"rows";
232 int mdims =
static_cast<int> (val);
239 for (
int i = 0; i < mdims; i++)
256 btmp.
elem (i) = (tmp.elem (i) != 0.);
262 error (
"load: failed to load matrix constant");
269 error (
"load: failed to extract dimensions");
275 error (
"load: failed to extract number of dimensions");
279 else if (kw ==
"rows")
286 if (nr > 0 && nc > 0)
295 btmp.
elem (i,j) = (tmp.elem (i, j) != 0.);
301 error (
"load: failed to load matrix constant");
305 else if (nr == 0 || nc == 0)
312 error (
"load: failed to extract number of rows and columns");
321 error (
"load: failed to extract number of rows and columns");
337 int32_t tmp = - d.
length ();
338 os.write (reinterpret_cast<char *> (&tmp), 4);
339 for (
int i = 0; i < d.
length (); i++)
342 os.write (reinterpret_cast<char *> (&tmp), 4);
351 htmp[i] = (mtmp[i] ? 1 : 0);
353 os.write (htmp, nel);
363 if (! is.read (reinterpret_cast<char *> (&mdims), 4))
378 for (
int i = 0; i < mdims; i++)
380 if (! is.read (reinterpret_cast<char *> (&di), 4))
401 if (! is.read (htmp, nel))
406 mtmp[i] = (htmp[i] ? 1 : 0);
418 #if defined (HAVE_HDF5)
426 hid_t space_hid, data_hid;
427 space_hid = data_hid = -1;
433 for (
int i = 0; i < rank; i++)
434 hdims[i] = dv (rank-i-1);
436 space_hid = H5Screate_simple (rank, hdims, 0);
437 if (space_hid < 0)
return false;
439 data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_HBOOL, space_hid,
440 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
442 data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_HBOOL, space_hid,
447 H5Sclose (space_hid);
458 retval = H5Dwrite (data_hid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL,
459 H5P_DEFAULT, htmp) >= 0;
462 H5Sclose (space_hid);
476 #if defined (HAVE_HDF5)
486 hid_t data_hid = H5Dopen (loc_id, name, H5P_DEFAULT);
488 hid_t data_hid = H5Dopen (loc_id, name);
490 hid_t space_id = H5Dget_space (data_hid);
492 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
503 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
515 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
521 if (H5Dread (data_hid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL, H5P_DEFAULT, htmp)
528 btmp.
elem (i) = htmp[i];
547 bool *pr =
static_cast<bool *
> (retval->
get_data ());
553 for (
mwIndex i = 0; i < nel; i++)
559 DEFUN (logical, args, ,
561 @deftypefn {Built-in Function} {} logical (@var{x})\n\
562 Convert the numeric object @var{x} to logical type.\n\
564 Any nonzero values will be converted to true (1) while zero values will be\n\
565 converted to false (0). The non-numeric value NaN cannot be converted and\n\
566 will produce an error.\n\
568 Compatibility Note: Octave accepts complex values as input, whereas\n\
569 @sc{matlab} issues an error.\n\
570 @seealso{double, single, char}\n\
575 if (args.length () == 1)
void gripe_implicit_conversion(const char *id, const char *from, const char *to)
bool is_empty(void) const
octave_value convert_to_str_internal(bool pad, bool force, char type) const
static octave_base_value * default_numeric_conversion_function(const octave_base_value &a)
void gripe_wrong_type_arg(const char *name, const char *s, bool is_error)
octave_idx_type columns(void) const
OCTINTERP_API void print_usage(void)
void gripe_load(const char *type) const
bool is_scalar_type(void) const
bool is_numeric_type(void) 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,...)
void * get_data(void) const
#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)
Complex complex_value(bool=false) const
boolNDArray bool_array_value(bool warn=false) 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)
octave_idx_type nelem(void) const
Number of elements in the array.
double double_value(bool=false) const
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
void swap_bytes< 4 >(void *ptr)
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
octave_value convert_to_str(bool pad=false, bool force=false, char type= '\'') const
bool is_sparse_type(void) const
bool is_bool_type(void) const
static int static_type_id(void)
const T * data(void) const
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
bool save_binary(std::ostream &os, bool &save_as_floats)
void resize(const dim_vector &dv, const T &rfv)
#define panic_impossible()
float lo_ieee_float_nan_value(void)
friend class octave_value
bool save_ascii(std::ostream &os)
dim_vector dims(void) const
void gripe_invalid_conversion(const std::string &from, const std::string &to)
bool bool_value(bool warn=false) const
octave_base_value * try_narrowing_conversion(void)
int current_print_indent_level(void) const
type_conv_info numeric_conversion_function(void) const
NDArray array_value(bool=false) const
mxArray * as_mxArray(void) const
FloatComplex float_complex_value(bool=false) const
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)
float float_value(bool=false) const
static const pair_type keywords[]
std::complex< float > FloatComplex
bool load_binary(std::istream &is, bool swap, oct_mach_info::float_format fmt)
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
std::complex< double > Complex
const T * fortran_vec(void) const
octave_idx_type cols(void) const
octave_idx_type rows(void) const
Matrix matrix_value(bool=false) const
boolNDArray bool_array_value(bool=false) const
bool load_ascii(std::istream &is)