PDLA

 view release on metacpan or  search on metacpan

Basic/Core/Core.xs  view on Meta::CPAN

    pdl_set(PDLA_REPRP(x), x->datatype, pos, x->dims,
        (PDLA_VAFFOK(x) ? x->vafftrans->incs : x->dimincs), PDLA_REPROFFS(x),
	x->ndims,value);
    if (PDLA_VAFFOK(x))
       pdl_vaffinechanged(x, PDLA_PARENTDATACHANGED);
    else
       pdl_changed( x , PDLA_PARENTDATACHANGED , 0 );

BOOT:

   /* Initialize structure of pointers to core C routines */

   PDLA.Version     = PDLA_CORE_VERSION;
   PDLA.SvPDLAV      = SvPDLAV;
   PDLA.SetSV_PDLA   = SetSV_PDLA;
   PDLA.create      = pdl_create;
   PDLA.pdlnew      = pdl_external_new;
   PDLA.tmp         = pdl_external_tmp;
   PDLA.destroy     = pdl_destroy;
   PDLA.null        = pdl_null;
   PDLA.copy        = pdl_copy;
   PDLA.hard_copy   = pdl_hard_copy;
   PDLA.converttype = pdl_converttype;
   PDLA.twod        = pdl_twod;
   PDLA.smalloc     = pdl_malloc;
   PDLA.howbig      = pdl_howbig;
   PDLA.packdims    = pdl_packdims;
   PDLA.unpackdims  = pdl_unpackdims;
   PDLA.setdims     = pdl_setdims;
   PDLA.grow        = pdl_grow;
   PDLA.flushcache  = NULL;
   PDLA.reallocdims = pdl_reallocdims;
   PDLA.reallocthreadids = pdl_reallocthreadids;
   PDLA.resize_defaultincs = pdl_resize_defaultincs;
   PDLA.get_threadoffsp = pdl_get_threadoffsp;
   PDLA.thread_copy = pdl_thread_copy;
   PDLA.clearthreadstruct = pdl_clearthreadstruct;
   PDLA.initthreadstruct = pdl_initthreadstruct;
   PDLA.startthreadloop = pdl_startthreadloop;
   PDLA.iterthreadloop = pdl_iterthreadloop;
   PDLA.freethreadloop = pdl_freethreadloop;
   PDLA.thread_create_parameter = pdl_thread_create_parameter;
   PDLA.add_deletedata_magic = pdl_add_deletedata_magic;

   PDLA.setdims_careful = pdl_setdims_careful;
   PDLA.put_offs = pdl_put_offs;
   PDLA.get_offs = pdl_get_offs;
   PDLA.get = pdl_get;
   PDLA.set_trans_childtrans = pdl_set_trans_childtrans;
   PDLA.set_trans_parenttrans = pdl_set_trans_parenttrans;

   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;
   PDLA.get_pdl_badvalue = pdl_get_pdl_badvalue;
#include "pdlbadvalinit.c"
#endif
   /*
      "Publish" pointer to this structure in perl variable for use
       by other modules
   */
   sv_setiv(get_sv("PDLA::SHARE",TRUE|GV_ADDMULTI), PTR2IV(&PDLA));

# make piddle belonging to 'class' and of type 'type'
# from avref 'array_ref' which is checked for being
# rectangular first

SV*
pdl_avref(array_ref, class, type)
     SV* array_ref
     char* class
     int type
  PREINIT:
     AV *dims, *av;
     int i, depth;
     int datalevel = -1;
     SV* psv;
     pdl* p;
  CODE:
     /* make a piddle from a Perl array ref */

     if (!SvROK(array_ref))
       croak("pdl_avref: not a reference");


     if (SvTYPE(SvRV(array_ref)) != SVt_PVAV)
       croak("pdl_avref: not an array reference");

     // Expand the array ref to a list, and allocate a Perl list to hold the dimlist
     av = (AV *) SvRV(array_ref);
     dims = (AV *) sv_2mortal( (SV *) newAV());

     av_store(dims,0,newSViv((IV) av_len(av)+1));

     /* even if we contain nothing depth is one */
     depth = 1 + av_ndcheck(av,dims,0,&datalevel);

     /* printf("will make type %s\n",class); */
     /*
	at this stage start making a piddle and populate it with
	values from the array (which has already been checked in av_check)
     */
     if (strcmp(class,"PDLA") == 0) {
        p = pdl_from_array(av,dims,type,NULL); /* populate with data */



( run in 1.247 second using v1.01-cache-2.11-cpan-39bf76dae61 )