Mercurial > jwe > octave
comparison libinterp/octave-value/ov-struct.cc @ 28131:4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
* mexproto.h, mex.cc, mxarray.h (mxMakeArrayReal, mxMakeArrayComplex,
mxGetDoubles, mxGetSingles, mxGetInt8s, mxGetInt16s, mxGetInt32s,
mxGetInt64s, mxGetUint8s, mxGetUint16s, mxGetUint32s, mxGetUint64s,
mxGetComplexDoubles, mxGetComplexSingles, mxSetDoubles, mxSetSingles,
mxSetInt8s, mxSetInt16s, mxSetInt32s, mxSetInt64s, mxSetUint8s,
mxSetUint16s, mxSetUint32s, mxSetUint64s, mxSetComplexDoubles,
mxSetComplexSingles): New functions. Provide corresponding member
functions in mxArray class hierarchy to handle the actual operations.
(mxGetComplexInt8s, mxGetComplexInt16s, mxGetComplexInt32s,
mxGetComplexInt64s, mxGetComplexUint8s, mxGetComplexUint16s,
mxGetComplexUint32s, mxGetComplexUint64s, mxSetComplexInt8s,
mxSetComplexInt16s, mxSetComplexInt32s, mxSetComplexInt64s,
mxSetComplexUint8s, mxSetComplexUint16s, mxSetComplexUint32s,
mxSetComplexUint64s): Add prototypes and functions, but leave
commented out since we don't have complex integer data.
(class mxArray_number, class mxArray_sparse):
Handle interleaved complex data. In mxArray_octave_value and
mxArray_matlab constructors, handle interleaved flag in constructor to
determine data layout to use when creating mxArray_number or
mxArray_sparse objects.
(mex::make_value): Check flag in mex function to determine whether to
create arrays with interleaved complex.
* ov.h, ov.cc, ov-base.h, ov-base.cc, ov-base-diag.h, ov-base-diag.cc,
ov-bool-mat.h, ov-bool-mat.cc, ov-bool-sparse.h, ov-bool-sparse.cc,
ov-bool.h, ov-bool.cc, ov-cell.h, ov-cell.cc, ov-ch-mat.h,
ov-ch-mat.cc, ov-class.h, ov-class.cc, ov-complex.h, ov-complex.cc,
ov-cx-mat.h, ov-cx-mat.cc, ov-cx-sparse.h, ov-cx-sparse.cc,
ov-float.h, ov-float.cc, ov-flt-complex.h, ov-flt-complex.cc,
ov-flt-cx-mat.h, ov-flt-cx-mat.cc, ov-flt-re-mat.h, ov-flt-re-mat.cc,
ov-intx.h, ov-lazy-idx.h, ov-perm.h, ov-perm.cc, ov-range.h,
ov-range.cc, ov-re-mat.h, ov-re-mat.cc, ov-re-sparse.h,
ov-re-sparse.cc, ov-scalar.h, ov-scalar.cc, ov-struct.h, ov-struct.cc:
In all as_mxArray methods, handle new interleaved input to optionally
create objects that will use interleaved complex data.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 18 Feb 2020 13:16:41 -0500 |
parents | bd51beb6205e |
children | ef349f5c320b |
comparison
equal
deleted
inserted
replaced
28130:0a88a4743096 | 28131:4c21f99b4ad5 |
---|---|
1010 | 1010 |
1011 return retval; | 1011 return retval; |
1012 } | 1012 } |
1013 | 1013 |
1014 mxArray * | 1014 mxArray * |
1015 octave_struct::as_mxArray (void) const | 1015 octave_struct::as_mxArray (bool interleaved) const |
1016 { | 1016 { |
1017 int nf = nfields (); | 1017 int nf = nfields (); |
1018 string_vector kv = map_keys (); | 1018 string_vector kv = map_keys (); |
1019 | 1019 |
1020 OCTAVE_LOCAL_BUFFER (const char *, f, nf); | 1020 OCTAVE_LOCAL_BUFFER (const char *, f, nf); |
1021 | 1021 |
1022 for (int i = 0; i < nf; i++) | 1022 for (int i = 0; i < nf; i++) |
1023 f[i] = kv[i].c_str (); | 1023 f[i] = kv[i].c_str (); |
1024 | 1024 |
1025 mxArray *retval = new mxArray (dims (), nf, f); | 1025 mxArray *retval = new mxArray (interleaved, dims (), nf, f); |
1026 | 1026 |
1027 mxArray **elts = static_cast<mxArray **> (retval->get_data ()); | 1027 mxArray **elts = static_cast<mxArray **> (retval->get_data ()); |
1028 | 1028 |
1029 mwSize nel = numel (); | 1029 mwSize nel = numel (); |
1030 | 1030 |
1036 | 1036 |
1037 const octave_value *p = c.data (); | 1037 const octave_value *p = c.data (); |
1038 | 1038 |
1039 mwIndex k = 0; | 1039 mwIndex k = 0; |
1040 for (mwIndex j = i; j < ntot; j += nf) | 1040 for (mwIndex j = i; j < ntot; j += nf) |
1041 elts[j] = new mxArray (p[k++]); | 1041 elts[j] = new mxArray (interleaved, p[k++]); |
1042 } | 1042 } |
1043 | 1043 |
1044 return retval; | 1044 return retval; |
1045 } | 1045 } |
1046 | 1046 |
1628 | 1628 |
1629 return retval; | 1629 return retval; |
1630 } | 1630 } |
1631 | 1631 |
1632 mxArray * | 1632 mxArray * |
1633 octave_scalar_struct::as_mxArray (void) const | 1633 octave_scalar_struct::as_mxArray (bool interleaved) const |
1634 { | 1634 { |
1635 int nf = nfields (); | 1635 int nf = nfields (); |
1636 string_vector kv = map_keys (); | 1636 string_vector kv = map_keys (); |
1637 | 1637 |
1638 OCTAVE_LOCAL_BUFFER (const char *, f, nf); | 1638 OCTAVE_LOCAL_BUFFER (const char *, f, nf); |
1639 | 1639 |
1640 for (int i = 0; i < nf; i++) | 1640 for (int i = 0; i < nf; i++) |
1641 f[i] = kv[i].c_str (); | 1641 f[i] = kv[i].c_str (); |
1642 | 1642 |
1643 mxArray *retval = new mxArray (dims (), nf, f); | 1643 mxArray *retval = new mxArray (interleaved, dims (), nf, f); |
1644 | 1644 |
1645 mxArray **elts = static_cast<mxArray **> (retval->get_data ()); | 1645 mxArray **elts = static_cast<mxArray **> (retval->get_data ()); |
1646 | 1646 |
1647 mwSize nel = numel (); | 1647 mwSize nel = numel (); |
1648 | 1648 |
1654 | 1654 |
1655 const octave_value *p = c.data (); | 1655 const octave_value *p = c.data (); |
1656 | 1656 |
1657 mwIndex k = 0; | 1657 mwIndex k = 0; |
1658 for (mwIndex j = i; j < ntot; j += nf) | 1658 for (mwIndex j = i; j < ntot; j += nf) |
1659 elts[j] = new mxArray (p[k++]); | 1659 elts[j] = new mxArray (interleaved, p[k++]); |
1660 } | 1660 } |
1661 | 1661 |
1662 return retval; | 1662 return retval; |
1663 } | 1663 } |
1664 | 1664 |