view release on metacpan or search on metacpan
Basic/Bad/bad.pd view on Meta::CPAN
} # sub: check_badflag()
!NO!SUBS!
pp_addhdr <<'EOHDR';
static pdl* new_pdlscalar(int datatype)
{
pdl *p = PDLA->pdlnew();
PDLA->setdims (p, NULL, 0); /* set dims */
p->datatype = datatype; /* and data type */
PDLA->allocdata (p); /* allocate the data chunk */
return p;
}
EOHDR
use PDLA::Types;
my $ntypes = $#PDLA::Types::names;
my $str;
foreach my $i ( 0 .. $ntypes ) {
Basic/Core/Core.xs view on Meta::CPAN
PDLA.get_convertedpdl = pdl_get_convertedpdl;
PDLA.make_trans_mutual = pdl_make_trans_mutual;
PDLA.trans_mallocfreeproc = pdl_trans_mallocfreeproc;
PDLA.make_physical = pdl_make_physical;
PDLA.make_physdims = pdl_make_physdims;
PDLA.make_physvaffine = pdl_make_physvaffine;
PDLA.pdl_barf = pdl_barf;
PDLA.pdl_warn = pdl_warn;
PDLA.allocdata = pdl_allocdata;
PDLA.safe_indterm = pdl_safe_indterm;
PDLA.children_changesoon = pdl_children_changesoon;
PDLA.changed = pdl_changed;
PDLA.vaffinechanged = pdl_vaffinechanged;
PDLA.NaN_float = union_nan_float.f;
PDLA.NaN_double = union_nan_double.d;
#if BADVAL
PDLA.propagate_badflag = propagate_badflag;
PDLA.propagate_badvalue = propagate_badvalue;
Basic/Core/pdl.h.PL view on Meta::CPAN
#define PDLAMAX(a,b) ((a) > (b) ? (a) : (b))
/***************
* Some macros to guard against dataflow infinite recursion.
*/
#define DECL_RECURSE_GUARD static int __nrec=0;
#define START_RECURSE_GUARD __nrec++; if(__nrec > 1000) {__nrec=0; die("PDLA:Internal Error: data structure recursion limit exceeded (max 1000 levels)\n\tThis could mean that you have found an infinite-recursion error in PDLA, or\n\tthat you are buil...
#define ABORT_RECURSE_GUARD __nrec=0;
#define END_RECURSE_GUARD __nrec--;
#define PDLA_ENSURE_ALLOCATED(it) ( (void)((it->state & PDLA_ALLOCATED) || ((pdl_allocdata(it)),1)) )
#define PDLA_ENSURE_VAFFTRANS(it) \
( ((!it->vafftrans) || (it->vafftrans->ndims < it->ndims)) && \
(pdl_vafftrans_alloc(it),1) )
/* __PDLA_H */
#endif
!NO!SUBS!
Basic/Core/pdlapi.c view on Meta::CPAN
pdl *it;
it = pdl_null();
PDLA.converttypei_new(old,it,type);
if(it->datatype != type) { croak("FOOBAR! HELP!\n"); }
return it;
} else {
return old;
}
}
void pdl_allocdata(pdl *it) {
int i;
PDLA_Indx nvals=1;
SV *bar;
for(i=0; i<it->ndims; i++) {
nvals *= it->dims[i];
}
it->nvals = nvals;
PDLADEBUG_f(printf("pdl_allocdata %p, %"IND_FLAG", %d\n",(void*)it, it->nvals,
it->datatype));
pdl_grow(it,nvals);
PDLADEBUG_f(pdl_dump(it));
it->state |= PDLA_ALLOCATED;
}
/* Wrapper to pdl_create so that the pdl_new and pdl_tmp functions
can be stored in the Core struct and exported to external
Basic/Core/pdlapi.c view on Meta::CPAN
pdl *pdl_hard_copy(pdl *src) {
int i;
pdl *it = pdl_null();
it->state = 0;
pdl_make_physical(src); /* Wasteful XXX... should be lazier */
it->datatype = src->datatype;
pdl_setdims(it,src->dims,src->ndims);
pdl_allocdata(it);
/* null != [0] */
#ifdef ELIFSLEFJSEFSE
if(src->ndims == 1 && src->dims[0] == 0)
#else
if(src->state & PDLA_NOMYDIMS)
#endif
it->state |= PDLA_NOMYDIMS;
pdl_reallocthreadids(it,src->nthreadids);
Basic/Core/pdlapi.c view on Meta::CPAN
void pdl_resize_defaultincs(pdl *it) {
PDLA_Indx inc = 1;
int i=0;
for(i=0; i<it->ndims; i++) {
it->dimincs[i] = inc; inc *= it->dims[i];
}
it->nvals = inc;
it->state &= ~PDLA_ALLOCATED; /* Need to realloc when phys */
#ifdef DONT_OPTIMIZE
pdl_allocdata(it);
#endif
}
/* Init dims & incs - if *incs is NULL ignored (but space is always same for both) */
void pdl_setdims(pdl* it, PDLA_Indx * dims, int ndims) {
int i;
pdl_reallocdims(it,ndims);
Basic/Core/pdlapi.c view on Meta::CPAN
pdl_resize_defaultincs(it);
pdl_reallocthreadids(it,0); /* XXX Maybe trouble */
}
/* This is *not* careful! */
void pdl_setdims_careful(pdl *it)
{
pdl_resize_defaultincs(it);
#ifdef DONT_OPTIMIZE
pdl_allocdata(it);
#endif
pdl_reallocthreadids(it,0); /* XXX For now */
}
void pdl_print(pdl *it) {
#ifdef FOO
int i;
printf("PDLA %d: sv = %d, data = %d, datatype = %d, nvals = %d, ndims = %d\n",
(int)it, (int)(it->hash), (int)(it->data), it->datatype, it->nvals, it->ndims);
printf("Dims: ");
Basic/Core/pdlapi.c view on Meta::CPAN
DECL_RECURSE_GUARD;
PDLADEBUG_f(printf("Make_physical %p\n",(void*)it));
PDLA_CHKMAGIC(it);
START_RECURSE_GUARD;
if(it->state & PDLA_ALLOCATED && !(it->state & PDLA_ANYCHANGED)) {
goto mkphys_end;
}
if(!(it->state & PDLA_ANYCHANGED)) {
pdl_allocdata(it);
goto mkphys_end;
}
if(!it->trans) {
ABORT_RECURSE_GUARD;
die("PDLA Not physical but doesn't have parent");
}
#ifndef DONT_OPTIMIZE
#ifndef DONT_VAFFINE
if(it->trans->flags & PDLA_ITRANS_ISAFFINE) {
if(!PDLA_VAFFOK(it))
Basic/Core/pdlapi.c view on Meta::CPAN
* (!(it->state & PDLA_ALLOCATED) && vaffinepar)
* i.e. at least one of the parent piddles is a real vaffine
* CS
*/
if((!(it->state & PDLA_ALLOCATED) && vaffinepar) ||
it->state & PDLA_PARENTDIMSCHANGED ||
it->state & PDLA_PARENTREPRCHANGED) {
it->trans->vtable->redodims(it->trans);
}
if(!(it->state & PDLA_ALLOCATED)) {
pdl_allocdata(it);
}
/* Make parents physical first. XXX Needs more reasonable way */
/* Already done
* for(i=0; i<it->trans->vtable->nparents; i++) {
* pdl_make_physical(it->trans->pdls[i]);
* }
*/
/*
* We think we made them physical or physvaffine already...
* for(i=0; i<it->trans->vtable->npdls; i++) {
Basic/Core/pdlcore.c.PL view on Meta::CPAN
ndims = av_len(dims)+1;
pdims = (PDLA_Indx *) pdl_malloc( (ndims) * sizeof(*pdims) );
for (i=0; i<ndims; i++) {
pdims[i] = SvIV(*(av_fetch(dims, ndims-1-i, 0))); /* reverse order */
}
if (p == NULL)
p = pdl_new();
pdl_setdims (p, pdims, ndims);
p->datatype = type;
pdl_allocdata (p);
pdl_make_physical(p);
/* this one assigns the data */
{
/******
* Copy the undefval to fill empty spots in the piddle...
*/
SV *sv = get_sv("PDLA::undefval",0);
undefval = ((!sv) || (sv==&PL_sv_undef)) ? 0 : (PDLA_Anyval)SvNV(sv);
}
Basic/Core/pdlcore.h.PL view on Meta::CPAN
pdl* pdl_external_tmp();
pdl* pdl_create(int type);
void pdl_destroy(pdl *it);
void pdl_setdims(pdl* it, PDLA_Indx* dims, int ndims);
void pdl_reallocdims ( pdl *it,int ndims ); /* reallocate dims and incs */
void pdl_reallocthreadids ( pdl *it,int ndims ); /* reallocate threadids */
void pdl_resize_defaultincs ( pdl *it ); /* Make incs out of dims */
void pdl_unpackarray ( HV* hash, char *key, PDLA_Indx *dims, int ndims );
void pdl_print(pdl *it);
void pdl_dump(pdl *it);
void pdl_allocdata(pdl *it);
PDLA_Indx *pdl_get_threadoffsp(pdl_thread *thread); /* For pthreading */
void pdl_thread_copy(pdl_thread *from,pdl_thread *to);
void pdl_clearthreadstruct(pdl_thread *it);
void pdl_initthreadstruct(int nobl,pdl **pdls,PDLA_Indx *realdims,PDLA_Indx *creating,int npdls,
pdl_errorinfo *info,pdl_thread *thread,char *flags, int noPthreadFlag );
int pdl_startthreadloop(pdl_thread *thread,void (*func)(pdl_trans *),pdl_trans *);
int pdl_iterthreadloop(pdl_thread *thread,int which);
void pdl_freethreadloop(pdl_thread *thread);
void pdl_thread_create_parameter(pdl_thread *thread,int j,PDLA_Indx *dims,
Basic/Core/pdlcore.h.PL view on Meta::CPAN
void (*converttypei_new)(pdl *par,pdl *child,int type);
void (*trans_mallocfreeproc)(struct pdl_trans *tr);
void (*make_physical)(pdl *it);
void (*make_physdims)(pdl *it);
void (*pdl_barf) (const char* pat,...);
void (*pdl_warn) (const char* pat,...);
void (*make_physvaffine)(pdl *it);
void (*allocdata) (pdl *it);
PDLA_Indx (*safe_indterm)(PDLA_Indx dsz, PDLA_Indx at, char *file, int lineno);
float NaN_float;
double NaN_double;
!NO!SUBS!
# set up the qsort routines
# fortunately it looks like Types.pm.PL is processed before this
Basic/Gen/PP/PdlParObj.pm view on Meta::CPAN
}
sub do_resize {
my($this,$ind,$size) = @_;
my @c;my $index = 0;
for(@{$this->{IndObjs}}) {
push @c,$index if $_->name eq $ind; $index ++;
}
my $pdl = $this->get_nname;
return (join '',map {"$pdl->dims[$_] = $size;\n"} @c).
"PDLA->resize_defaultincs($pdl);PDLA->allocdata($pdl);".
$this->get_xsdatapdecl(undef,1);
}
sub do_pdlaccess {
my($this) = @_;
return '$PRIV(pdls['.$this->{Number}.'])';
}
sub do_pointeraccess {
Basic/Pod/API.pod view on Meta::CPAN
__DATA__
__C__
static pdl* new_pdl(int datatype, PDLA_Indx dims[], int ndims)
{
pdl *p = PDLA->pdlnew();
PDLA->setdims (p, dims, ndims); /* set dims */
p->datatype = datatype; /* and data type */
PDLA->allocdata (p); /* allocate the data chunk */
return p;
}
pdl* myfloatseq()
{
PDLA_Indx dims[] = {5,5,5};
pdl *p = new_pdl(PDLA_F,dims,3);
PDLA_Float *dataf = (PDLA_Float *) p->data;
PDLA_Indx i; /* dimensions might be 64bits */
Basic/Pod/API.pod view on Meta::CPAN
=item *
C<int howbig(int pdl_datatype)>
=item *
C<void add_deletedata_magic(pdl *p, void (*func)(pdl*, int), int param)>
=item *
C<void allocdata(pdl *p)>
=item *
C<void make_physical(pdl *p)>
=item *
C<void make_physdims(pdl *p)>
=item *
t/inline-with.t view on Meta::CPAN
SKIP: {
#use Inline 'INFO'; # use to generate lots of info
use_ok 'Inline', with => 'PDLA' or skip 'with PDLA failed', 3;
eval { Inline->bind(C => <<'EOF') };
static pdl* new_pdl(int datatype, PDLA_Indx dims[], int ndims)
{
pdl *p = PDLA->pdlnew();
PDLA->setdims (p, dims, ndims); /* set dims */
p->datatype = datatype; /* and data type */
PDLA->allocdata (p); /* allocate the data chunk */
return p;
}
pdl* myfloatseq()
{
PDLA_Indx dims[] = {5,5,5};
pdl *p = new_pdl(PDLA_F,dims,3);
PDLA_Float *dataf = (PDLA_Float *) p->data;
PDLA_Indx i; /* dimensions might be 64bits */