include/lwpr_mem.h File Reference

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.

Detailed Description

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.


Function Documentation

int lwpr_mem_alloc_model ( LWPR_Model model,
int  nIn,
int  nOut,
int  storeRFS 
)

Allocates memory for internal variables of a LWPR model structure.

Parameters:
[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
Returns:
  • 1 in case of succes
  • 0 in case of failure

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.

See also:
lwpr_init_model, lwpr_free_model
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.

Parameters:
[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)
Returns:
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be allocated).
int lwpr_mem_alloc_sub ( LWPR_SubModel sub,
int  storeRFS 
)

Allocates memory for internal variables of a LWPR submodel structure.

Parameters:
[in,out] sub Pointer to an existing LWPR_SubModel structure
[in] storeRFS Expected number of receptive fields
Returns:
  • 1 in case of succes
  • 0 in case of failure

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.

Parameters:
[in,out] ws Pointer to a LWPR_Workspace structure (must already be allocated).
[in] nIn Input dimensionality of the LWPR model
Returns:
  • 1 in case of succes
  • 0 in case of failure
void lwpr_mem_free_rf ( LWPR_ReceptiveField RF  ) 

Disposes the memory for the internal variables of a receptive field.

Parameters:
[in,out] RF Pointer to a receptive field structure.

Note that this function does not dispose the LWPR_ReceptiveField structure itself.

See also:
lwpr_free_model
void lwpr_mem_free_ws ( LWPR_Workspace ws  ) 

Disposes the internal memory for an internally used "workspace".

Parameters:
[in,out] ws Pointer to a LWPR_Workspace structure.

Note that this function does not dispose the LWPR_Workspace structure itself.

See also:
lwpr_free_model
int lwpr_mem_realloc_rf ( LWPR_ReceptiveField RF,
int  nRegStore 
)

Re-allocates memory for the PLS-related variables of a receptive field.

Parameters:
[in,out] RF Pointer to a valid receptive field structure.
[in] nRegStore Number of PLS axes that can be stored.
Returns:
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be allocated).

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.

Generated on Thu Feb 9 08:18:35 2012 for LWPR Library by  doxygen 1.6.3