49 #if ! defined (octave_mxarray_h)
50 #define octave_mxarray_h 1
52 #include "octave-config.h"
56 #if ! defined (MXARRAY_TYPEDEFS_ONLY)
64 #define DO_MUTABLE_METHOD(RET_T, METHOD_CALL) \
65 RET_T retval = m_rep->METHOD_CALL; \
67 if (m_rep->mutation_needed ()) \
70 retval = m_rep->METHOD_CALL; \
75 #define DO_VOID_MUTABLE_METHOD(METHOD_CALL) \
78 if (m_rep->mutation_needed ()) \
113 const char *cname = get_class_name ();
115 if (cname && name_arg)
116 retval = !
strcmp (cname, name_arg);
155 return is_logical () && get_number_of_elements () == 1;
160 virtual mwSize
get_m (
void)
const = 0;
162 virtual mwSize
get_n (
void)
const = 0;
200 err_invalid_type (
"set_property");
205 err_invalid_type (
"get_cell");
229 virtual mxComplexInt8 * get_complex_int8s (
void)
const = 0;
230 virtual mxComplexInt16 * get_complex_int16s (
void)
const = 0;
231 virtual mxComplexInt32 * get_complex_int32s (
void)
const = 0;
232 virtual mxComplexInt64 * get_complex_int64s (
void)
const = 0;
233 virtual mxComplexUint8 * get_complex_uint8s (
void)
const = 0;
234 virtual mxComplexUint16 * get_complex_uint16s (
void)
const = 0;
235 virtual mxComplexUint32 * get_complex_uint32s (
void)
const = 0;
236 virtual mxComplexUint64 * get_complex_uint64s (
void)
const = 0;
258 virtual int set_complex_int8s (mxComplexInt8 *data) = 0;
259 virtual int set_complex_int16s (mxComplexInt16 *data) = 0;
260 virtual int set_complex_int32s (mxComplexInt32 *data) = 0;
261 virtual int set_complex_int64s (mxComplexInt64 *data) = 0;
262 virtual int set_complex_uint8s (mxComplexUint8 *data) = 0;
263 virtual int set_complex_uint16s (mxComplexUint16 *data) = 0;
264 virtual int set_complex_uint32s (mxComplexUint32 *data) = 0;
265 virtual int set_complex_uint64s (mxComplexUint64 *data) = 0;
270 virtual mwIndex *
get_ir (
void)
const = 0;
272 virtual mwIndex *
get_jc (
void)
const = 0;
317 return (m_interleaved
318 ? is_complex () ? 2 * size : size
324 error (
"%s: invalid type for mxArray::%s", get_class_name (), op);
344 OCTINTERP_API
mxArray (
bool interleaved, mxClassID
id, mwSize ndims,
345 const mwSize *dims, mxComplexity flag = mxREAL,
349 mxComplexity flag = mxREAL);
351 OCTINTERP_API
mxArray (
bool interleaved, mxClassID
id, mwSize
m, mwSize
n,
352 mxComplexity flag = mxREAL,
bool init =
true);
354 OCTINTERP_API
mxArray (
bool interleaved, mxClassID
id,
double val);
356 OCTINTERP_API
mxArray (
bool interleaved, mxClassID
id, mxLogical val);
358 OCTINTERP_API
mxArray (
bool interleaved,
const char *str);
360 OCTINTERP_API
mxArray (
bool interleaved, mwSize
m,
const char **str);
362 OCTINTERP_API
mxArray (
bool interleaved, mxClassID
id, mwSize
m, mwSize
n,
363 mwSize nzmax, mxComplexity flag = mxREAL);
365 OCTINTERP_API
mxArray (
bool interleaved, mwSize ndims,
const mwSize *dims,
366 int num_keys,
const char **keys);
371 OCTINTERP_API
mxArray (
bool interleaved, mwSize
m, mwSize
n,
int num_keys,
374 OCTINTERP_API
mxArray (
bool interleaved, mwSize ndims,
const mwSize *dims);
378 OCTINTERP_API
mxArray (
bool interleaved, mwSize
m, mwSize
n);
474 OCTINTERP_API
void set_name (
const char *name);
537 mxComplexInt8 * get_complex_int8s (
void)
const
540 mxComplexInt16 * get_complex_int16s (
void)
const
543 mxComplexInt32 * get_complex_int32s (
void)
const
546 mxComplexInt64 * get_complex_int64s (
void)
const
549 mxComplexUint8 * get_complex_uint8s (
void)
const
552 mxComplexUint16 * get_complex_uint16s (
void)
const
555 mxComplexUint32 * get_complex_uint32s (
void)
const
558 mxComplexUint64 * get_complex_uint64s (
void)
const
605 int set_complex_int8s (mxComplexInt8 *data)
608 int set_complex_int16s (mxComplexInt16 *data)
611 int set_complex_int32s (mxComplexInt32 *data)
614 int set_complex_int64s (mxComplexInt64 *data)
617 int set_complex_uint8s (mxComplexUint8 *data)
620 int set_complex_uint16s (mxComplexUint16 *data)
623 int set_complex_uint32s (mxComplexUint32 *data)
626 int set_complex_uint64s (mxComplexUint64 *data)
679 static OCTINTERP_API
void *
malloc (std::size_t
n);
681 static OCTINTERP_API
void *
calloc (std::size_t
n, std::size_t t);
683 static OCTINTERP_API
void *
alloc (
bool init, std::size_t
n, std::size_t t);
687 char *retval =
nullptr;
691 mwSize sz =
sizeof (mxChar) * (
strlen (str) + 1);
696 strcpy (retval, str);
716 create_rep (
bool interleaved, mxClassID
id, mwSize ndims,
717 const mwSize *dims, mxComplexity flag,
bool init);
724 create_rep (
bool interleaved, mxClassID
id, mwSize
m, mwSize
n,
725 mxComplexity flag,
bool init);
728 create_rep (
bool interleaved, mxClassID
id,
double val);
731 create_rep (
bool interleaved, mxClassID
id, mxLogical val);
734 create_rep (
bool interleaved,
const char *str);
737 create_rep (
bool interleaved, mwSize
m,
const char **str);
740 create_rep (
bool interleaved, mxClassID
id, mwSize
m, mwSize
n,
741 mwSize nzmax, mxComplexity flag);
753 #undef DO_MUTABLE_METHOD
754 #undef DO_VOID_MUTABLE_METHOD
Vector representing the dimensions (size) of an Array.
virtual int set_int8s(mxInt8 *data)=0
virtual int set_complex_singles(mxComplexSingle *data)=0
OCTAVE_NORETURN void err_invalid_type(const char *op) const
virtual int is_logical(void) const =0
virtual mxInt16 * get_int16s(void) const =0
virtual void set_n(mwSize n)=0
virtual void set_cell(mwIndex idx, mxArray *val)=0
virtual int is_int32(void) const =0
virtual int add_field(const char *key)=0
virtual mxUint8 * get_uint8s(void) const =0
virtual mxUint64 * get_uint64s(void) const =0
virtual void set_nzmax(mwSize nzmax)=0
virtual int set_uint16s(mxUint16 *data)=0
virtual int is_logical_scalar_true(void) const =0
virtual mxInt32 * get_int32s(void) const =0
virtual int is_uint16(void) const =0
virtual int set_uint64s(mxUint64 *data)=0
virtual int get_string(char *buf, mwSize buflen) const =0
virtual int is_double(void) const =0
virtual mxComplexSingle * get_complex_singles(void) const =0
virtual mwIndex calc_single_subscript(mwSize nsubs, mwIndex *subs) const =0
virtual mxArray * get_cell(mwIndex) const
virtual int set_doubles(mxDouble *data)=0
virtual mxArray * as_mxArray(void) const
virtual int set_int64s(mxInt64 *data)=0
virtual mxArray * mutate(void) const
virtual int is_numeric(void) const =0
virtual int is_function_handle(void) const =0
virtual mwSize * get_dimensions(void) const =0
virtual void * get_imag_data(void) const =0
virtual void set_imag_data(void *pi)=0
virtual mxArray * get_field_by_number(mwIndex index, int key_num) const =0
virtual int set_int16s(mxInt16 *data)=0
virtual int set_singles(mxSingle *data)=0
virtual void set_m(mwSize m)=0
virtual void set_data(void *pr)=0
virtual mwSize get_number_of_elements(void) const =0
virtual int is_logical_scalar(void) const
virtual int is_struct(void) const =0
virtual bool is_scalar(void) const =0
virtual int is_class(const char *name_arg) const
virtual int is_single(void) const =0
virtual mxInt8 * get_int8s(void) const =0
virtual const char * get_class_name(void) const =0
std::size_t get_numeric_element_size(std::size_t size) const
virtual int get_number_of_fields(void) const =0
virtual int is_sparse(void) const =0
virtual mwSize get_nzmax(void) const =0
virtual int is_int16(void) const =0
virtual void set_property(mwIndex, const char *, const mxArray *)
virtual int set_complex_doubles(mxComplexDouble *data)=0
virtual int is_char(void) const =0
virtual char * array_to_string(void) const =0
virtual mxInt64 * get_int64s(void) const =0
virtual mxSingle * get_singles(void) const =0
virtual ~mxArray_base(void)=default
virtual bool mutation_needed(void) const
virtual void * get_data(void) const =0
virtual mwSize get_m(void) const =0
virtual int is_uint32(void) const =0
virtual void set_jc(mwIndex *jc)=0
virtual mwIndex * get_ir(void) const =0
virtual bool is_octave_value(void) const
virtual int is_uint64(void) const =0
virtual int is_int64(void) const =0
virtual int set_uint32s(mxUint32 *data)=0
virtual mwSize get_number_of_dimensions(void) const =0
virtual int is_int8(void) const =0
virtual int set_uint8s(mxUint8 *data)=0
virtual int is_complex(void) const =0
virtual int set_dimensions(mwSize *dims_arg, mwSize ndims_arg)=0
virtual mxComplexDouble * get_complex_doubles(void) const =0
virtual void set_class_name(const char *name_arg)=0
virtual mxDouble * get_doubles(void) const =0
virtual mwIndex * get_jc(void) const =0
mxArray_base(const mxArray_base &)=default
virtual double get_scalar(void) const =0
virtual mwSize get_n(void) const =0
virtual int is_uint8(void) const =0
virtual int isempty(void) const =0
virtual mxArray_base * dup(void) const =0
virtual void set_ir(mwIndex *ir)=0
virtual void remove_field(int key_num)=0
virtual std::size_t get_element_size(void) const =0
virtual mxArray * get_property(mwIndex, const char *) const
virtual const char * get_field_name_by_number(int key_num) const =0
virtual mxUint32 * get_uint32s(void) const =0
virtual void set_field_by_number(mwIndex index, int key_num, mxArray *val)=0
virtual octave_value as_octave_value(void) const =0
virtual int get_field_number(const char *key) const =0
virtual mxUint16 * get_uint16s(void) const =0
virtual int set_int32s(mxInt32 *data)=0
virtual int iscell(void) const =0
virtual mxClassID get_class_id(void) const =0
mxArray & operator=(const mxArray &)=delete
mxInt64 * get_int64s(void) const
int set_uint8s(mxUint8 *data)
mxClassID get_class_id(void) const
int is_single(void) const
int set_complex_singles(mxComplexSingle *data)
OCTINTERP_API void maybe_mutate(void) const
int set_uint32s(mxUint32 *data)
void * get_imag_data(void) const
OCTINTERP_API void set_name(const char *name)
const char * get_class_name(void) const
mxInt8 * get_int8s(void) const
bool mutation_needed(void) const
int is_logical_scalar_true(void) const
int is_uint32(void) const
bool is_octave_value(void) const
OCTINTERP_API ~mxArray(void)
void set_property(mwIndex idx, const char *pname, const mxArray *pval)
int set_singles(mxSingle *data)
int set_uint16s(mxUint16 *data)
static OCTINTERP_API void * alloc(bool init, std::size_t n, std::size_t t)
mxArray * get_property(mwIndex idx, const char *pname) const
int set_uint64s(mxUint64 *data)
mxArray * dup(void) const
void * get_data(void) const
mwIndex * get_jc(void) const
mwIndex calc_single_subscript(mwSize nsubs, mwIndex *subs) const
int is_function_handle(void) const
int set_dimensions(mwSize *dims_arg, mwSize ndims_arg)
static char * strsave(const char *str)
int is_uint64(void) const
int is_struct(void) const
static OCTINTERP_API void * calloc(std::size_t n, std::size_t t)
OCTINTERP_API mxArray(bool interleaved, const octave_value &ov)
int set_complex_doubles(mxComplexDouble *data)
int get_field_number(const char *key) const
std::size_t get_element_size(void) const
mxArray(mxArray_base *r, const char *n)
mxInt32 * get_int32s(void) const
mxArray * mutate(void) const
mxArray * get_field_by_number(mwIndex index, int key_num) const
int add_field(const char *key)
int get_number_of_fields(void) const
int is_sparse(void) const
mxDouble * get_doubles(void) const
mxComplexDouble * get_complex_doubles(void) const
mxUint16 * get_uint16s(void) const
mxUint8 * get_uint8s(void) const
int is_double(void) const
mwSize get_nzmax(void) const
mwIndex * get_ir(void) const
int set_int32s(mxInt32 *data)
bool is_scalar(void) const
int set_int64s(mxInt64 *data)
int set_doubles(mxDouble *data)
void set_nzmax(mwSize nzmax)
int is_logical(void) const
double get_scalar(void) const
mwSize get_number_of_dimensions(void) const
int set_int16s(mxInt16 *data)
mxArray(const mxArray &)=delete
const char * get_name(void) const
int is_numeric(void) const
mwSize get_number_of_elements(void) const
const char * get_field_name_by_number(int key_num) const
int get_string(char *buf, mwSize buflen) const
mxUint64 * get_uint64s(void) const
int is_class(const char *name_arg) const
int set_int8s(mxInt8 *data)
void set_class_name(const char *name_arg)
int is_complex(void) const
mxUint32 * get_uint32s(void) const
int is_uint16(void) const
void set_field_by_number(mwIndex index, int key_num, mxArray *val)
void set_cell(mwIndex idx, mxArray *val)
mxArray * get_cell(mwIndex idx) const
static OCTINTERP_API mxArray_base * create_rep(bool interleaved, const octave_value &ov)
char * array_to_string(void) const
int is_logical_scalar(void) const
static OCTINTERP_API void * malloc(std::size_t n)
OCTINTERP_API octave_value as_octave_value(void) const
mwSize * get_dimensions(void) const
void set_imag_data(void *pi)
mxSingle * get_singles(void) const
mxInt16 * get_int16s(void) const
void remove_field(int key_num)
mxComplexSingle * get_complex_singles(void) const
void error(const char *fmt,...)
#define DO_VOID_MUTABLE_METHOD(METHOD_CALL)
#define DO_MUTABLE_METHOD(RET_T, METHOD_CALL)
T::size_type strlen(const typename T::value_type *str)
OCTAVE_API bool strcmp(const T &str_a, const T &str_b)
Octave string utility functions.