AI-MaxEntropy
view release on metacpan or search on metacpan
AI-MaxEntropy.xs view on Meta::CPAN
/**************************************************************************
* XS of AI:MaxEntropy
* -> by Laye Suen
**************************************************************************/
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
/* Macros for debugging */
/* uncomment the line below to enable tracing and timing */
/*#define __ENABLE_TRACING__*/
#ifdef __ENABLE_TRACING__
#include "time.h"
#define TRACE(msg) \
printf(_fn); printf(": "); printf(msg); \
printf(": %0.10f s\n", 1.0 * (clock() - _t) / CLOCKS_PER_SEC); \
fflush(stdout); _t = clock()
#define dTRACE(fn) clock_t _t = clock(); char* _fn = fn
#else
#define TRACE(msg)
#define dTRACE
#endif
/* Other macros */
#define hvref_fetch(hvref, key) \
hv_fetch((HV*)SvRV(hvref), key, strlen(key), 0)
#define hvref_exists(hvref, key) \
hv_exists((HV*)SvRV(hvref), key, strlen(key))
#define hvref_store(hvref, key, value) \
hv_store((HV*)SvRV(hvref), key, strlen(key), value, 0)
#define hvref_delete(hvref, key) \
hv_delete((HV*)SvRV(hvref), key, strlen(key), G_DISCARD)
/* internal structures */
struct samples_t {
int s_num;
int* x_len;
int** x;
int* y;
double* w;
};
struct f_map_t {
int y_num;
int** lambda_idx;
};
/**************************************************************************
* EXPORTED XSUBS
**************************************************************************/
MODULE = AI::MaxEntropy PACKAGE = AI::MaxEntropy
void
_neg_log_likelihood(lambda_in, step, self, OUTLIST SV* f, OUTLIST SV* g)
AV* lambda_in
SV* step
SV* self
PREINIT:
dTRACE("_neg_log_likelihood");
/* fetch the pre-cached samples and f_map */
( run in 1.135 second using v1.01-cache-2.11-cpan-8450f2e95f3 )