GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
mxarray.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2001-2024 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 /*
27 
28 Part of this code was originally distributed as part of Octave Forge under
29 the following terms:
30 
31 Author: Paul Kienzle
32 I grant this code to the public domain.
33 2001-03-22
34 
35 THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
36 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
39 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
40 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
41 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
43 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
44 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45 SUCH DAMAGE.
46 
47 */
48 
49 #if ! defined (octave_mxarray_h)
50 #define octave_mxarray_h 1
51 
52 #include "octave-config.h"
53 
54 #include "mxtypes.h"
55 
56 #if ! defined (MXARRAY_TYPEDEFS_ONLY)
57 
58 #include <cstring>
59 #include "error.h"
60 
61 class octave_value;
62 class dim_vector;
63 
64 #define DO_MUTABLE_METHOD(RET_T, METHOD_CALL) \
65  RET_T retval = m_rep->METHOD_CALL; \
66  \
67  if (m_rep->mutation_needed ()) \
68  { \
69  maybe_mutate (); \
70  retval = m_rep->METHOD_CALL; \
71  } \
72  \
73  return retval
74 
75 #define DO_VOID_MUTABLE_METHOD(METHOD_CALL) \
76  m_rep->METHOD_CALL; \
77  \
78  if (m_rep->mutation_needed ()) \
79  { \
80  maybe_mutate (); \
81  m_rep->METHOD_CALL; \
82  }
83 
84 class OCTINTERP_API mxArray;
85 
86 // A class to provide the default implementation of some of the
87 // virtual functions declared in the mxArray class.
88 
89 class OCTINTERP_API mxArray_base
90 {
91 protected:
92 
93  OCTINTERP_API mxArray_base (bool interleaved);
94 
95 public:
96 
97  mxArray_base () = delete;
98 
99  OCTAVE_DEFAULT_COPY_MOVE (mxArray_base)
100 
101  virtual mxArray_base * dup () const = 0;
102 
103  virtual mxArray * as_mxArray () const { return nullptr; }
104 
105  virtual ~mxArray_base () = default;
106 
107  virtual bool is_octave_value () const { return false; }
108 
109  virtual int iscell () const = 0;
110 
111  virtual int is_char () const = 0;
112 
113  virtual int is_class (const char *name_arg) const
114  {
115  int retval = 0;
116 
117  const char *cname = get_class_name ();
118 
119  if (cname && name_arg)
120  retval = ! strcmp (cname, name_arg);
121 
122  return retval;
123  }
124 
125  virtual int is_complex () const = 0;
126 
127  virtual int is_double () const = 0;
128 
129  virtual int is_function_handle () const = 0;
130 
131  virtual int is_int16 () const = 0;
132 
133  virtual int is_int32 () const = 0;
134 
135  virtual int is_int64 () const = 0;
136 
137  virtual int is_int8 () const = 0;
138 
139  virtual int is_logical () const = 0;
140 
141  virtual int is_numeric () const = 0;
142 
143  virtual int is_single () const = 0;
144 
145  virtual int is_sparse () const = 0;
146 
147  virtual int is_struct () const = 0;
148 
149  virtual int is_uint16 () const = 0;
150 
151  virtual int is_uint32 () const = 0;
152 
153  virtual int is_uint64 () const = 0;
154 
155  virtual int is_uint8 () const = 0;
156 
157  virtual int is_logical_scalar () const
158  {
159  return is_logical () && get_number_of_elements () == 1;
160  }
161 
162  virtual int is_logical_scalar_true () const = 0;
163 
164  virtual mwSize get_m () const = 0;
165 
166  virtual mwSize get_n () const = 0;
167 
168  virtual mwSize * get_dimensions () const = 0;
169 
170  virtual mwSize get_number_of_dimensions () const = 0;
171 
172  virtual void set_m (mwSize m) = 0;
173 
174  virtual void set_n (mwSize n) = 0;
175 
176  virtual int set_dimensions (mwSize *dims_arg, mwSize ndims_arg) = 0;
177 
178  virtual mwSize get_number_of_elements () const = 0;
179 
180  virtual int isempty () const = 0;
181 
182  virtual bool is_scalar () const = 0;
183 
184  virtual mxClassID get_class_id () const = 0;
185 
186  virtual const char * get_class_name () const = 0;
187 
188  virtual void set_class_name (const char *name_arg) = 0;
189 
190  // The following functions aren't pure virtual because they are only
191  // valid for one type. Making them pure virtual would mean that they
192  // have to be implemented for all derived types, and all of those
193  // would need to throw errors instead of just doing it once here.
194 
195  virtual mxArray *
196  get_property (mwIndex /*idx*/, const char * /*pname*/) const
197  {
198  return nullptr;
199  }
200 
201  virtual void set_property (mwIndex /*idx*/, const char * /*pname*/,
202  const mxArray * /*pval*/)
203  {
204  err_invalid_type ("set_property");
205  }
206 
207  virtual mxArray * get_cell (mwIndex /*idx*/) const
208  {
209  err_invalid_type ("get_cell");
210  }
211 
212  virtual void set_cell (mwIndex idx, mxArray *val) = 0;
213 
214  virtual double get_scalar () const = 0;
215 
216  virtual void * get_data () const = 0;
217 
218  virtual mxDouble * get_doubles () const = 0;
219  virtual mxSingle * get_singles () const = 0;
220  virtual mxInt8 * get_int8s () const = 0;
221  virtual mxInt16 * get_int16s () const = 0;
222  virtual mxInt32 * get_int32s () const = 0;
223  virtual mxInt64 * get_int64s () const = 0;
224  virtual mxUint8 * get_uint8s () const = 0;
225  virtual mxUint16 * get_uint16s () const = 0;
226  virtual mxUint32 * get_uint32s () const = 0;
227  virtual mxUint64 * get_uint64s () const = 0;
228 
229  virtual mxComplexDouble * get_complex_doubles () const = 0;
230  virtual mxComplexSingle * get_complex_singles () const = 0;
231 
232  virtual void * get_imag_data () const = 0;
233 
234  virtual void set_data (void *pr) = 0;
235 
236  virtual int set_doubles (mxDouble *data) = 0;
237  virtual int set_singles (mxSingle *data) = 0;
238  virtual int set_int8s (mxInt8 *data) = 0;
239  virtual int set_int16s (mxInt16 *data) = 0;
240  virtual int set_int32s (mxInt32 *data) = 0;
241  virtual int set_int64s (mxInt64 *data) = 0;
242  virtual int set_uint8s (mxUint8 *data) = 0;
243  virtual int set_uint16s (mxUint16 *data) = 0;
244  virtual int set_uint32s (mxUint32 *data) = 0;
245  virtual int set_uint64s (mxUint64 *data) = 0;
246 
247  virtual int set_complex_doubles (mxComplexDouble *data) = 0;
248  virtual int set_complex_singles (mxComplexSingle *data) = 0;
249 
250  virtual void set_imag_data (void *pi) = 0;
251 
252  virtual mwIndex * get_ir () const = 0;
253 
254  virtual mwIndex * get_jc () const = 0;
255 
256  virtual mwSize get_nzmax () const = 0;
257 
258  virtual void set_ir (mwIndex *ir) = 0;
259 
260  virtual void set_jc (mwIndex *jc) = 0;
261 
262  virtual void set_nzmax (mwSize nzmax) = 0;
263 
264  virtual int add_field (const char *key) = 0;
265 
266  virtual void remove_field (int key_num) = 0;
267 
268  virtual mxArray * get_field_by_number (mwIndex index, int key_num) const = 0;
269 
270  virtual void
271  set_field_by_number (mwIndex index, int key_num, mxArray *val) = 0;
272 
273  virtual int get_number_of_fields () const = 0;
274 
275  virtual const char * get_field_name_by_number (int key_num) const = 0;
276 
277  virtual int get_field_number (const char *key) const = 0;
278 
279  virtual int get_string (char *buf, mwSize buflen) const = 0;
280 
281  virtual char * array_to_string () const = 0;
282 
283  virtual mwIndex calc_single_subscript (mwSize nsubs, mwIndex *subs) const = 0;
284 
285  virtual std::size_t get_element_size () const = 0;
286 
287  virtual bool mutation_needed () const { return false; }
288 
289  virtual mxArray * mutate () const { return nullptr; }
290 
291  virtual octave_value as_octave_value () const = 0;
292 
293 protected:
294 
295  std::size_t get_numeric_element_size (std::size_t size) const
296  {
297  return (m_interleaved
298  ? is_complex () ? 2 * size : size
299  : size);
300  }
301 
302  OCTAVE_NORETURN void err_invalid_type (const char *op) const
303  {
304  error ("%s: invalid type for mxArray::%s", get_class_name (), op);
305  }
306 
307  //--------
308 
309  // If TRUE, we are using interleaved storage for complex numeric arrays.
311 
312 };
313 
314 // The main interface class. The representation can be based on an
315 // octave_value object or a separate object that tries to reproduce
316 // the semantics of mxArray objects in Matlab more directly.
317 
318 class mxArray
319 {
320 public:
321 
322  OCTINTERP_API mxArray (bool interleaved, const octave_value& ov);
323 
324  OCTINTERP_API mxArray (bool interleaved, mxClassID id, mwSize ndims,
325  const mwSize *dims, mxComplexity flag = mxREAL,
326  bool init = true);
327 
328  OCTINTERP_API mxArray (bool interleaved, mxClassID id, const dim_vector& dv,
329  mxComplexity flag = mxREAL);
330 
331  OCTINTERP_API mxArray (bool interleaved, mxClassID id, mwSize m, mwSize n,
332  mxComplexity flag = mxREAL, bool init = true);
333 
334  OCTINTERP_API mxArray (bool interleaved, mxClassID id, double val);
335 
336  OCTINTERP_API mxArray (bool interleaved, mxClassID id, mxLogical val);
337 
338  OCTINTERP_API mxArray (bool interleaved, const char *str);
339 
340  OCTINTERP_API mxArray (bool interleaved, mwSize m, const char **str);
341 
342  OCTINTERP_API mxArray (bool interleaved, mxClassID id, mwSize m, mwSize n,
343  mwSize nzmax, mxComplexity flag = mxREAL);
344 
345  OCTINTERP_API mxArray (bool interleaved, mwSize ndims, const mwSize *dims,
346  int num_keys, const char **keys);
347 
348  OCTINTERP_API mxArray (bool interleaved, const dim_vector& dv, int num_keys,
349  const char **keys);
350 
351  OCTINTERP_API mxArray (bool interleaved, mwSize m, mwSize n, int num_keys,
352  const char **keys);
353 
354  OCTINTERP_API mxArray (bool interleaved, mwSize ndims, const mwSize *dims);
355 
356  OCTINTERP_API mxArray (bool interleaved, const dim_vector& dv);
357 
358  OCTINTERP_API mxArray (bool interleaved, mwSize m, mwSize n);
359 
360  mxArray * dup () const
361  {
362  mxArray *retval = m_rep->as_mxArray ();
363 
364  if (retval)
365  retval->set_name (m_name);
366  else
367  {
368  mxArray_base *new_rep = m_rep->dup ();
369 
370  retval = new mxArray (new_rep, m_name);
371  }
372 
373  return retval;
374  }
375 
376  OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (mxArray)
377 
378  OCTINTERP_API ~mxArray ();
379 
380  bool is_octave_value () const { return m_rep->is_octave_value (); }
381 
382  int iscell () const { return m_rep->iscell (); }
383 
384  int is_char () const { return m_rep->is_char (); }
385 
386  int is_class (const char *name_arg) const { return m_rep->is_class (name_arg); }
387 
388  int is_complex () const { return m_rep->is_complex (); }
389 
390  int is_double () const { return m_rep->is_double (); }
391 
392  int is_function_handle () const { return m_rep->is_function_handle (); }
393 
394  int is_int16 () const { return m_rep->is_int16 (); }
395 
396  int is_int32 () const { return m_rep->is_int32 (); }
397 
398  int is_int64 () const { return m_rep->is_int64 (); }
399 
400  int is_int8 () const { return m_rep->is_int8 (); }
401 
402  int is_logical () const { return m_rep->is_logical (); }
403 
404  int is_numeric () const { return m_rep->is_numeric (); }
405 
406  int is_single () const { return m_rep->is_single (); }
407 
408  int is_sparse () const { return m_rep->is_sparse (); }
409 
410  int is_struct () const { return m_rep->is_struct (); }
411 
412  int is_uint16 () const { return m_rep->is_uint16 (); }
413 
414  int is_uint32 () const { return m_rep->is_uint32 (); }
415 
416  int is_uint64 () const { return m_rep->is_uint64 (); }
417 
418  int is_uint8 () const { return m_rep->is_uint8 (); }
419 
420  int is_logical_scalar () const { return m_rep->is_logical_scalar (); }
421 
423  { return m_rep->is_logical_scalar_true (); }
424 
425  mwSize get_m () const { return m_rep->get_m (); }
426 
427  mwSize get_n () const { return m_rep->get_n (); }
428 
429  mwSize * get_dimensions () const { return m_rep->get_dimensions (); }
430 
432  { return m_rep->get_number_of_dimensions (); }
433 
435 
437 
438  int set_dimensions (mwSize *dims_arg, mwSize ndims_arg)
439  { DO_MUTABLE_METHOD (int, set_dimensions (dims_arg, ndims_arg)); }
440 
442  { return m_rep->get_number_of_elements (); }
443 
444  int isempty () const { return get_number_of_elements () == 0; }
445 
446  bool is_scalar () const { return m_rep->is_scalar (); }
447 
448  const char * get_name () const { return m_name; }
449 
450  OCTINTERP_API void set_name (const char *name);
451 
452  mxClassID get_class_id () const { return m_rep->get_class_id (); }
453 
454  const char * get_class_name () const { return m_rep->get_class_name (); }
455 
456  mxArray * get_property (mwIndex idx, const char *pname) const
457  { return m_rep->get_property (idx, pname); }
458 
459  void set_property (mwIndex idx, const char *pname, const mxArray *pval)
460  { m_rep->set_property (idx, pname, pval); }
461 
462  void set_class_name (const char *name_arg)
463  { DO_VOID_MUTABLE_METHOD (set_class_name (name_arg)); }
464 
465  mxArray * get_cell (mwIndex idx) const
466  { DO_MUTABLE_METHOD (mxArray *, get_cell (idx)); }
467 
468  void set_cell (mwIndex idx, mxArray *val)
469  { DO_VOID_MUTABLE_METHOD (set_cell (idx, val)); }
470 
471  double get_scalar () const { return m_rep->get_scalar (); }
472 
473  void * get_data () const { DO_MUTABLE_METHOD (void *, get_data ()); }
474 
477 
480 
481  mxInt8 * get_int8s () const
482  { DO_MUTABLE_METHOD (mxInt8 *, get_int8s ()); }
483 
484  mxInt16 * get_int16s () const
486 
487  mxInt32 * get_int32s () const
489 
490  mxInt64 * get_int64s () const
492 
493  mxUint8 * get_uint8s () const
495 
498 
501 
504 
507 
510 
511  void * get_imag_data () const
512  { DO_MUTABLE_METHOD (void *, get_imag_data ()); }
513 
514  void set_data (void *pr) { DO_VOID_MUTABLE_METHOD (set_data (pr)); }
515 
516  int set_doubles (mxDouble *data)
517  { DO_MUTABLE_METHOD (int, set_doubles (data)); }
518 
519  int set_singles (mxSingle *data)
520  { DO_MUTABLE_METHOD (int, set_singles (data)); }
521 
522  int set_int8s (mxInt8 *data)
523  { DO_MUTABLE_METHOD (int, set_int8s (data)); }
524 
525  int set_int16s (mxInt16 *data)
526  { DO_MUTABLE_METHOD (int, set_int16s (data)); }
527 
528  int set_int32s (mxInt32 *data)
529  { DO_MUTABLE_METHOD (int, set_int32s (data)); }
530 
531  int set_int64s (mxInt64 *data)
532  { DO_MUTABLE_METHOD (int, set_int64s (data)); }
533 
534  int set_uint8s (mxUint8 *data)
535  { DO_MUTABLE_METHOD (int, set_uint8s (data)); }
536 
537  int set_uint16s (mxUint16 *data)
538  { DO_MUTABLE_METHOD (int, set_uint16s (data)); }
539 
540  int set_uint32s (mxUint32 *data)
541  { DO_MUTABLE_METHOD (int, set_uint32s (data)); }
542 
543  int set_uint64s (mxUint64 *data)
544  { DO_MUTABLE_METHOD (int, set_uint64s (data)); }
545 
547  { DO_MUTABLE_METHOD (int, set_complex_doubles (data)); }
548 
550  { DO_MUTABLE_METHOD (int, set_complex_singles (data)); }
551 
553 
555 
557 
558  mwSize get_nzmax () const { return m_rep->get_nzmax (); }
559 
561 
563 
564  void set_nzmax (mwSize nzmax) { DO_VOID_MUTABLE_METHOD (set_nzmax (nzmax)); }
565 
566  int add_field (const char *key) { DO_MUTABLE_METHOD (int, add_field (key)); }
567 
568  void remove_field (int key_num)
569  { DO_VOID_MUTABLE_METHOD (remove_field (key_num)); }
570 
571  mxArray * get_field_by_number (mwIndex index, int key_num) const
572  { DO_MUTABLE_METHOD (mxArray *, get_field_by_number (index, key_num)); }
573 
574  void set_field_by_number (mwIndex index, int key_num, mxArray *val)
575  { DO_VOID_MUTABLE_METHOD (set_field_by_number (index, key_num, val)); }
576 
577  int get_number_of_fields () const
578  { return m_rep->get_number_of_fields (); }
579 
580  const char * get_field_name_by_number (int key_num) const
581  { DO_MUTABLE_METHOD (const char *, get_field_name_by_number (key_num)); }
582 
583  int get_field_number (const char *key) const
584  { DO_MUTABLE_METHOD (int, get_field_number (key)); }
585 
586  int get_string (char *buf, mwSize buflen) const
587  { return m_rep->get_string (buf, buflen); }
588 
589  char * array_to_string () const { return m_rep->array_to_string (); }
590 
592  { return m_rep->calc_single_subscript (nsubs, subs); }
593 
594  std::size_t get_element_size () const
595  { return m_rep->get_element_size (); }
596 
597  bool mutation_needed () const { return m_rep->mutation_needed (); }
598 
599  mxArray * mutate () const { return m_rep->mutate (); }
600 
601  static OCTINTERP_API void * malloc (std::size_t n);
602 
603  static OCTINTERP_API void * calloc (std::size_t n, std::size_t t);
604 
605  static OCTINTERP_API void * alloc (bool init, std::size_t n, std::size_t t);
606 
607  static char * strsave (const char *str)
608  {
609  char *retval = nullptr;
610 
611  if (str)
612  {
613  mwSize sz = sizeof (mxChar) * (strlen (str) + 1);
614 
615  retval = static_cast<char *> (mxArray::malloc (sz));
616 
617  if (retval)
618  strcpy (retval, str);
619  }
620 
621  return retval;
622  }
623 
624  static OCTINTERP_API octave_value
625  as_octave_value (const mxArray *ptr, bool null_is_empty = true);
626 
627  OCTINTERP_API octave_value as_octave_value () const;
628 
629 private:
630 
631  mxArray (mxArray_base *r, const char *n)
632  : m_rep (r), m_name (mxArray::strsave (n)) { }
633 
634  static OCTINTERP_API mxArray_base *
635  create_rep (bool interleaved, const octave_value& ov);
636 
637  static OCTINTERP_API mxArray_base *
638  create_rep (bool interleaved, mxClassID id, mwSize ndims,
639  const mwSize *dims, mxComplexity flag, bool init);
640 
641  static OCTINTERP_API mxArray_base *
642  create_rep (bool interleaved, mxClassID id, const dim_vector& dv,
643  mxComplexity flag);
644 
645  static OCTINTERP_API mxArray_base *
646  create_rep (bool interleaved, mxClassID id, mwSize m, mwSize n,
647  mxComplexity flag, bool init);
648 
649  static OCTINTERP_API mxArray_base *
650  create_rep (bool interleaved, mxClassID id, double val);
651 
652  static OCTINTERP_API mxArray_base *
653  create_rep (bool interleaved, mxClassID id, mxLogical val);
654 
655  static OCTINTERP_API mxArray_base *
656  create_rep (bool interleaved, const char *str);
657 
658  static OCTINTERP_API mxArray_base *
659  create_rep (bool interleaved, mwSize m, const char **str);
660 
661  static OCTINTERP_API mxArray_base *
662  create_rep (bool interleaved, mxClassID id, mwSize m, mwSize n,
663  mwSize nzmax, mxComplexity flag);
664 
665  OCTINTERP_API void maybe_mutate () const;
666 
667  //--------
668 
669  mutable mxArray_base *m_rep;
670 
671  char *m_name;
672 
673 };
674 
675 #undef DO_MUTABLE_METHOD
676 #undef DO_VOID_MUTABLE_METHOD
677 
678 #endif
679 #endif
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:94
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
Definition: mxarray.h:302
virtual mxInt8 * get_int8s() const =0
virtual bool is_octave_value() const
Definition: mxarray.h:107
virtual void set_n(mwSize n)=0
virtual void set_cell(mwIndex idx, mxArray *val)=0
virtual int add_field(const char *key)=0
virtual mxComplexDouble * get_complex_doubles() const =0
virtual mwIndex * get_jc() const =0
virtual void set_nzmax(mwSize nzmax)=0
virtual int set_uint16s(mxUint16 *data)=0
virtual mxDouble * get_doubles() const =0
virtual int is_logical() const =0
virtual int is_uint64() const =0
virtual char * array_to_string() const =0
virtual int set_uint64s(mxUint64 *data)=0
virtual int get_string(char *buf, mwSize buflen) const =0
virtual bool is_scalar() const =0
virtual mxSingle * get_singles() const =0
virtual mwIndex calc_single_subscript(mwSize nsubs, mwIndex *subs) const =0
virtual mxArray * get_cell(mwIndex) const
Definition: mxarray.h:207
virtual int set_doubles(mxDouble *data)=0
virtual int set_int64s(mxInt64 *data)=0
virtual int is_complex() const =0
virtual mxComplexSingle * get_complex_singles() const =0
virtual octave_value as_octave_value() const =0
virtual void set_imag_data(void *pi)=0
virtual int is_numeric() const =0
virtual mxArray * get_field_by_number(mwIndex index, int key_num) const =0
virtual int set_int16s(mxInt16 *data)=0
mxArray_base()=delete
virtual int is_double() const =0
virtual mwSize * get_dimensions() const =0
virtual int set_singles(mxSingle *data)=0
virtual int is_char() const =0
virtual void set_m(mwSize m)=0
virtual void set_data(void *pr)=0
virtual int is_logical_scalar_true() const =0
bool m_interleaved
Definition: mxarray.h:310
virtual void * get_data() const =0
virtual mxInt16 * get_int16s() const =0
virtual int is_uint16() const =0
virtual double get_scalar() const =0
virtual int is_class(const char *name_arg) const
Definition: mxarray.h:113
virtual mwSize get_nzmax() const =0
std::size_t get_numeric_element_size(std::size_t size) const
Definition: mxarray.h:295
virtual mxArray_base * dup() const =0
virtual int iscell() const =0
virtual void set_property(mwIndex, const char *, const mxArray *)
Definition: mxarray.h:201
virtual int set_complex_doubles(mxComplexDouble *data)=0
virtual void * get_imag_data() const =0
virtual int isempty() const =0
virtual mwSize get_number_of_elements() const =0
virtual int is_logical_scalar() const
Definition: mxarray.h:157
virtual mxArray * as_mxArray() const
Definition: mxarray.h:103
virtual void set_jc(mwIndex *jc)=0
virtual std::size_t get_element_size() const =0
virtual int set_uint32s(mxUint32 *data)=0
virtual mxUint64 * get_uint64s() const =0
virtual mxUint8 * get_uint8s() const =0
virtual int set_uint8s(mxUint8 *data)=0
virtual bool mutation_needed() const
Definition: mxarray.h:287
virtual mxInt32 * get_int32s() const =0
virtual mwIndex * get_ir() const =0
virtual int set_dimensions(mwSize *dims_arg, mwSize ndims_arg)=0
virtual mxUint16 * get_uint16s() const =0
virtual int is_int16() const =0
virtual int is_single() const =0
virtual void set_class_name(const char *name_arg)=0
virtual mxUint32 * get_uint32s() const =0
virtual mxArray * mutate() const
Definition: mxarray.h:289
virtual mwSize get_number_of_dimensions() const =0
virtual int is_function_handle() const =0
virtual int is_uint8() const =0
virtual mwSize get_m() const =0
virtual int is_int8() const =0
virtual int is_int32() const =0
virtual int get_number_of_fields() const =0
virtual void set_ir(mwIndex *ir)=0
virtual void remove_field(int key_num)=0
virtual int is_uint32() const =0
virtual mxArray * get_property(mwIndex, const char *) const
Definition: mxarray.h:196
virtual const char * get_field_name_by_number(int key_num) const =0
virtual int is_int64() const =0
virtual void set_field_by_number(mwIndex index, int key_num, mxArray *val)=0
virtual const char * get_class_name() const =0
virtual int is_struct() const =0
virtual mxInt64 * get_int64s() const =0
virtual int get_field_number(const char *key) const =0
virtual mwSize get_n() const =0
virtual int set_int32s(mxInt32 *data)=0
virtual ~mxArray_base()=default
virtual int is_sparse() const =0
virtual mxClassID get_class_id() const =0
int set_uint8s(mxUint8 *data)
Definition: mxarray.h:534
int set_complex_singles(mxComplexSingle *data)
Definition: mxarray.h:549
mxUint8 * get_uint8s() const
Definition: mxarray.h:493
int is_logical() const
Definition: mxarray.h:402
int is_logical_scalar() const
Definition: mxarray.h:420
int is_single() const
Definition: mxarray.h:406
mwSize get_m() const
Definition: mxarray.h:425
int set_uint32s(mxUint32 *data)
Definition: mxarray.h:540
int is_int64() const
Definition: mxarray.h:398
int get_number_of_fields() const
Definition: mxarray.h:577
mwIndex * get_ir() const
Definition: mxarray.h:554
mxInt64 * get_int64s() const
Definition: mxarray.h:490
mxUint64 * get_uint64s() const
Definition: mxarray.h:502
double get_scalar() const
Definition: mxarray.h:471
void set_name(const char *name)
Definition: mex.cc:3029
~mxArray()
Definition: mex.cc:3021
char * array_to_string() const
Definition: mxarray.h:589
void * get_imag_data() const
Definition: mxarray.h:511
void set_n(mwSize n)
Definition: mxarray.h:436
mwSize get_number_of_dimensions() const
Definition: mxarray.h:431
bool mutation_needed() const
Definition: mxarray.h:597
void set_property(mwIndex idx, const char *pname, const mxArray *pval)
Definition: mxarray.h:459
mxArray * mutate() const
Definition: mxarray.h:599
std::size_t get_element_size() const
Definition: mxarray.h:594
int set_singles(mxSingle *data)
Definition: mxarray.h:519
mwSize * get_dimensions() const
Definition: mxarray.h:429
const char * get_class_name() const
Definition: mxarray.h:454
int set_uint16s(mxUint16 *data)
Definition: mxarray.h:537
void set_m(mwSize m)
Definition: mxarray.h:434
static void * alloc(bool init, std::size_t n, std::size_t t)
Definition: mex.cc:3491
mxArray * get_property(mwIndex idx, const char *pname) const
Definition: mxarray.h:456
int is_function_handle() const
Definition: mxarray.h:392
mwIndex * get_jc() const
Definition: mxarray.h:556
mxInt16 * get_int16s() const
Definition: mxarray.h:484
int set_uint64s(mxUint64 *data)
Definition: mxarray.h:543
int is_double() const
Definition: mxarray.h:390
mwIndex calc_single_subscript(mwSize nsubs, mwIndex *subs) const
Definition: mxarray.h:591
int is_char() const
Definition: mxarray.h:384
mwSize get_number_of_elements() const
Definition: mxarray.h:441
int set_dimensions(mwSize *dims_arg, mwSize ndims_arg)
Definition: mxarray.h:438
mxUint16 * get_uint16s() const
Definition: mxarray.h:496
static char * strsave(const char *str)
Definition: mxarray.h:607
void set_data(void *pr)
Definition: mxarray.h:514
int isempty() const
Definition: mxarray.h:444
int is_struct() const
Definition: mxarray.h:410
mxComplexSingle * get_complex_singles() const
Definition: mxarray.h:508
static void * calloc(std::size_t n, std::size_t t)
Definition: mex.cc:3485
mxArray(bool interleaved, const octave_value &ov)
Definition: mex.cc:2949
int set_complex_doubles(mxComplexDouble *data)
Definition: mxarray.h:546
int get_field_number(const char *key) const
Definition: mxarray.h:583
int iscell() const
Definition: mxarray.h:382
mxArray * get_field_by_number(mwIndex index, int key_num) const
Definition: mxarray.h:571
int add_field(const char *key)
Definition: mxarray.h:566
mwSize get_nzmax() const
Definition: mxarray.h:558
int is_uint32() const
Definition: mxarray.h:414
mxInt32 * get_int32s() const
Definition: mxarray.h:487
bool is_scalar() const
Definition: mxarray.h:446
int set_int32s(mxInt32 *data)
Definition: mxarray.h:528
int set_int64s(mxInt64 *data)
Definition: mxarray.h:531
int is_int32() const
Definition: mxarray.h:396
int set_doubles(mxDouble *data)
Definition: mxarray.h:516
void set_nzmax(mwSize nzmax)
Definition: mxarray.h:564
int is_logical_scalar_true() const
Definition: mxarray.h:422
int is_numeric() const
Definition: mxarray.h:404
mxArray * dup() const
Definition: mxarray.h:360
bool is_octave_value() const
Definition: mxarray.h:380
mwSize get_n() const
Definition: mxarray.h:427
void set_jc(mwIndex *jc)
Definition: mxarray.h:562
octave_value as_octave_value() const
Definition: mex.cc:3046
int set_int16s(mxInt16 *data)
Definition: mxarray.h:525
int is_complex() const
Definition: mxarray.h:388
mxClassID get_class_id() const
Definition: mxarray.h:452
mxSingle * get_singles() const
Definition: mxarray.h:478
const char * get_field_name_by_number(int key_num) const
Definition: mxarray.h:580
mxUint32 * get_uint32s() const
Definition: mxarray.h:499
int is_uint64() const
Definition: mxarray.h:416
int get_string(char *buf, mwSize buflen) const
Definition: mxarray.h:586
void * get_data() const
Definition: mxarray.h:473
int is_class(const char *name_arg) const
Definition: mxarray.h:386
int set_int8s(mxInt8 *data)
Definition: mxarray.h:522
void set_class_name(const char *name_arg)
Definition: mxarray.h:462
mxDouble * get_doubles() const
Definition: mxarray.h:475
void set_field_by_number(mwIndex index, int key_num, mxArray *val)
Definition: mxarray.h:574
void set_cell(mwIndex idx, mxArray *val)
Definition: mxarray.h:468
mxArray * get_cell(mwIndex idx) const
Definition: mxarray.h:465
int is_uint8() const
Definition: mxarray.h:418
mxComplexDouble * get_complex_doubles() const
Definition: mxarray.h:505
void set_ir(mwIndex *ir)
Definition: mxarray.h:560
static void * malloc(std::size_t n)
Definition: mex.cc:3479
void set_imag_data(void *pi)
Definition: mxarray.h:552
int is_uint16() const
Definition: mxarray.h:412
mxInt8 * get_int8s() const
Definition: mxarray.h:481
void remove_field(int key_num)
Definition: mxarray.h:568
const char * get_name() const
Definition: mxarray.h:448
int is_int8() const
Definition: mxarray.h:400
int is_sparse() const
Definition: mxarray.h:408
int is_int16() const
Definition: mxarray.h:394
void() error(const char *fmt,...)
Definition: error.cc:988
T octave_idx_type m
Definition: mx-inlines.cc:781
octave_idx_type n
Definition: mx-inlines.cc:761
T * r
Definition: mx-inlines.cc:781
#define DO_VOID_MUTABLE_METHOD(METHOD_CALL)
Definition: mxarray.h:75
#define DO_MUTABLE_METHOD(RET_T, METHOD_CALL)
Definition: mxarray.h:64
int16_t mxInt16
Definition: mxtypes.h:95
char mxChar
Definition: mxtypes.h:87
uint64_t mxUint64
Definition: mxtypes.h:102
int32_t mxInt32
Definition: mxtypes.h:96
float mxSingle
Definition: mxtypes.h:92
mxClassID
Definition: mxtypes.h:57
int64_t mxInt64
Definition: mxtypes.h:97
int64_t mwIndex
Definition: mxtypes.h:125
double mxDouble
Definition: mxtypes.h:91
mxComplexity
Definition: mxtypes.h:79
@ mxREAL
Definition: mxtypes.h:80
uint32_t mxUint32
Definition: mxtypes.h:101
uint8_t mxUint8
Definition: mxtypes.h:99
uint16_t mxUint16
Definition: mxtypes.h:100
int8_t mxInt8
Definition: mxtypes.h:94
unsigned char mxLogical
Definition: mxtypes.h:89
int64_t mwSize
Definition: mxtypes.h:124
T::size_type strlen(const typename T::value_type *str)
Definition: oct-string.cc:88
bool strcmp(const T &str_a, const T &str_b)
Octave string utility functions.