Math-SimpleHisto-XS
view release on metacpan or search on metacpan
CODE:
RETVAL = self->nfills;
OUTPUT: RETVAL
void
all_bin_contents(self)
simple_histo_1d* self
PREINIT:
SV* rv;
PPCODE:
rv = histo_data_av(aTHX_ self);
XPUSHs(sv_2mortal(rv));
void
set_all_bin_contents(self, new_data)
simple_histo_1d* self
AV* new_data
PREINIT:
unsigned int n, i;
double* data;
CODE:
HS_ASSERT_BIN_RANGE(self, ibin);
RETVAL = self->data[ibin];
OUTPUT: RETVAL
void
set_bin_content(self, ibin, content)
simple_histo_1d* self
unsigned int ibin
double content
PPCODE:
/* Would be nicer in the API, but again, this is faster. */
HS_ASSERT_BIN_RANGE(self, ibin);
HS_INVALIDATE_CUMULATIVE(self);
self->total += content - self->data[ibin];
self->data[ibin] = content;
void
set_underflow(self, content)
simple_histo_1d* self
double content
PPCODE:
/* This doesn't invalidate the INTERNAL cumulative histo */
self->underflow = content;
void
set_overflow(self, content)
simple_histo_1d* self
double content
PPCODE:
/* This doesn't invalidate the INTERNAL cumulative histo */
self->overflow = content;
void
set_nfills(self, nfills)
simple_histo_1d* self
unsigned int nfills
PPCODE:
/* This doesn't invalidate the INTERNAL cumulative histo */
self->nfills = nfills;
#void
#binary_dump(self)
# simple_histo_1d* self
# PREINIT:
# char* out;
# SV* outSv;
# double* tmp;
# unsigned int size;
# PPCODE:
# size = sizeof(simple_histo_1d) + sizeof(double)*self->nbins;
# outSv = newSVpvs("");
# SvGROW(outSv, size+1);
# printf(" %u\n", SvLEN(outSv));
# out = SvPVX(outSv);
# SvLEN_set(outSv, size);
# printf("%u\n", SvLEN(outSv));
# /*Newx(out, size+1, char);*/
# tmp = self->data;
# self->data = NULL;
rand(self, ...)
simple_histo_1d* self
PREINIT:
double rndval;
double retval;
SV* rngsv;
Math__SimpleHisto__XS__RNG rng;
unsigned int ibin;
PREINIT:
simple_histo_1d* cum_hist;
PPCODE:
if (items > 1) {
rngsv = ST(1);
}
else {
rngsv = get_sv("Math::SimpleHisto::XS::RNG::Gen", 0);
if (rngsv == 0) {
croak("Cannot find default random number generator!");
}
}
if (sv_derived_from(rngsv, "Math::SimpleHisto::XS::RNG")) {
}
XPUSHs(sv_2mortal(newSVnv(retval)));
void
_get_info(self)
simple_histo_1d* self
PREINIT:
SV* data_ary;
SV* bins_ary;
PPCODE:
/* min, max, nbins, nfills, overflow, underflow, dataref, binsref*/
EXTEND(SP, 8);
mPUSHn(self->min);
mPUSHn(self->max);
mPUSHu(self->nbins);
mPUSHu(self->nfills);
mPUSHn(self->overflow);
mPUSHn(self->underflow);
data_ary = histo_data_av(aTHX_ self);
XPUSHs(sv_2mortal(data_ary));
void
bin_centers(self)
simple_histo_1d* self
PREINIT:
AV* av;
SV* rv;
int i, n;
double x;
PPCODE:
av = newAV();
rv = (SV*)newRV((SV*)av);
SvREFCNT_dec(av);
n = self->nbins;
av_fill(av, n-1);
if (self->bins == NULL) {
double binsize = self->binsize;
x = self->min + 0.5*binsize;
for (i = 0; i < n; ++i) {
av_store(av, i, newSVnv(x));
OUTPUT: RETVAL
void
bin_lower_boundaries(self)
simple_histo_1d* self
PREINIT:
AV* av;
SV* rv;
int i, n;
PPCODE:
/* inlines HS_BIN_LOWER_BOUNDARY somewhat for unrolling */
av = newAV();
rv = (SV*)newRV((SV*)av);
SvREFCNT_dec(av);
n = self->nbins;
av_fill(av, n-1);
if (self->bins == NULL) {
double binsize = self->binsize;
double x = self->min;
for (i = 0; i < n; ++i) {
void
bin_upper_boundaries(self)
simple_histo_1d* self
PREINIT:
AV* av;
SV* rv;
int i, n;
double x, binsize;
PPCODE:
/* inlines HS_BIN_UPPER_BOUNDARY somewhat for unrolling */
av = newAV();
rv = (SV*)newRV((SV*)av);
SvREFCNT_dec(av);
n = self->nbins;
av_fill(av, n-1);
if (self->bins == NULL) {
binsize = self->binsize;
x = self->min;
for (i = 0; i < n; ++i) {
const-xs.inc view on Meta::CPAN
dTARGET;
#endif
STRLEN len;
int type;
IV iv;
/* NV nv; Uncomment this if you need to return NVs */
/* const char *pv; Uncomment this if you need to return PVs */
INPUT:
SV * sv;
const char * s = SvPV(sv, len);
PPCODE:
/* Change this to constant(aTHX_ s, len, &iv, &nv);
if you need to return both NVs and IVs */
type = constant(aTHX_ s, len, &iv);
/* Return 1 or 2 items. First is error message, or undef if no error.
Second, if present, is found value */
switch (type) {
case PERL_constant_NOTFOUND:
sv =
sv_2mortal(newSVpvf("%s is not a valid Math::SimpleHisto::XS macro", s));
PUSHs(sv);
( run in 0.921 second using v1.01-cache-2.11-cpan-5511b514fd6 )