Functions |
static mxArray * | vlmxCreatePlainScalar (double x) |
| Create a MATLAB array which is a plain scalar.
|
static mxArray * | vlmxCreateArrayFromVlArray (VlArray const *x) |
| Create a MATLAB array from a VlArray.
|
static VlArray * | vlmxEnvelopeArrayInVlArray (VlArray *v, mxArray *x) |
| Envelope a MATLAB array in a VlArray instance.
|
static int | vlmxCompareStringsI (const char *s1, const char *s2) |
| Case insensitive string comparison.
|
static int | vlmxCompareToStringI (mxArray const *array, char const *string) |
| Case insensitive string comparison with array.
|
static int | vlmxIsEqualToStringI (mxArray const *array, char const *string) |
| Case insensitive string equality test with array.
|
static int | vlmxNextOption (mxArray const *args[], int nargs, vlmxOption const *options, int *next, mxArray const **optarg) |
| Parse the next option.
|
static VlEnumerator * | vlmxDecodeEnumeration (mxArray const *name_array, VlEnumerator const *enumeration, vl_bool caseInsensitive) |
| Get an emumeration member by name.
|
|
vl_bool | vlmxIsOfClass (mxArray const *array, mxClassID classId) |
| Check if a MATLAB array is of a prescribed class.
|
vl_bool | vlmxIsReal (mxArray const *array) |
| Check if a MATLAB array is real.
|
|
vl_bool | vlmxIsScalar (mxArray const *array) |
| Check if a MATLAB array is scalar.
|
static vl_bool | vlmxIsVector (mxArray const *array, vl_index numElements) |
| Check if a MATLAB array is a vector.
|
static vl_bool | vlmxIsMatrix (mxArray const *array, vl_index M, vl_index N) |
| Check if a MATLAB array is a matrix.
|
static vl_bool | vlmxIsArray (mxArray const *array, vl_index numDimensions, vl_index *dimensions) |
| Check if the MATLAB array has the specified dimensions.
|
|
vl_bool | vlmxIsPlain (mxArray const *array) |
| Check if a MATLAB array is plain.
|
vl_bool | vlmxIsPlainScalar (mxArray const *array) |
| Check if a MATLAB array is plain scalar.
|
vl_bool | vlmxIsPlainVector (mxArray const *array, vl_index numElements) |
| Check if a MATLAB array is a plain vector.
|
vl_bool | vlmxIsPlainMatrix (mxArray const *array, vl_index M, vl_index N) |
| Check if a MATLAB array is a plain matrix.
|
static int | vlmxIsString (const mxArray *array, vl_index length) |
| Check if the array is a string.
|
- Author:
- Andrea Vedaldi
This header file provides helper functions for writing MATLAB MEX files.
VLFeat environment
When the VLFeat DLL is linked to a MATLAB MEX files, at run time the MEX file must configure VLFeat to use MATLAB memory allocation and logging functions. This can be obtained by calling the macro VL_USE_MATLAB_ENV as the first line of each MEX file which is linked to the VLFeat DLL.
Array tests
MATLAB supports a variety of array types. Most MEX file arguments are restricted to a few types and must be properly checked at run time. mexutils.h provides some helper functions to make it simpler to check such arguments. MATLAB basic array types are:
- Numeric array:
mxDOUBLE_CLASS
, mxSINGLE_CLASS
, mxINT8_CLASS
, mxUINT8_CLASS
, mxINT16_CLASS
, mxUINT16_CLASS
, mxINT32_CLASS
, mxUINT32_CLASS
. Moreover:
- all such types have a real component
- all such types may have a imaginary component
mxDOUBLE_LCASS
arrays with two dimensions can be sparse.
- Logical array (
mxLOGICAL_CLASS
).
- Character array (
mxCHAR_CLASS
).
The other MATLAB array types are:
- Struct array (
mxSTRUCT_CLASS
).
- Cell array (
mxCELL_CLASS
).
- Custom class array (
mxCLASS_CLASS
).
- Unkown type array (
mxUNKNOWN_CLASS
).
VLFeat defines a number of common classes of arrays and corresponding tests.
- Scalar array is a non-sparse array with exactly one element. Note that the array may have an arbitrary number of dimensions, and be of any numeric or other type. All dimensions are singleton (which is implied by having exactly one element). Use vlmxIsScalar to test if an array is scalar.
- Vector array is a non-sparse array which is either empty (empty vector) or has at most one non-singleton dimension. The array can be of any numeric or other type. The elements of such a MATLAB array are stored as a plain C array with a number of elements equal to the number of elements in the array (obtained with
mxGetNumberOfElements
). Use vlmxIsVector to test whether an array is a vector.
- Matrix array is a non-sparse array for which all dimensions beyond the first two are singleton, or a non-sparse array which is empty and for which at least one of the first two dimensions is zero. The array can be of any numeric or other type. The non-singleton dimensions can be zero (empty matrix), one, or more. The element of such a MATLAB array are stored as a C array in column major order and its dimensions can be obtained by
mxGetM
and mxGetN
. Use vlmxIsMatrix to test if an array is a matrix.
- Real array is a numeric array (as for
mxIsNumeric
) without a complex component. Use vlmxIsReal to check if an array is real.
- Use vlmxIsOfClass to check if an array is of a prescribed (storage) class, such as
mxDOUBLE_CLASS
.
Parsing options
It is common to pass optional arguments to a MEX file as option type-value pairs. Here type is a string identifying the option and value is a MATLAB array specifing its value. The function vlmxNextOption can be used to simplify parsing a list of such arguments (similar to UNIX getopt
). The functions vlmxError and vlmxWarning are shortcuts to specify VLFeat formatted errors.
static int vlmxNextOption |
( |
mxArray const * |
args[], |
|
|
int |
nargs, |
|
|
vlmxOption const * |
options, |
|
|
int * |
next, |
|
|
mxArray const ** |
optarg |
|
) |
| |
|
static |
- Parameters:
-
args | MEX argument array. |
nargs | MEX argument array length. |
options | List of option definitions. |
next | Pointer to the next option (input and output). |
optarg | Pointer to the option optional argument (output). |
- Returns:
- the code of the next option, or -1 if there are no more options.
The function parses the array args for options. args is expected to be a sequence alternating option names and option values, in the form of nargs instances of mxArray
. The function then scans the option starting at position next in the array. The option name is matched (case insensitive) to the table of options options, a pointer to the option value is stored in optarg, next is advanced to the next option, and the option code is returned.
The function is typically used in a loop to parse all the available options. next is initialized to zero, and then the function is called until the special code -1 is returned.
If the option name cannot be matched to the available options, either because the option name is not a string array or because the name is unknown, the function exits the MEX file with an error.