AI-NeuralNet-FastSOM
view release on metacpan or search on metacpan
* 'Z' is of course the number of NVs in the 'element' array.
*/
typedef struct {
SV *ref;
IV Z;
NV element;
} SOM_Vector;
/*
* SOM_Array : holds Y ptrs to SOM_Vector thingys
*
* should be allocated:
* sizeof(SOM_Array) + sizeof(SOM_Vector*)*(Y-1)
*
* 'ref' and 'vector' elements similar in functionality to the 'ref' and
* 'element' members, respectively, of the SOM_Vector struct.
*
* 'Y' is the number of SOM_Vector pointers in the 'vector' array.
*
* 'Z' is provided here only for propogation down the line in creating
* the SOM_Vectors.
*/
typedef struct {
SV *ref;
IV Y;
IV Z;
SOM_Vector *vector;
} SOM_Array;
/*
* SOM_Map : holds X ptrs to SOM_Array thingys
*
* should be allocated:
* sizeof(SOM_Map) + sizeof(SOM_Array*)*(X-1)
*
* 'ref' and 'array' are similar in functionality to the 'ref' and 'element'
* members, respectively, of the SOM_Vector struct.
*
* 'X' is the number of SOM_Array pointers in the 'array' array.
*
* 'Y' and 'Z' are provided here only for propagation down the line in
* creation of SOM_Array and SOM_Vector structs.
*/
typedef struct {
SV *ref;
IV X;
IV Y;
IV Z;
SOM_Array *array;
} SOM_Map;
/*
* SOM_Rect : holds a ptr to a single SOM_Map thingy
*
* should be allocated:
* sizeof(SOM_Rect)
*
* this struct is the main object.
*
* 'X', 'Y', and 'Z' are held here for progagation down to the structs
* that make up our grid map.
*
* '_R' = initial SOM radius
* '_Sigma0' = ???
* '_L0' = initial SOM learning rate
*
* 'output_dim' is kept from instantiation simply because the perl interface
* already provides access to it.
*/
typedef struct {
SV *ref;
IV X;
IV Y;
IV Z;
NV R;
NV Sigma0;
NV L0;
NV LAMBDA;
NV T;
int type;
SV *output_dim;
AV *labels;
SOM_Map *map;
} SOM_GENERIC;
typedef SOM_GENERIC SOM_Rect;
typedef SOM_GENERIC SOM_Torus;
typedef SOM_GENERIC SOM_Hexa;
enum SOMType {
SOMType_Hexa,
SOMType_Rect,
SOMType_Torus
};
typedef AV AV_SPECIAL;
#ifndef PERL_MAGIC_tied
#define PERL_MAGIC_tied 'P'
#endif
#ifndef Newx
#define Newx(ptr,nitems,type) New(0,ptr,nitems,type)
#endif
#ifndef Newxc
#define Newxc(ptr,nitems,type,cast) Newc(0,ptr,nitems,type,cast)
#endif
#ifndef Newxz
#define Newxz(ptr,nitems,type) Newz(0,ptr,nitems,type)
#endif
#ifndef PERL_UNUSED_VAR
#define PERL_UNUSED_VAR(x) ((void)x)
#endif
#define selfmg2iv(self,mg) SvIV(SvRV(SvTIED_obj((SV*)SvIV(SvRV(self)),mg)))
#define self2iv(self) SvIV(SvRV(self))
#define selfmagic(self) SvTIED_mg((SV*)SvRV(self), PERL_MAGIC_tied)
#define self2somptr(self,mg) INT2PTR(SOM_GENERIC*,selfmg2iv(self,mg))
#define tied2ptr(self) (INT2PTR(SOM_GENERIC*,SvIV(SvRV(self))))
( run in 1.043 second using v1.01-cache-2.11-cpan-140bd7fdf52 )