Prototypes for auxiliary LWPR routines that handle memory allocation and disposition. More...
#include <mex.h>
Go to the source code of this file.
Defines | |
#define | LWPR_MALLOC(s) mxMalloc(s) |
Standard malloc, or mxMalloc if compiling MEX-files. | |
#define | LWPR_CALLOC(n, s) mxCalloc(n,s) |
Standard calloc, or mxCalloc if compiling MEX-files. | |
#define | LWPR_REALLOC(p, s) mxRealloc(p,s) |
Standard realloc, or mxRealloc if compiling MEX-files. | |
#define | LWPR_FREE(p) mxFree(p) |
Standard free, or mxFree if compiling MEX-files. | |
Functions | |
int | lwpr_mem_alloc_rf (LWPR_ReceptiveField *RF, const LWPR_Model *model, int nReg, int nRegStore) |
Allocates memory for the internal variables of a receptive field. | |
int | lwpr_mem_realloc_rf (LWPR_ReceptiveField *RF, int nRegStore) |
Re-allocates memory for the PLS-related variables of a receptive field. | |
void | lwpr_mem_free_rf (LWPR_ReceptiveField *RF) |
Disposes the memory for the internal variables of a receptive field. | |
int | lwpr_mem_alloc_ws (LWPR_Workspace *ws, int nIn) |
Allocates memory for internal variables of a LWPR workspace structure. | |
void | lwpr_mem_free_ws (LWPR_Workspace *ws) |
Disposes the internal memory for an internally used "workspace". | |
int | lwpr_mem_alloc_model (LWPR_Model *model, int nIn, int nOut, int storeRFS) |
Allocates memory for internal variables of a LWPR model structure. | |
int | lwpr_mem_alloc_sub (LWPR_SubModel *sub, int storeRFS) |
Allocates memory for internal variables of a LWPR submodel structure. |
Prototypes for auxiliary LWPR routines that handle memory allocation and disposition.
When compiling the library for usage within MEX-files, it is important to use Matlab's memory management, because otherwise memory leaks may occur. The macros LWPR_MALLOC(), LWPR_CALLOC(), LWPR_REALLOC(), and LWPR_FREE() handle everything automatically.
int lwpr_mem_alloc_model | ( | LWPR_Model * | model, | |
int | nIn, | |||
int | nOut, | |||
int | storeRFS | |||
) |
Allocates memory for internal variables of a LWPR model structure.
[in,out] | model | Pointer to an existing LWPR_Model structure |
[in] | nIn | Input dimensionality of the LWPR model |
[in] | nOut | Output dimensionality of the LWPR model |
[in] | storeRFS | Expected number of receptive fields per output dimension |
This function also allocates space for workspaces (one per thread) and submodels (one per output dimension), the latter by calling lwpr_mem_alloc_sub().
Note that this function does not allocate the LWPR_Workspace structure itself.
int lwpr_mem_alloc_rf | ( | LWPR_ReceptiveField * | RF, | |
const LWPR_Model * | model, | |||
int | nReg, | |||
int | nRegStore | |||
) |
Allocates memory for the internal variables of a receptive field.
[in,out] | RF | Pointer to a receptive field structure (must already be allocated). |
[in] | model | Pointer to a valid LWPR model structure. |
[in] | nReg | Initial number of PLS regression axes |
[in] | nRegStore | Number of PLS axes that can initially be stored (>= nReg) |
int lwpr_mem_alloc_sub | ( | LWPR_SubModel * | sub, | |
int | storeRFS | |||
) |
Allocates memory for internal variables of a LWPR submodel structure.
[in,out] | sub | Pointer to an existing LWPR_SubModel structure |
[in] | storeRFS | Expected number of receptive fields |
Note that storeRFS determines only the number of pointers, that is, this function does not allocate any receptive field by itself.
int lwpr_mem_alloc_ws | ( | LWPR_Workspace * | ws, | |
int | nIn | |||
) |
Allocates memory for internal variables of a LWPR workspace structure.
[in,out] | ws | Pointer to a LWPR_Workspace structure (must already be allocated). |
[in] | nIn | Input dimensionality of the LWPR model |
void lwpr_mem_free_rf | ( | LWPR_ReceptiveField * | RF | ) |
Disposes the memory for the internal variables of a receptive field.
[in,out] | RF | Pointer to a receptive field structure. |
Note that this function does not dispose the LWPR_ReceptiveField structure itself.
void lwpr_mem_free_ws | ( | LWPR_Workspace * | ws | ) |
Disposes the internal memory for an internally used "workspace".
[in,out] | ws | Pointer to a LWPR_Workspace structure. |
Note that this function does not dispose the LWPR_Workspace structure itself.
int lwpr_mem_realloc_rf | ( | LWPR_ReceptiveField * | RF, | |
int | nRegStore | |||
) |
Re-allocates memory for the PLS-related variables of a receptive field.
[in,out] | RF | Pointer to a valid receptive field structure. |
[in] | nRegStore | Number of PLS axes that can be stored. |
This function does NOT add a new PLS axis, but only creates the space for it. Note that in case of failure to do so, the receptive field is still fully functional.