Algorithm-PageRank-XS
view release on metacpan or search on metacpan
#define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#define NEED_newRV_noinc
#define NEED_sv_2pv_flags
#define NEED_vnewSVpvf
#define NEED_warner
#include "ppport.h"
#define MAGIC 1
#ifndef INFINITY
# ifdef HUGE_VAL
# define INFINITY ((NV) HUGE_VAL)
# else /* HUGE_VAL */
# define INFINITY (NV_MAX*NV_MAX)
# endif /* HUGE_VAL */
#endif /* INFINITY */
#define MORTALCOPY(sv) sv_2mortal(newSVsv(sv))
#define MAX_SIZE ((size_t) -1)
/* Workaround for older perls without packWARN */
#ifndef packWARN
# define packWARN(a) (a)
#endif
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <float.h>
#include "table.h"
#include "pagerank.h"
typedef struct pagerank {
Table * main_table;
HV * dim_map;
HV * rev_map;
size_t num_elements;
float alpha;
size_t max_tries;
float convergence;
} *pagerank;
typedef Table TableRef;
/* Duplicate from perl source (since it's not exported unfortunately) */
static bool my_isa_lookup(pTHX_ HV *stash, const char *name, HV* name_stash,
int len, int level) {
AV* av;
GV* gv;
GV** gvp;
HV* hv = Nullhv;
SV* subgen = Nullsv;
/* A stash/class can go by many names (ie. User == main::User), so
we compare the stash itself just in case */
if ((name_stash && stash == name_stash) ||
strEQ(HvNAME(stash), name) ||
strEQ(name, "UNIVERSAL")) return TRUE;
( run in 0.927 second using v1.01-cache-2.11-cpan-39bf76dae61 )