-
Notifications
You must be signed in to change notification settings - Fork 0
An adapter-class for MATLAB's mxArrays
License
Dunkelschorsch/arrayadapt
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A C++ wrapper class for MATLAB's mxArray type arrayadapt provides a convient way to access mxArrays in MATLAB's .mex files. The 'ArrayAdaptor' class template can be specialzed for one of the builtin numeric types and a fixed number of dimensions. It allows for subscripted indexing in additon to using C's []-indexing style. An array which is constructed to be n-dimensional will only take 'n' arguments for specifying the size of each dimension in the constructor. Specifying a different number will result in a compiler-error. Furthermore, also the indexing operator will take exactly 'n' arguments. Providing more or less than 'n' indices will result in a compiler-error, again. One source of headache eliminated. Currently, one- through three-dimensional arrays of any numeric type can be wrapped, but extending to an arbitrary number of dimensions can be easily done by implementing two simple class templates. One that takes care of construction and one that encapsulates element access. If debug mode is active for your mex-file, bounds-checking on element access and type-checking on construction is done (at runtime, of course). Since arrayadapt only provides a different interface to the underlying mxArray it will never interfere, in any way, with existing code that changes the data by other means (direct access, other wrappers, etc). Along with arrayadapt comes an 'mx_traits' class template which is currently used to provide a consistent way to get the mxClassID associated with the numeric types in C. In order to use arrayadapt your compiler should have proper support for C99's exact-width integer types (defined in stdint.h). On performance: Any decent compiler should be able to strip away the arrayadapt extras completely. On my systems (tested on gcc 4.5 and 4.6) there is no trace left of it in the resulting assembly. No function calls, no classes, no nothing. All files in this repository (https://github.com/Dunkelschorsch/arrayadapt) are licensed under the BSD license. See the LICENSE file.
About
An adapter-class for MATLAB's mxArrays
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published