26 #if defined (HAVE_CONFIG_H)
43 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
44 # include <memory_resource>
79 extern OCTINTERP_API
const mxArray *
119 mxClassID class_id, mxComplexity flag);
171 mxClassID class_id, mxComplexity flag);
199 int num_keys,
const char **keys);
223 extern OCTINTERP_API mxComplexInt8 * mxGetComplexInt8s (
const mxArray *p);
224 extern OCTINTERP_API mxComplexInt16 * mxGetComplexInt16s (
const mxArray *p);
225 extern OCTINTERP_API mxComplexInt32 * mxGetComplexInt32s (
const mxArray *p);
226 extern OCTINTERP_API mxComplexInt64 * mxGetComplexInt64s (
const mxArray *p);
227 extern OCTINTERP_API mxComplexUint8 * mxGetComplexUint8s (
const mxArray *p);
228 extern OCTINTERP_API mxComplexUint16 * mxGetComplexUint16s (
const mxArray *p);
229 extern OCTINTERP_API mxComplexUint32 * mxGetComplexUint32s (
const mxArray *p);
230 extern OCTINTERP_API mxComplexUint64 * mxGetComplexUint64s (
const mxArray *p);
251 extern OCTINTERP_API
int mxSetComplexInt8s (
mxArray *p, mxComplexInt8 *
d);
252 extern OCTINTERP_API
int mxSetComplexInt16s (
mxArray *p, mxComplexInt16 *
d);
253 extern OCTINTERP_API
int mxSetComplexInt32s (
mxArray *p, mxComplexInt32 *
d);
254 extern OCTINTERP_API
int mxSetComplexInt64s (
mxArray *p, mxComplexInt64 *
d);
255 extern OCTINTERP_API
int mxSetComplexUint8s (
mxArray *p, mxComplexUint8 *
d);
256 extern OCTINTERP_API
int mxSetComplexUint16s (
mxArray *p, mxComplexUint16 *
d);
257 extern OCTINTERP_API
int mxSetComplexUint32s (
mxArray *p, mxComplexUint32 *
d);
258 extern OCTINTERP_API
int mxSetComplexUint64s (
mxArray *p, mxComplexUint64 *
d);
271 std::cerr <<
"xmalloc (" <<
n <<
") = " << ptr << std::endl;
280 void *newptr = std::realloc (ptr,
n);
283 std::cerr <<
"xrealloc (" << ptr <<
", " <<
n <<
") = " << newptr
294 std::cerr <<
"xfree (" << ptr <<
")" << std::endl;
305 for (mwSize i = 0; i <
m; i++)
307 mwSize tmp =
strlen (str[i]);
318 template <
typename T>
339 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
341 class mx_deleting_memory_resource :
public std::pmr::memory_resource
345 void * do_allocate (std::size_t bytes,
size_t )
350 throw std::bad_alloc ();
355 void do_deallocate (
void *ptr, std::size_t ,
361 bool do_is_equal (
const std::pmr::memory_resource& other)
const noexcept
363 return this ==
dynamic_cast<const mx_deleting_memory_resource *
> (&other);
367 class mx_preserving_memory_resource :
public std::pmr::memory_resource
371 void * do_allocate (std::size_t bytes,
size_t )
376 throw std::bad_alloc ();
381 void do_deallocate (
void * , std::size_t ,
385 bool do_is_equal (
const std::pmr::memory_resource& other)
const noexcept
387 return this ==
dynamic_cast<const mx_preserving_memory_resource *
> (&other);
393 static mx_deleting_memory_resource the_mx_deleting_memory_resource;
394 static mx_preserving_memory_resource the_mx_preserving_memory_resource;
396 static std::pmr::memory_resource *current_mx_memory_resource = &the_mx_deleting_memory_resource;
403 : m_interleaved (interleaved)
408 mwSize nsubs,
const mwIndex *subs)
425 mwSize
n = (nsubs <= ndims ? nsubs : ndims);
430 retval = dims[
n] * retval + subs[
n];
451 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
452 static inline void maybe_disown_ptr (
void *ptr);
455 #define VOID_MUTATION_METHOD(FCN_NAME, ARG_LIST) \
456 void FCN_NAME ARG_LIST { request_mutation (); }
458 #define CONST_VOID_MUTATION_METHOD(FCN_NAME, ARG_LIST) \
459 void FCN_NAME ARG_LIST const { request_mutation (); }
461 #define MUTATION_METHOD(RET_TYPE, FCN_NAME, ARG_LIST, RET_VAL) \
462 RET_TYPE FCN_NAME ARG_LIST { request_mutation (); return RET_VAL; }
464 #define CONST_MUTATION_METHOD(RET_TYPE, FCN_NAME, ARG_LIST, RET_VAL) \
465 RET_TYPE FCN_NAME ARG_LIST const { request_mutation (); return RET_VAL; }
467 #define GET_DATA_METHOD(RT, FCN_NAME, ID, COMPLEXITY) \
468 RT * FCN_NAME (void) const { return get_data<RT> (ID, COMPLEXITY); }
586 for (mwIndex i =
m_ndims - 1; i > 0; i--)
603 for (mwIndex i = 0; i <
m_ndims; i++)
637 m_id = mxUNKNOWN_CLASS;
642 m_id = mxDOUBLE_CLASS;
643 else if (cn ==
"single")
644 m_id = mxSINGLE_CLASS;
645 else if (cn ==
"char")
647 else if (cn ==
"logical")
648 m_id = mxLOGICAL_CLASS;
649 else if (cn ==
"cell")
651 else if (cn ==
"struct")
652 m_id = mxSTRUCT_CLASS;
653 else if (cn ==
"function_handle")
654 m_id = mxFUNCTION_CLASS;
655 else if (cn ==
"int8")
657 else if (cn ==
"uint8")
658 m_id = mxUINT8_CLASS;
659 else if (cn ==
"int16")
660 m_id = mxINT16_CLASS;
661 else if (cn ==
"uint16")
662 m_id = mxUINT16_CLASS;
663 else if (cn ==
"int32")
664 m_id = mxINT32_CLASS;
665 else if (cn ==
"uint32")
666 m_id = mxUINT32_CLASS;
667 else if (cn ==
"int64")
668 m_id = mxINT64_CLASS;
669 else if (cn ==
"uint64")
670 m_id = mxUINT64_CLASS;
733 if (m_data ==
nullptr)
737 return *
static_cast<const bool *
> (m_data);
739 return *
static_cast<const double *
> (m_data);
741 return *
static_cast<const double *
> (m_data);
763 template <
typename T>
764 T *
get_data (mxClassID class_id, mxComplexity complexity)
const
770 T *retval =
static_cast<T *
> (ptr);
803 mxDOUBLE_CLASS, mxCOMPLEX);
806 mxDOUBLE_CLASS, mxCOMPLEX);
812 GET_DATA_METHOD (mxComplexInt16 *, get_complex_int16s, (
void),
nullptr);
814 GET_DATA_METHOD (mxComplexInt32 *, get_complex_int32s, (
void),
nullptr);
816 GET_DATA_METHOD (mxComplexInt64 *, get_complex_int64s, (
void),
nullptr);
818 GET_DATA_METHOD (mxComplexUint8 *, get_complex_uint8s, (
void),
nullptr);
820 GET_DATA_METHOD (mxComplexUint16 *, get_complex_uint16s, (
void),
nullptr);
822 GET_DATA_METHOD (mxComplexUint32 *, get_complex_uint32s, (
void),
nullptr);
824 GET_DATA_METHOD (mxComplexUint64 *, get_complex_uint64s, (
void),
nullptr);
829 void *retval =
nullptr;
924 const char *p = tmp.
data ();
926 for (mwIndex i = 0; i < nel; i++)
953 const char *p = tmp.
data ();
955 for (mwIndex i = 0; i < nel; i++)
980 case mxCELL_CLASS:
return sizeof (
mxArray *);
981 case mxSTRUCT_CLASS:
return sizeof (
mxArray *);
982 case mxLOGICAL_CLASS:
return sizeof (mxLogical);
983 case mxCHAR_CLASS:
return sizeof (mxChar);
994 case mxFUNCTION_CLASS:
return 0;
1027 for (mwIndex i = 0; i <
m_ndims; i++)
1089 return (
m_id == mxDOUBLE_CLASS ||
m_id == mxSINGLE_CLASS
1090 ||
m_id == mxINT8_CLASS ||
m_id == mxUINT8_CLASS
1091 ||
m_id == mxINT16_CLASS ||
m_id == mxUINT16_CLASS
1092 ||
m_id == mxINT32_CLASS ||
m_id == mxUINT32_CLASS
1093 ||
m_id == mxINT64_CLASS ||
m_id == mxUINT64_CLASS);
1113 &&
static_cast<mxLogical *
> (
get_data ())[0] != 0);
1122 for (mwSize i =
m_ndims - 1 ; i > 0 ; i--)
1150 for (
int i = 0; i <
m_ndims; i++)
1164 mwSize retval =
m_dims[0];
1166 for (mwIndex i = 1; i <
m_ndims; i++)
1185 case mxDOUBLE_CLASS:
return "double";
1186 case mxSINGLE_CLASS:
return "single";
1187 case mxCHAR_CLASS:
return "char";
1188 case mxLOGICAL_CLASS:
return "logical";
1189 case mxCELL_CLASS:
return "cell";
1190 case mxSTRUCT_CLASS:
return "struct";
1191 case mxFUNCTION_CLASS:
return "function_handle";
1192 case mxINT8_CLASS:
return "int8";
1193 case mxUINT8_CLASS:
return "uint8";
1194 case mxINT16_CLASS:
return "int16";
1195 case mxUINT16_CLASS:
return "uint16";
1196 case mxINT32_CLASS:
return "int32";
1197 case mxUINT32_CLASS:
return "uint32";
1198 case mxINT64_CLASS:
return "int64";
1199 case mxUINT64_CLASS:
return "uint64";
1200 case mxUNKNOWN_CLASS:
return "unknown";
1202 default:
return "unknown";
1295 mxComplexInt8 * get_complex_int8s (
void)
const
1300 mxComplexInt16 * get_complex_int16s (
void)
const
1305 mxComplexInt32 * get_complex_int32s (
void)
const
1310 mxComplexInt64 * get_complex_int64s (
void)
const
1315 mxComplexUint8 * get_complex_uint8s (
void)
const
1320 mxComplexUint16 * get_complex_uint16s (
void)
const
1325 mxComplexUint32 * get_complex_uint32s (
void)
const
1330 mxComplexUint64 * get_complex_uint64s (
void)
const
1408 int set_complex_int8s (mxComplexInt8 *)
1413 int set_complex_int16s (mxComplexInt16 *)
1418 int set_complex_int32s (mxComplexInt32 *)
1423 int set_complex_int64s (mxComplexInt64 *)
1428 int set_complex_uint8s (mxComplexUint8 *)
1433 int set_complex_uint16s (mxComplexUint16 *)
1438 int set_complex_uint32s (mxComplexUint32 *)
1443 int set_complex_uint64s (mxComplexUint64 *)
1539 case mxCELL_CLASS:
return sizeof (
mxArray *);
1540 case mxSTRUCT_CLASS:
return sizeof (
mxArray *);
1541 case mxLOGICAL_CLASS:
return sizeof (mxLogical);
1542 case mxCHAR_CLASS:
return sizeof (mxChar);
1553 case mxFUNCTION_CLASS:
return 0;
1570 m_ndims (ndims < 2 ? 2 : ndims),
1584 for (mwIndex i = 0; i < ndims; i++)
1587 for (mwIndex i =
m_ndims - 1; i > 1; i--)
1601 for (mwIndex i = 0; i <
m_ndims; i++)
1604 for (mwIndex i =
m_ndims - 1; i > 1; i--)
1627 for (mwIndex i = 0; i <
m_ndims; i++)
1641 for (mwIndex i = 0; i < nd; i++)
1665 const mwSize *dims,
bool init =
true)
1685 double *dpr =
static_cast<double *
> (
m_pr);
1693 mxLogical *lpr =
static_cast<mxLogical *
> (
m_pr);
1699 str ? (
strlen (str) ? 1 : 0) : 0,
1703 mxChar *cpr =
static_cast<mxChar *
> (
m_pr);
1705 for (mwIndex i = 0; i < nel; i++)
1714 mxChar *cpr =
static_cast<mxChar *
> (
m_pr);
1720 for (mwIndex j = 0; j <
m; j++)
1722 const char *ptr = str[j];
1724 std::size_t tmp_len =
strlen (ptr);
1726 for (std::size_t i = 0; i < tmp_len; i++)
1727 cpr[
m*i+j] =
static_cast<mxChar
> (ptr[i]);
1729 for (std::size_t i = tmp_len; i < static_cast<std::size_t> (nc); i++)
1730 cpr[
m*i+j] =
static_cast<mxChar
> (
' ');
1757 case mxDOUBLE_CLASS:
1758 retval = *(
static_cast<double *
> (
m_pr));
1761 case mxSINGLE_CLASS:
1762 retval = *(
static_cast<float *
> (
m_pr));
1766 retval = *(
static_cast<mxChar *
> (
m_pr));
1769 case mxLOGICAL_CLASS:
1770 retval = *(
static_cast<bool *
> (
m_pr));
1774 retval = *(
static_cast<int8_t *
> (
m_pr));
1778 retval = *(
static_cast<uint8_t *
> (
m_pr));
1782 retval = *(
static_cast<int16_t *
> (
m_pr));
1785 case mxUINT16_CLASS:
1786 retval = *(
static_cast<uint16_t *
> (
m_pr));
1790 retval = *(
static_cast<int32_t *
> (
m_pr));
1793 case mxUINT32_CLASS:
1794 retval = *(
static_cast<uint32_t *
> (
m_pr));
1798 retval = *(
static_cast<int64_t *
> (
m_pr));
1801 case mxUINT64_CLASS:
1802 retval = *(
static_cast<uint64_t *
> (
m_pr));
1823 return static_cast<mxDouble *
> (
m_pr);
1828 return static_cast<mxSingle *
> (
m_pr);
1833 return static_cast<mxInt8 *
> (
m_pr);
1838 return static_cast<mxInt16 *
> (
m_pr);
1843 return static_cast<mxInt32 *
> (
m_pr);
1848 return static_cast<mxInt64 *
> (
m_pr);
1853 return static_cast<mxUint8 *
> (
m_pr);
1858 return static_cast<mxUint16 *
> (
m_pr);
1863 return static_cast<mxUint32 *
> (
m_pr);
1868 return static_cast<mxUint64 *
> (
m_pr);
1873 return static_cast<mxComplexDouble *
> (
m_pr);
1878 return static_cast<mxComplexSingle *
> (
m_pr);
1884 int get_complex_int8s (mxComplexInt8 *
d)
1890 int get_complex_int16s (mxComplexInt16 *
d)
1896 int get_complex_int32s (mxComplexInt32 *
d)
1902 int get_complex_int64s (mxComplexInt64 *
d)
1908 int get_complex_uint8s (mxComplexUint8 *
d)
1914 int get_complex_uint16s (mxComplexUint16 *
d)
1920 int get_complex_uint32s (mxComplexUint32 *
d)
1926 int get_complex_uint64s (mxComplexUint64 *
d)
2008 int set_complex_int8s (mxComplexInt8 *
d)
2014 int set_complex_int16s (mxComplexInt16 *
d)
2020 int set_complex_int32s (mxComplexInt32 *
d)
2026 int set_complex_int64s (mxComplexInt64 *
d)
2032 int set_complex_uint8s (mxComplexUint8 *
d)
2038 int set_complex_uint16s (mxComplexUint16 *
d)
2044 int set_complex_uint32s (mxComplexUint32 *
d)
2050 int set_complex_uint64s (mxComplexUint64 *
d)
2063 if (! (nel < buflen))
2072 mxChar *ptr =
static_cast<mxChar *
> (
m_pr);
2074 for (mwIndex i = 0; i < nel; i++)
2075 buf[i] =
static_cast<char> (ptr[i]);
2093 mxChar *ptr =
static_cast<mxChar *
> (
m_pr);
2095 for (mwIndex i = 0; i < nel; i++)
2096 buf[i] =
static_cast<char> (ptr[i]);
2112 case mxDOUBLE_CLASS:
2114 ? fp_to_ov<Complex> (dv) : fp_to_ov<double> (dv));
2116 case mxSINGLE_CLASS:
2118 ? fp_to_ov<FloatComplex> (dv) : fp_to_ov<float> (dv));
2121 return int_to_ov<mxChar, charNDArray, char> (dv);
2123 case mxLOGICAL_CLASS:
2124 return int_to_ov<mxLogical, boolNDArray, bool> (dv);
2127 return int_to_ov<int8_t, int8NDArray, octave_int8> (dv);
2130 return int_to_ov<uint8_t, uint8NDArray, octave_uint8> (dv);
2133 return int_to_ov<int16_t, int16NDArray, octave_int16> (dv);
2135 case mxUINT16_CLASS:
2136 return int_to_ov<uint16_t, uint16NDArray, octave_uint16> (dv);
2139 return int_to_ov<int32_t, int32NDArray, octave_int32> (dv);
2141 case mxUINT32_CLASS:
2142 return int_to_ov<uint32_t, uint32NDArray, octave_uint32> (dv);
2145 return int_to_ov<int64_t, int64NDArray, octave_int64> (dv);
2147 case mxUINT64_CLASS:
2148 return int_to_ov<uint64_t, uint64NDArray, octave_uint64> (dv);
2167 template <
typename ELT_T>
2173 ELT_T *ppr =
static_cast<ELT_T *
> (
m_pr);
2175 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
2177 if (current_mx_memory_resource == &the_mx_deleting_memory_resource)
2179 octave::unwind_action act ([=] () { maybe_disown_ptr (
m_pr); });
2197 for (mwIndex i = 0; i < nel; i++)
2205 template <
typename ELT_T,
typename ARRAY_T,
typename ARRAY_ELT_T>
2210 error (
"complex integer types are not supported");
2212 ELT_T *ppr =
static_cast<ELT_T *
> (
m_pr);
2214 #if 0 && defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
2219 octave::unwind_action act ([=] () { maybe_disown_ptr (
m_pr); });
2221 return ARRAY_T (ppr, dv, current_mx_memory_resource);
2230 ARRAY_ELT_T *ptr = val.fortran_vec ();
2234 for (mwIndex i = 0; i < nel; i++)
2255 mxComplexity flag = mxREAL,
bool init =
true)
2261 mxComplexity flag = mxREAL)
2267 mxComplexity flag = mxREAL,
bool init =
true)
2322 mxComplexity flag = mxREAL,
bool init =
true)
2324 m_pi (flag == mxCOMPLEX
2330 mxComplexity flag = mxREAL)
2332 m_pi (flag == mxCOMPLEX
2338 mxComplexity flag = mxREAL,
bool init =
true)
2340 m_pi (flag == mxCOMPLEX
2444 case mxDOUBLE_CLASS:
2445 return to_ov<double> (dv);
2447 case mxSINGLE_CLASS:
2448 return to_ov<float> (dv);
2450 case mxLOGICAL_CLASS:
2454 case mxUINT16_CLASS:
2456 case mxUINT32_CLASS:
2458 case mxUINT64_CLASS:
2459 error (
"complex integer types are not supported");
2482 template <
typename T>
2488 T *ppr =
static_cast<T *
> (
m_pr);
2497 T *ppi =
static_cast<T *
> (
m_pi);
2499 for (mwIndex i = 0; i < nel; i++)
2500 ptr[i] = std::complex<T> (ppr[i], ppi[i]);
2519 m_nzmax (nzmax > 0 ? nzmax : 1),
2521 m_jc (static_cast<mwIndex *> (
mxArray::calloc (
n + 1, sizeof (mwIndex)))),
2537 memcpy (
m_jc, val.
m_jc, (val.
get_n () + 1) * sizeof (mwIndex));
2570 return static_cast<mxDouble *
> (
m_pr);
2575 return static_cast<mxComplexDouble *
> (
m_pr);
2603 m_nzmax = (nzmax > 0 ? nzmax : 1);
2614 case mxDOUBLE_CLASS:
2615 return is_complex () ? to_ov<Complex> (dv): to_ov<double> (dv);
2617 case mxSINGLE_CLASS:
2618 error (
"single precision sparse data type not supported");
2620 case mxLOGICAL_CLASS:
2621 return to_ov<bool> (dv);
2632 template <
typename ELT_T>
2636 ELT_T *ppr =
static_cast<ELT_T *
> (
m_pr);
2638 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
2640 if (current_mx_memory_resource == &the_mx_deleting_memory_resource)
2642 octave::unwind_action act ([=] ()
2644 maybe_disown_ptr (
m_pr);
2645 maybe_disown_ptr (
m_ir);
2646 maybe_disown_ptr (
m_jc);
2651 ppr,
m_ir,
m_jc, current_mx_memory_resource));
2656 ppr,
m_ir,
m_jc, current_mx_memory_resource));
2667 for (mwIndex i = 0; i <
m_nzmax; i++)
2669 val.
xdata (i) = ppr[i];
2673 for (mwIndex i = 0; i <
n + 1; i++)
2699 mxComplexity flag = mxREAL)
2742 mxComplexity flag = mxREAL)
2744 m_pi (flag == mxCOMPLEX
2780 return m_pi !=
nullptr;
2804 case mxDOUBLE_CLASS:
2806 double *ppr =
static_cast<double *
> (
m_pr);
2807 double *ppi =
static_cast<double *
> (
m_pi);
2812 for (mwIndex i = 0; i <
m_nzmax; i++)
2818 for (mwIndex i = 0; i <
get_n () + 1; i++)
2825 case mxSINGLE_CLASS:
2826 error (
"single precision sparse data type not supported");
2848 int num_keys,
const char **keys)
2891 * sizeof (char *)))),
2901 for (mwIndex i = 0; i < nel *
m_nfields; i++)
2904 m_data[i] = (ptr ? ptr->
dup () :
nullptr);
2932 for (mwIndex i = 0; i < ntot; i++)
2956 new_data =
static_cast<mxArray **
>
2965 for (mwIndex i = 0; i < ntot; i++)
2969 new_data[j++] =
nullptr;
2973 new_data[j++] =
m_data[k++];
2989 if (key_num >= 0 && key_num <
m_nfields)
2997 char **new_fields =
static_cast<char **
>
3004 for (
int i = 0; i < key_num; i++)
3007 for (
int i = key_num + 1; i <
m_nfields; i++)
3010 if (new_nfields > 0)
3016 for (mwIndex i = 0; i < ntot; i++)
3021 new_data[j++] =
m_data[k++];
3040 return key_num >= 0 && key_num <
m_nfields
3090 for (mwIndex j = i; j < ntot; j +=
m_nfields)
3093 m.assign (keys[i], c);
3141 for (mwIndex i = 0; i < nel; i++)
3144 m_data[i] = (ptr ? ptr->
dup () :
nullptr);
3161 for (mwIndex i = 0; i < nel; i++)
3188 for (mwIndex i = 0; i < nel; i++)
3202 : m_rep (create_rep (interleaved, ov)), m_name (nullptr)
3206 const mwSize *dims, mxComplexity flag,
bool init)
3207 : m_rep (create_rep (interleaved, id, ndims, dims, flag, init)),
3213 : m_rep (create_rep (interleaved, id, dv, flag)), m_name (nullptr)
3217 mxComplexity flag,
bool init)
3218 : m_rep (create_rep (interleaved, id,
m,
n, flag, init)), m_name (nullptr)
3222 : m_rep (create_rep (interleaved, id, val)), m_name (nullptr)
3226 : m_rep (create_rep (interleaved, id, val)), m_name (nullptr)
3230 : m_rep (create_rep (interleaved, str)), m_name (nullptr)
3234 : m_rep (create_rep (interleaved,
m, str)), m_name (nullptr)
3238 mwSize nzmax, mxComplexity flag)
3239 : m_rep (create_rep (interleaved, id,
m,
n, nzmax, flag)), m_name (nullptr)
3245 : m_rep (new
mxArray_struct (interleaved, ndims, dims, num_keys, keys)),
3262 : m_rep (new
mxArray_cell (interleaved, ndims, dims)), m_name (nullptr)
3266 : m_rep (new
mxArray_cell (interleaved, dv)), m_name (nullptr)
3311 const mwSize *dims, mxComplexity flag,
bool init)
3331 mxComplexity flag,
bool init)
3377 mwSize nzmax, mxComplexity flag)
3400 new_val->
m_rep =
nullptr;
3458 std::string nm = fcn->
name ();
3476 error (
"%s: failed to allocate %zd bytes of memory",
3500 memset (ptr, 0,
n*t);
3573 warning (
"mxFree: skipping memory not allocated by mxMalloc, mxCalloc, or mxRealloc");
3655 bool inlist =
false;
3667 warning (
"mex::free_value: skipping memory not allocated by mex::make_value");
3752 static inline void *
3761 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
3764 maybe_disown_ptr (
void *ptr)
3785 template <
typename T>
3798 if (key_num >= 0 && key_num <
m_nfields)
3836 return std::numeric_limits<double>::epsilon ();
3997 mxClassID class_id, mxComplexity flag)
4004 mxClassID class_id, mxComplexity flag)
4025 mxClassID class_id, mxComplexity flag)
4033 mxClassID class_id, mxComplexity flag)
4041 mxClassID class_id, mxComplexity flag)
4093 int num_keys,
const char **keys)
4290 return ptr->
get_m ();
4296 return ptr->
get_n ();
4342 return static_cast<double *
> (ptr->
get_data ());
4355 return static_cast<mxChar *
> (ptr->
get_data ());
4363 return static_cast<mxLogical *
> (ptr->
get_data ());
4446 mxComplexInt8 * mxGetComplexInt8s (
const mxArray *ptr)
4448 return ptr->get_complex_int8s ();
4451 mxComplexInt16 * mxGetComplexInt16s (
const mxArray *ptr)
4453 return ptr->get_complex_int16s ();
4456 mxComplexInt32 * mxGetComplexInt32s (
const mxArray *ptr)
4458 return ptr->get_complex_int32s ();
4461 mxComplexInt64 * mxGetComplexInt64s (
const mxArray *ptr)
4463 return ptr->get_complex_int64s ();
4466 mxComplexUint8 * mxGetComplexUint8s (
const mxArray *ptr)
4468 return ptr->get_complex_uint8s ();
4471 mxComplexUint16 * mxGetComplexUint16s (
const mxArray *ptr)
4473 return ptr->get_complex_uint16s ();
4476 mxComplexUint32 * mxGetComplexUint32s (
const mxArray *ptr)
4478 return ptr->get_complex_uint32s ();
4481 mxComplexUint64 * mxGetComplexUint64s (
const mxArray *ptr)
4483 return ptr->get_complex_uint64s ();
4562 int mxSetComplexInt8s (
mxArray *ptr, mxComplexInt8 *data)
4567 int mxSetComplexInt16s (
mxArray *ptr, mxComplexInt16 *data)
4572 int mxSetComplexInt32s (
mxArray *ptr, mxComplexInt32 *data)
4577 int mxSetComplexInt64s (
mxArray *ptr, mxComplexInt64 *data)
4582 int mxSetComplexUint8s (
mxArray *ptr, mxComplexUint8 *data)
4587 int mxSetComplexUint16s (
mxArray *ptr, mxComplexUint16 *data)
4592 int mxSetComplexUint32s (
mxArray *ptr, mxComplexUint32 *data)
4597 int mxSetComplexUint64s (
mxArray *ptr, mxComplexUint64 *data)
4636 const mxArray *property_value)
4638 ptr->
set_property (idx, property_name, property_value);
4795 volatile int nargout = nargout_arg;
4797 int nargin = args.
length ();
4799 for (
int i = 0; i < nargin; i++)
4802 int nout = (nargout == 0 ? 1 : nargout);
4804 for (
int i = 0; i < nout; i++)
4805 argout[i] =
nullptr;
4808 octave::unwind_protect_var<mex *> restore_var (
mex_context);
4810 mex context (mex_fcn);
4812 for (
int i = 0; i < nargin; i++)
4823 F77_INT tmp_nargout = nargout;
4826 fcn (tmp_nargout, argout, tmp_nargin, argin);
4832 fcn (nargout, argout, nargin, argin);
4839 if (nargout == 0 && argout[0])
4851 for (
int i = 0; i < nargout; i++)
4878 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
4885 octave::unwind_protect_var<std::pmr::memory_resource *>
4886 upv (current_mx_memory_resource, &the_mx_preserving_memory_resource);
4890 for (
int i = 0; i < nargin; i++)
4898 mxArray *argin[],
const char *fname)
4904 bool execution_error =
false;
4910 octave::tree_evaluator& tw = interp.get_evaluator ();
4912 octave::unwind_action act
4913 ([&tw] (
const std::list<octave::octave_lvalue> *lvl)
4915 tw.set_lvalue_list (lvl);
4916 }, tw.lvalue_list ());
4918 tw.set_lvalue_list (
nullptr);
4922 catch (
const octave::execution_exception&)
4930 interp.recover_from_exception ();
4932 execution_error =
true;
4943 int num_to_copy = retval.
length ();
4945 if (nargout < retval.
length ())
4946 num_to_copy = nargout;
4948 for (
int i = 0; i < num_to_copy; i++)
4957 while (num_to_copy < nargout)
4958 argout[num_to_copy++] =
nullptr;
4960 return execution_error ? 1 : 0;
4965 mxArray *argin[],
const char *fname)
4973 const char *field_names[] = {
"identifier",
"message",
"case",
"stack"};
4976 std::string msg =
"mexCallMATLABWithTrap: function call <"
4977 + std::string (fname) +
"> failed";
5002 bool execution_error =
false;
5008 ret = interp.eval_string (std::string (s),
false, parse_status, 0);
5010 catch (
const octave::execution_exception&)
5012 interp.recover_from_exception ();
5014 execution_error =
true;
5017 if (parse_status || execution_error)
5031 bool execution_error =
false;
5037 ret = interp.eval_string (std::string (s),
false, parse_status, 0);
5039 catch (
const octave::execution_exception&)
5041 interp.recover_from_exception ();
5043 execution_error =
true;
5046 if (parse_status || execution_error)
5048 const char *field_names[] = {
"identifier",
"message",
"case",
"stack"};
5051 std::string msg =
"mexEvalStringWithTrap: eval of <"
5052 + std::string (s) +
"> failed";
5068 if (s[
len - 1] ==
'\n')
5070 std::string s_tmp (s,
len - 1);
5087 if (fmt &&
strlen (fmt) > 0)
5092 sprintf (tmpfmt,
"%s: %s", fname, fmt);
5094 va_start (args, fmt);
5113 if (s[
len - 1] ==
'\n')
5115 std::string s_tmp (s,
len - 1);
5116 warning (
"%s\n", s_tmp.c_str ());
5135 if (fmt &&
strlen (fmt) > 0)
5140 sprintf (tmpfmt,
"%s: %s", fname, fmt);
5142 va_start (args, fmt);
5153 va_start (args, fmt);
5168 if (!
strcmp (space,
"global"))
5169 val = interp.global_varval (name);
5174 octave::unwind_protect frame;
5176 bool caller = !
strcmp (space,
"caller");
5177 bool base = !
strcmp (space,
"base");
5186 octave::tree_evaluator& tw = interp.get_evaluator ();
5188 frame.add (&octave::tree_evaluator::restore_frame, &tw,
5189 tw.current_call_stack_frame_number ());
5191 tw.goto_base_frame ();
5194 val = interp.varval (name);
5197 mexErrMsgTxt (
"mexGetVariable: symbol table does not exist");
5225 if (name[0] ==
'\0')
5228 if (! name || name[0] ==
'\0')
5233 if (!
strcmp (space,
"global"))
5235 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
5242 octave::unwind_protect_var<std::pmr::memory_resource *>
5243 upv (current_mx_memory_resource, &the_mx_preserving_memory_resource);
5252 octave::unwind_protect frame;
5254 bool caller = !
strcmp (space,
"caller");
5255 bool base = !
strcmp (space,
"base");
5264 octave::tree_evaluator& tw = interp.get_evaluator ();
5266 frame.add (&octave::tree_evaluator::restore_frame, &tw,
5267 tw.current_call_stack_frame_number ());
5269 tw.goto_base_frame ();
5272 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
5279 octave::unwind_protect_var<std::pmr::memory_resource *>
5280 upv (current_mx_memory_resource,
5281 &the_mx_preserving_memory_resource);
5287 mexErrMsgTxt (
"mexPutVariable: symbol table does not exist");
5363 retval = interp.mislocked (fname);
5392 #if defined (OCTAVE_HAVE_STD_PMR_POLYMORPHIC_ALLOCATOR)
5399 octave::unwind_protect_var<std::pmr::memory_resource *>
5400 upv (current_mx_memory_resource, &the_mx_preserving_memory_resource);
5407 return (ret ? 0 : 1);
5427 interp.munlock (fname);
N Dimensional Array with copy-on-write semantics.
OCTARRAY_OVERRIDABLE_FUNC_API const T * data(void) const
Size of the specified dimension.
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
octave_idx_type * xcidx(void)
octave_idx_type * xridx(void)
Vector representing the dimensions (size) of an Array.
void resize(int n, int fill_value=0)
static const bool is_complex
mxArray * make_value(const octave_value &ov)
mex & operator=(const mex &)=delete
std::set< void * > m_foreign_memlist
const char * function_name(void) const
void * calloc(std::size_t n, std::size_t t)
mex(octave_mex_function &f)
void unmark_array(mxArray *ptr)
octave_mex_function & m_curr_mex_fcn
void * calloc_unmarked(std::size_t n, std::size_t t)
static std::set< void * > s_global_memlist
void * malloc(std::size_t n)
void * realloc(void *ptr, std::size_t n)
void * malloc_unmarked(std::size_t n)
void global_unmark(void *ptr)
bool free_value(mxArray *ptr)
std::set< mxArray * > m_arraylist
octave_mex_function & current_mex_function(void) const
void global_mark(void *ptr)
std::set< void * > m_memlist
void mark_foreign(void *ptr)
mxArray * mark_array(mxArray *ptr)
void unmark_foreign(void *ptr)
int set_complex_doubles(mxComplexDouble *d)
mxSingle * get_singles(void) const
mxInt16 * get_int16s(void) const
int set_uint16s(mxUint16 *d)
mxArray_base * dup(void) const
mxComplexSingle * get_complex_singles(void) const
mxArray_base_full(bool interleaved, mxClassID id, mwSize m, mwSize n, bool init=true)
mxArray_base_full(bool interleaved, mwSize m, const char **str)
int set_doubles(mxDouble *d)
int set_int32s(mxInt32 *d)
mxArray_base_full(bool interleaved, const char *str)
mxInt64 * get_int64s(void) const
int set_complex_singles(mxComplexSingle *d)
mxComplexDouble * get_complex_doubles(void) const
mxUint8 * get_uint8s(void) const
int set_uint64s(mxUint64 *d)
char * array_to_string(void) const
mxUint16 * get_uint16s(void) const
int set_uint32s(mxUint32 *d)
mxInt32 * get_int32s(void) const
int set_int16s(mxInt16 *d)
mxArray_base_full(bool interleaved, mxClassID id, mxLogical val)
void * get_data(void) const
octave_value fp_to_ov(const dim_vector &dv) const
mxArray_base_full(bool interleaved, mxClassID id, double val)
mxArray_base_full & operator=(const mxArray_base_full &)
octave_value as_octave_value(void) const
int set_int64s(mxInt64 *d)
mxUint64 * get_uint64s(void) const
int set_uint8s(mxUint8 *d)
int set_singles(mxSingle *d)
mxDouble * get_doubles(void) const
mxUint32 * get_uint32s(void) const
octave_value int_to_ov(const dim_vector &dv) const
double get_scalar(void) const
mxArray_base_full(const mxArray_base_full &val)
mxArray_base_full(bool interleaved, mxClassID id, const dim_vector &dv)
int get_string(char *buf, mwSize buflen) const
mxArray_base_full(bool interleaved, mxClassID id, mwSize ndims, const mwSize *dims, bool init=true)
mxInt8 * get_int8s(void) const
mxArray_base_sparse & operator=(const mxArray_base_sparse &)
octave_value to_ov(const dim_vector &dv) const
int set_complex_doubles(mxComplexDouble *d)
mxDouble * get_doubles(void) const
int set_doubles(mxDouble *d)
void set_nzmax(mwSize nzmax)
mwSize get_nzmax(void) const
mxArray_base_sparse(const mxArray_base_sparse &val)
mxComplexDouble * get_complex_doubles(void) const
int is_sparse(void) const
mxArray_base * dup(void) const
~mxArray_base_sparse(void)
void * get_data(void) const
mxArray_base_sparse(bool interleaved, mxClassID id, mwSize m, mwSize n, mwSize nzmax)
mwIndex * get_jc(void) const
mwIndex * get_ir(void) const
octave_value as_octave_value(void) const
OCTAVE_NORETURN void err_invalid_type(const char *op) const
OCTINTERP_API mxArray_base(bool interleaved)
virtual mxArray * mutate(void) const
virtual int is_logical_scalar(void) const
std::size_t get_numeric_element_size(std::size_t size) const
virtual bool is_octave_value(void) const
virtual octave_value as_octave_value(void) const =0
mxArray_cell & operator=(const mxArray_cell &)
mxArray_cell(bool interleaved, mwSize m, mwSize n)
mxArray_cell(const mxArray_cell &val)
void * get_data(void) const
void set_data(void *data)
void set_cell(mwIndex idx, mxArray *val)
mxArray_base * dup(void) const
mxArray_cell(bool interleaved, mwSize ndims, const mwSize *dims)
octave_value as_octave_value(void) const
mxArray * get_cell(mwIndex idx) const
mxArray_cell(bool interleaved, const dim_vector &dv)
mxArray_interleaved_full(const char *str)
mxArray_interleaved_full(mxClassID id, mxLogical val)
mxArray_base * dup(void) const
mxArray_interleaved_full(mxClassID id, mwSize m, mwSize n, mxComplexity flag=mxREAL, bool init=true)
int is_complex(void) const
void * get_imag_data(void) const
mxArray_interleaved_full(const mxArray_interleaved_full &val)
mxArray_interleaved_full(mxClassID id, double val)
mxArray_interleaved_full(mwSize m, const char **str)
mxArray_interleaved_full(mxClassID id, mwSize ndims, const mwSize *dims, mxComplexity flag=mxREAL, bool init=true)
~mxArray_interleaved_full(void)=default
mxArray_interleaved_full & operator=(const mxArray_interleaved_full &)
void set_imag_data(void *)
mxArray_interleaved_full(mxClassID id, const dim_vector &dv, mxComplexity flag=mxREAL)
void * get_imag_data(void) const
mxArray_base * dup(void) const
mxArray_interleaved_sparse(const mxArray_interleaved_sparse &val)
int is_complex(void) const
mxArray_interleaved_sparse & operator=(const mxArray_interleaved_sparse &)
mxArray_interleaved_sparse(mxClassID id, mwSize m, mwSize n, mwSize nzmax, mxComplexity flag=mxREAL)
void set_imag_data(void *)
~mxArray_interleaved_sparse(void)=default
void set_cell(mwIndex, mxArray *)
mxArray * get_field_by_number(mwIndex, int) const
void set_field_by_number(mwIndex, int, mxArray *)
int set_complex_singles(mxComplexSingle *)
int set_doubles(mxDouble *)
mxArray_matlab & operator=(const mxArray_matlab &)
int add_field(const char *)
int set_uint16s(mxUint16 *)
mxClassID get_class_id(void) const
bool is_scalar(void) const
mxComplexDouble * get_complex_doubles(void) const
mxUint64 * get_uint64s(void) const
void * get_imag_data(void) const
mwIndex * get_ir(void) const
mxSingle * get_singles(void) const
int set_dimensions(mwSize *dims, mwSize ndims)
int set_int64s(mxInt64 *)
int get_number_of_fields(void) const
mwIndex calc_single_subscript(mwSize nsubs, mwIndex *subs) const
mwIndex * get_jc(void) const
int is_numeric(void) const
mxArray_matlab(const mxArray_matlab &val)
int set_uint64s(mxUint64 *)
void * get_data(void) const
mxInt8 * get_int8s(void) const
mxDouble * get_doubles(void) const
int is_complex(void) const
mxUint32 * get_uint32s(void) const
char * array_to_string(void) const
mxArray_matlab(bool interleaved, mxClassID id=mxUNKNOWN_CLASS)
int is_logical_scalar_true(void) const
const char * get_field_name_by_number(int) const
int is_double(void) const
int is_logical(void) const
int is_struct(void) const
mwSize * get_dimensions(void) const
int get_field_number(const char *) const
mxInt64 * get_int64s(void) const
mxInt32 * get_int32s(void) const
int is_function_handle(void) const
mxArray_matlab(bool interleaved, mxClassID id, const dim_vector &dv)
int set_int16s(mxInt16 *)
mxArray_matlab(bool interleaved, mxClassID id, mwSize ndims, const mwSize *dims)
int is_uint32(void) const
int is_single(void) const
void set_class_name(const char *name)
mxArray * get_cell(mwIndex) const
mwSize get_number_of_dimensions(void) const
int set_uint32s(mxUint32 *)
mwSize get_nzmax(void) const
mxInt16 * get_int16s(void) const
double get_scalar(void) const
int is_sparse(void) const
mxArray_matlab(bool interleaved, mxClassID id, mwSize m, mwSize n)
mxUint8 * get_uint8s(void) const
int is_uint64(void) const
const char * get_class_name(void) const
int set_singles(mxSingle *)
void set_imag_data(void *)
int get_string(char *, mwSize) const
mxComplexSingle * get_complex_singles(void) const
std::size_t get_element_size(void) const
int set_complex_doubles(mxComplexDouble *)
mxUint16 * get_uint16s(void) const
int is_uint16(void) const
int set_int32s(mxInt32 *)
dim_vector dims_to_dim_vector(void) const
mwSize get_number_of_elements(void) const
int set_uint8s(mxUint8 *)
int is_sparse(void) const
int set_uint16s(mxUint16 *)
bool mutation_needed(void) const
int set_dimensions(mwSize *, mwSize)
mxClassID get_class_id(void) const
int is_uint16(void) const
mxUint64 * get_uint64s(void) const
const char * get_class_name(void) const
int add_field(const char *)
void * get_data(void) const
octave_value as_octave_value(void) const
mwSize get_number_of_elements(void) const
mxSingle * get_singles(void) const
int set_doubles(mxDouble *)
void set_cell(mwIndex, mxArray *)
int set_singles(mxSingle *)
int set_uint32s(mxUint32 *)
int is_logical(void) const
~mxArray_octave_value(void)
mxUint16 * get_uint16s(void) const
int set_int64s(mxInt64 *)
std::size_t get_element_size(void) const
mxArray_octave_value(const mxArray_octave_value &arg)
const char * get_field_name_by_number(int) const
int is_uint64(void) const
int set_uint8s(mxUint8 *)
mxUint32 * get_uint32s(void) const
mxInt16 * get_int16s(void) const
mxUint8 * get_uint8s(void) const
mxArray_octave_value & operator=(const mxArray_octave_value &)=delete
int set_uint64s(mxUint64 *)
int set_complex_doubles(mxComplexDouble *)
void set_class_name(const char *)
int is_numeric(void) const
mwSize * get_dimensions(void) const
mxInt64 * get_int64s(void) const
mxArray * get_cell(mwIndex) const
void set_imag_data(void *)
int get_field_number(const char *) const
void set_property(mwIndex idx, const char *pname, const mxArray *pval)
bool is_scalar(void) const
int get_number_of_fields(void) const
int set_int32s(mxInt32 *)
char * array_to_string(void) const
mwIndex calc_single_subscript(mwSize nsubs, mwIndex *subs) const
mxComplexDouble * get_complex_doubles(void) const
bool is_octave_value(void) const
void * get_imag_data(void) const
mxArray_base * dup(void) const
mxArray_octave_value(bool interleaved, const octave_value &ov)
mxComplexSingle * get_complex_singles(void) const
mwIndex * get_jc(void) const
mwIndex * get_ir(void) const
mxInt8 * get_int8s(void) const
int is_complex(void) const
int set_int16s(mxInt16 *)
mxInt32 * get_int32s(void) const
mwSize get_nzmax(void) const
mxArray * get_property(mwIndex idx, const char *pname) const
int is_double(void) const
void request_mutation(void) const
int is_uint32(void) const
T * get_data(mxClassID class_id, mxComplexity complexity) const
int is_single(void) const
int get_string(char *buf, mwSize buflen) const
int set_complex_singles(mxComplexSingle *)
mxArray * as_mxArray(void) const
double get_scalar(void) const
mwSize get_number_of_dimensions(void) const
void set_field_by_number(mwIndex, int, mxArray *)
mxDouble * get_doubles(void) const
int is_logical_scalar_true(void) const
int is_function_handle(void) const
mxArray * get_field_by_number(mwIndex, int) const
mxArray * mutate(void) const
int is_struct(void) const
mxArray_separate_full(const mxArray_separate_full &val)
mxArray_separate_full(const char *str)
int set_complex_uint32s(mxComplexUint32 *)
mxUint8 * get_uint8s(void) const
mxArray_separate_full(mxClassID id, mwSize m, mwSize n, mxComplexity flag=mxREAL, bool init=true)
mxInt32 * get_int32s(void) const
int is_complex(void) const
mxInt16 * get_int16s(void) const
mxComplexDouble * get_complex_doubles(void) const
void set_imag_data(void *pi)
mxComplexUint64 * get_complex_uint64s(void) const
mxComplexInt8 * get_complex_int8s(void) const
mxInt64 * get_int64s(void) const
int set_complex_int16s(mxComplexInt16 *)
int set_uint64s(mxUint64 *)
mxArray_separate_full & operator=(const mxArray_separate_full &)
int set_int16s(mxInt16 *)
int set_int32s(mxInt32 *)
mxUint16 * get_uint16s(void) const
int set_uint8s(mxUint8 *)
mxArray_separate_full(mxClassID id, mwSize ndims, const mwSize *dims, mxComplexity flag=mxREAL, bool init=true)
mxArray_separate_full(mxClassID id, mxLogical val)
int set_complex_int32s(mxComplexInt32 *)
int set_complex_uint64s(mxComplexUint64 *)
octave_value as_octave_value(void) const
int set_complex_int8s(mxComplexInt8 *)
int set_int64s(mxInt64 *)
~mxArray_separate_full(void)
int set_doubles(mxDouble *)
mxUint32 * get_uint32s(void) const
mxComplexUint32 * get_complex_uint32s(void) const
mxArray_base * dup(void) const
int set_singles(mxSingle *)
octave_value to_ov(const dim_vector &dv) const
mxComplexUint8 * get_complex_uint8s(void) const
int set_uint32s(mxUint32 *)
int set_complex_int64s(mxComplexInt64 *)
int set_complex_doubles(mxComplexDouble *)
mxComplexInt64 * get_complex_int64s(void) const
int set_complex_singles(mxComplexSingle *)
mxArray_separate_full(mxClassID id, const dim_vector &dv, mxComplexity flag=mxREAL)
mxComplexInt32 * get_complex_int32s(void) const
mxSingle * get_singles(void) const
mxArray_separate_full(mwSize m, const char **str)
int set_complex_uint16s(mxComplexUint16 *)
mxArray_separate_full(mxClassID id, double val)
int set_uint16s(mxUint16 *)
mxInt8 * get_int8s(void) const
mxComplexUint16 * get_complex_uint16s(void) const
mxComplexInt16 * get_complex_int16s(void) const
int set_complex_uint8s(mxComplexUint8 *)
mxUint64 * get_uint64s(void) const
mxDouble * get_doubles(void) const
void * get_imag_data(void) const
mxComplexSingle * get_complex_singles(void) const
mxComplexDouble * get_complex_doubles(void) const
void set_imag_data(void *pi)
int is_complex(void) const
int set_doubles(mxDouble *)
mxArray_separate_sparse(mxClassID id, mwSize m, mwSize n, mwSize nzmax, mxComplexity flag=mxREAL)
mxArray_separate_sparse(const mxArray_separate_sparse &val)
octave_value as_octave_value(void) const
void * get_imag_data(void) const
int set_complex_doubles(mxComplexDouble *)
~mxArray_separate_sparse(void)
mxArray_base * dup(void) const
mxDouble * get_doubles(void) const
mxArray_separate_sparse & operator=(const mxArray_separate_sparse &)
mxArray_struct(bool interleaved, mwSize ndims, const mwSize *dims, int num_keys, const char **keys)
int get_number_of_fields(void) const
octave_value as_octave_value(void) const
mxArray_struct(bool interleaved, const dim_vector &dv, int num_keys, const char **keys)
void remove_field(int key_num)
mxArray_struct(const mxArray_struct &val)
mxArray_struct & operator=(const mxArray_struct &val)
int get_field_number(const char *key) const
mxArray * get_field_by_number(mwIndex index, int key_num) const
mxArray_struct(bool interleaved, mwSize m, mwSize n, int num_keys, const char **keys)
const char * get_field_name_by_number(int key_num) const
void set_data(void *data)
int add_field(const char *key)
void init(const char **keys)
mxArray_base * dup(void) const
void * get_data(void) const
void set_field_by_number(mwIndex index, int key_num, mxArray *val)
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
int is_logical_scalar_true(void) const
int is_uint32(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
mxInt32 * get_int32s(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
static OCTINTERP_API octave_value as_octave_value(const mxArray *ptr, bool null_is_empty=true)
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)
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
octave_value get_property(octave_idx_type idx, const std::string &name) const
void set_property(octave_idx_type idx, const std::string &name, const octave_value &pval)
std::string name(void) const
void * mex_fcn_ptr(void) const
void atexit(void(*fcn)(void))
bool use_interleaved_complex(void) const
void resize(octave_idx_type n, const octave_value &rfv=octave_value())
octave_idx_type length(void) const
bool is_classdef_object(void) const
bool issparse(void) const
bool is_uint16_type(void) const
const octave_idx_type * mex_get_ir(void) const
const octave_idx_type * mex_get_jc(void) const
bool is_int8_type(void) const
octave_idx_type rows(void) const
bool isnumeric(void) const
octave_idx_type numel(void) const
bool is_string(void) const
bool is_defined(void) const
charNDArray char_array_value(bool frc_str_conv=false) const
bool is_double_type(void) const
bool is_function_handle(void) const
std::string class_name(void) const
bool is_uint32_type(void) const
bool is_int64_type(void) const
bool isstruct(void) const
double scalar_value(bool frc_str_conv=false) const
octave_idx_type nfields(void) const
bool is_int32_type(void) const
bool is_uint64_type(void) const
octave_idx_type nzmax(void) const
bool is_int16_type(void) const
bool is_range(void) const
bool is_single_type(void) const
OCTINTERP_API const void * mex_get_data(mxClassID class_id=mxUNKNOWN_CLASS, mxComplexity complexity=mxREAL) const
mxArray * as_mxArray(bool interleaved=false) const
bool is_uint8_type(void) const
bool iscomplex(void) const
bool islogical(void) const
dim_vector dims(void) const
OCTINTERP_API octave_classdef * classdef_object_value(bool silent=false) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void warning(const char *fmt,...)
void vwarning_with_id(const char *id, const char *fmt, va_list args)
void verror_with_id(const char *id, const char *fmt, va_list args)
void error(const char *fmt,...)
#define panic_impossible()
octave_f77_int_type F77_INT
bool set_property_in_handle(double handle, const std::string &property, const octave_value &arg, const std::string &fcn)
octave_value get_property_from_handle(double handle, const std::string &property, const std::string &fcn)
interpreter & __get_interpreter__(void)
tree_evaluator & __get_evaluator__(void)
double lo_ieee_inf_value(void)
double lo_ieee_nan_value(void)
#define lo_ieee_isfinite(x)
F77_RET_T(F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, const F77_INT &, const F77_INT &, const F77_INT &, F77_INT &, F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, F77_DBLE *, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, F77_INT *, F77_INT &F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL)
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
F77_RET_T const F77_DBLE const F77_DBLE * f
static char * strsave(const char *s)
void mxSetIr(mxArray *ptr, mwIndex *ir)
OCTINTERP_API mxUint16 * mxGetUint16s(const mxArray *p)
void mxSetCell(mxArray *ptr, mwIndex idx, mxArray *val)
bool mxIsUint16(const mxArray *ptr)
std::size_t mxGetM(const mxArray *ptr)
OCTINTERP_API int mxSetDoubles(mxArray *p, mxDouble *d)
OCTINTERP_API mxDouble * mxGetDoubles(const mxArray *p)
void mexWarnMsgIdAndTxt(const char *id, const char *fmt,...)
OCTINTERP_API int mxSetUint8s(mxArray *p, mxUint8 *d)
#define CONST_MUTATION_METHOD(RET_TYPE, FCN_NAME, ARG_LIST, RET_VAL)
void * mxGetData(const mxArray *ptr)
void * mxMalloc(std::size_t n)
mwIndex mxCalcSingleSubscript(const mxArray *ptr, mwSize nsubs, mwIndex *subs)
OCTINTERP_API int mxSetInt16s(mxArray *p, mxInt16 *d)
OCTINTERP_API mxInt64 * mxGetInt64s(const mxArray *p)
bool mxIsFunctionHandle(const mxArray *ptr)
bool mxIsStruct(const mxArray *ptr)
int mxGetFieldNumber(const mxArray *ptr, const char *key)
void mexErrMsgTxt(const char *s)
void mxSetField(mxArray *ptr, mwIndex index, const char *key, mxArray *val)
OCTINTERP_API mxArray * mxCreateCellMatrix_interleaved(mwSize m, mwSize n)
void(* cmex_fptr)(int nlhs, mxArray **plhs, int nrhs, mxArray **prhs)
bool mxIsUint32(const mxArray *ptr)
void mxSetProperty(mxArray *ptr, mwIndex idx, const char *property_name, const mxArray *property_value)
OCTINTERP_API int mxSetComplexDoubles(mxArray *p, mxComplexDouble *d)
OCTINTERP_API mxUint64 * mxGetUint64s(const mxArray *p)
bool mxIsComplex(const mxArray *ptr)
OCTINTERP_API mxArray * mxCreateCharArray_interleaved(mwSize ndims, const mwSize *dims)
OCTINTERP_API mxComplexDouble * mxGetComplexDoubles(const mxArray *p)
OCTINTERP_API mxArray * mxCreateString(const char *str)
OCTINTERP_API mxArray * mxCreateSparseLogicalMatrix_interleaved(mwSize m, mwSize n, mwSize nzmax)
OCTINTERP_API mxArray * mxCreateCellArray(mwSize ndims, const mwSize *dims)
OCTINTERP_API int mxSetUint32s(mxArray *p, mxUint32 *d)
OCTINTERP_API int mxSetInt8s(mxArray *p, mxInt8 *d)
OCTINTERP_API mxArray * mxCreateNumericMatrix(mwSize m, mwSize n, mxClassID class_id, mxComplexity flag)
int mexAtExit(void(*f)(void))
OCTINTERP_API int mxSetUint16s(mxArray *p, mxUint16 *d)
bool mxIsFinite(const double v)
OCTINTERP_API mxSingle * mxGetSingles(const mxArray *p)
bool mxIsScalar(const mxArray *ptr)
bool mxIsFromGlobalWS(const mxArray *)
void mxSetFieldByNumber(mxArray *ptr, mwIndex index, int key_num, mxArray *val)
const char * mxGetClassName(const mxArray *ptr)
bool mxIsLogicalScalarTrue(const mxArray *ptr)
OCTINTERP_API int mxSetInt32s(mxArray *p, mxInt32 *d)
OCTINTERP_API mxArray * mxCreateSparse(mwSize m, mwSize n, mwSize nzmax, mxComplexity flag)
static octave_value_list mx_to_ov_args(int nargin, mxArray *argin[])
OCTINTERP_API mxArray * mxCreateStructArray(mwSize ndims, const mwSize *dims, int num_keys, const char **keys)
OCTINTERP_API void * mxGetImagData(const mxArray *ptr)
mxClassID mxGetClassID(const mxArray *ptr)
bool mxIsLogical(const mxArray *ptr)
mxArray * mxGetProperty(const mxArray *ptr, mwIndex idx, const char *property_name)
std::map< std::string, int > mex_lock_count
void mexWarnMsgTxt(const char *s)
OCTINTERP_API mxInt16 * mxGetInt16s(const mxArray *p)
void mxSetData(mxArray *ptr, void *pr)
const char * mexFunctionName(void)
mwIndex * mxGetIr(const mxArray *ptr)
OCTINTERP_API int mxSetUint64s(mxArray *p, mxUint64 *d)
OCTINTERP_API mxInt8 * mxGetInt8s(const mxArray *p)
bool mxIsInt64(const mxArray *ptr)
mxArray * mxGetFieldByNumber(const mxArray *ptr, mwIndex index, int key_num)
mxArray * mexCallMATLABWithTrap(int nargout, mxArray *argout[], int nargin, mxArray *argin[], const char *fname)
int mxSetDimensions(mxArray *ptr, const mwSize *dims, mwSize ndims)
std::size_t mxGetNumberOfElements(const mxArray *ptr)
octave_value_list call_mex(octave_mex_function &mex_fcn, const octave_value_list &args, int nargout_arg)
int mexPrintf(const char *fmt,...)
bool mxIsChar(const mxArray *ptr)
bool mxIsInf(const double v)
bool mxIsUint8(const mxArray *ptr)
void mxDestroyArray(mxArray *ptr)
void mxSetNzmax(mxArray *ptr, mwSize nzmax)
bool mxIsSingle(const mxArray *ptr)
void mexErrMsgIdAndTxt(const char *id, const char *fmt,...)
F77_RET_T(* fmex_fptr)(F77_INT &nlhs, mxArray **plhs, F77_INT &nrhs, mxArray **prhs)
int mxAddField(mxArray *ptr, const char *key)
void mexMakeMemoryPersistent(void *ptr)
bool mxIsInt8(const mxArray *ptr)
OCTINTERP_API mxComplexSingle * mxGetComplexSingles(const mxArray *p)
std::size_t mxGetElementSize(const mxArray *ptr)
OCTINTERP_API void mxSetImagData(mxArray *ptr, void *pi)
OCTINTERP_API mxArray * mxCreateLogicalArray(mwSize ndims, const mwSize *dims)
int mexCallMATLAB(int nargout, mxArray *argout[], int nargin, mxArray *argin[], const char *fname)
bool mxIsNaN(const double v)
OCTINTERP_API mxArray * mxCreateCharArray(mwSize ndims, const mwSize *dims)
OCTINTERP_API mxUint8 * mxGetUint8s(const mxArray *p)
void mxSetPr(mxArray *ptr, double *pr)
mxArray * mexEvalStringWithTrap(const char *s)
mxArray * mexGetVariable(const char *space, const char *name)
bool mxIsClass(const mxArray *ptr, const char *name)
OCTINTERP_API mxArray * mxCreateString_interleaved(const char *str)
OCTINTERP_API mxInt32 * mxGetInt32s(const mxArray *p)
OCTINTERP_API mxArray * mxCreateUninitNumericMatrix_interleaved(mwSize m, mwSize n, mxClassID class_id, mxComplexity flag)
static mwSize max_str_len(mwSize m, const char **str)
int mxGetNumberOfFields(const mxArray *ptr)
#define GET_DATA_METHOD(RT, FCN_NAME, ID, COMPLEXITY)
OCTINTERP_API mxArray * mxCreateCellArray_interleaved(mwSize ndims, const mwSize *dims)
void * mxCalloc(std::size_t n, std::size_t size)
OCTINTERP_API mxArray * mxCreateNumericArray_interleaved(mwSize ndims, const mwSize *dims, mxClassID class_id, mxComplexity flag)
mwIndex * mxGetJc(const mxArray *ptr)
int mexPutVariable(const char *space, const char *name, const mxArray *ptr)
void mxSetN(mxArray *ptr, mwSize n)
OCTINTERP_API mxArray * mxCreateNumericArray(mwSize ndims, const mwSize *dims, mxClassID class_id, mxComplexity flag)
OCTINTERP_API int mxSetInt64s(mxArray *p, mxInt64 *d)
static mxArray * maybe_mark_array(mxArray *ptr)
OCTINTERP_API mxArray * mxCreateSparseLogicalMatrix(mwSize m, mwSize n, mwSize nzmax)
bool mxIsInt32(const mxArray *ptr)
OCTINTERP_API double * mxGetPi(const mxArray *ptr)
OCTINTERP_API mxArray * mxCreateCharMatrixFromStrings_interleaved(mwSize m, const char **str)
void * mxRealloc(void *ptr, std::size_t size)
int mexIsGlobal(const mxArray *ptr)
void mxSetJc(mxArray *ptr, mwIndex *jc)
bool mxIsInt16(const mxArray *ptr)
const mwSize * mxGetDimensions(const mxArray *ptr)
OCTINTERP_API int mxSetComplexSingles(mxArray *p, mxComplexSingle *d)
OCTINTERP_API mxArray * mxCreateCellMatrix(mwSize m, mwSize n)
int mexEvalString(const char *s)
void mexSetTrapFlag(int flag)
mwSize mxGetNzmax(const mxArray *ptr)
OCTINTERP_API mxArray * mxCreateLogicalScalar(mxLogical val)
void mxSetClassName(mxArray *ptr, const char *name)
const mxArray * mexGetVariablePtr(const char *space, const char *name)
OCTINTERP_API mxUint32 * mxGetUint32s(const mxArray *p)
bool mxIsNumeric(const mxArray *ptr)
static void * xmalloc(size_t n)
static void * xrealloc(void *ptr, size_t n)
OCTINTERP_API mxArray * mxCreateSparse_interleaved(mwSize m, mwSize n, mwSize nzmax, mxComplexity flag)
OCTINTERP_API mxArray * mxCreateDoubleMatrix(mwSize nr, mwSize nc, mxComplexity flag)
bool mxIsCell(const mxArray *ptr)
static mxArray * maybe_unmark_array(mxArray *ptr)
void mexMakeArrayPersistent(mxArray *ptr)
OCTINTERP_API mxArray * mxCreateCharMatrixFromStrings(mwSize m, const char **str)
double mxGetScalar(const mxArray *ptr)
#define VOID_MUTATION_METHOD(FCN_NAME, ARG_LIST)
void mxRemoveField(mxArray *ptr, int key_num)
int mxGetString(const mxArray *ptr, char *buf, mwSize buflen)
const char * mxGetFieldNameByNumber(const mxArray *ptr, int key_num)
OCTINTERP_API mxArray * mxCreateStructMatrix(mwSize rows, mwSize cols, int num_keys, const char **keys)
bool mxIsLogicalScalar(const mxArray *ptr)
OCTINTERP_API mxArray * mxCreateDoubleScalar(double val)
OCTINTERP_API mxArray * mxCreateUninitNumericArray(mwSize ndims, const mwSize *dims, mxClassID class_id, mxComplexity flag)
static void xfree(void *ptr)
std::size_t mxGetN(const mxArray *ptr)
OCTINTERP_API mxArray * mxCreateNumericMatrix_interleaved(mwSize m, mwSize n, mxClassID class_id, mxComplexity flag)
mwSize mxGetNumberOfDimensions(const mxArray *ptr)
mxLogical * mxGetLogicals(const mxArray *ptr)
OCTINTERP_API mxArray * mxCreateUninitNumericMatrix(mwSize m, mwSize n, mxClassID class_id, mxComplexity flag)
OCTINTERP_API int mxMakeArrayComplex(mxArray *ptr)
double * mxGetPr(const mxArray *ptr)
int mexSet(double handle, const char *property, mxArray *val)
#define MUTATION_METHOD(RET_TYPE, FCN_NAME, ARG_LIST, RET_VAL)
const mxArray * mexGet(double handle, const char *property)
OCTINTERP_API mxArray * mxCreateStructMatrix_interleaved(mwSize rows, mwSize cols, int num_keys, const char **keys)
bool mxIsEmpty(const mxArray *ptr)
OCTINTERP_API mxArray * mxCreateLogicalArray_interleaved(mwSize ndims, const mwSize *dims)
mxArray * mxGetField(const mxArray *ptr, mwIndex index, const char *key)
char * mxArrayToString(const mxArray *ptr)
OCTINTERP_API mxArray * mxCreateLogicalMatrix_interleaved(mwSize m, mwSize n)
OCTINTERP_API int mxMakeArrayReal(mxArray *ptr)
mxChar * mxGetChars(const mxArray *ptr)
OCTINTERP_API const mxArray * mexGet_interleaved(double handle, const char *property)
static T * maybe_unmark(T *ptr)
bool mxIsSparse(const mxArray *ptr)
bool mxIsUint64(const mxArray *ptr)
OCTINTERP_API mxArray * mxCreateDoubleScalar_interleaved(double val)
bool mxIsDouble(const mxArray *ptr)
mxArray * mxGetCell(const mxArray *ptr, mwIndex idx)
OCTINTERP_API mxArray * mxCreateStructArray_interleaved(mwSize ndims, const mwSize *dims, int num_keys, const char **keys)
OCTINTERP_API mxArray * mxCreateLogicalScalar_interleaved(mxLogical val)
OCTINTERP_API void mxSetPi(mxArray *ptr, double *pi)
OCTINTERP_API mxArray * mxCreateUninitNumericArray_interleaved(mwSize ndims, const mwSize *dims, mxClassID class_id, mxComplexity flag)
OCTINTERP_API int mxSetSingles(mxArray *p, mxSingle *d)
void mxSetM(mxArray *ptr, mwSize m)
OCTINTERP_API mxArray * mxCreateLogicalMatrix(mwSize m, mwSize n)
static mwIndex calc_single_subscript_internal(mwSize ndims, const mwSize *dims, mwSize nsubs, const mwIndex *subs)
OCTINTERP_API mxArray * mxCreateDoubleMatrix_interleaved(mwSize nr, mwSize nc, mxComplexity flag)
static void * maybe_mark_foreign(void *ptr)
mxArray * mxDuplicateArray(const mxArray *ptr)
std::complex< double > Complex
std::complex< float > FloatComplex
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
octave_value_list feval(const char *name, const octave_value_list &args, int nargout)
Evaluate an Octave function (built-in or interpreted) and return the list of result values.
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.
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
std::size_t vformat(std::ostream &os, const char *fmt, va_list args)