Data-NDArray-Shared
view release on metacpan or search on metacpan
RETVAL = newRV_noinc((SV *)av);
}
OUTPUT:
RETVAL
void
shape(self)
SV *self
PREINIT:
EXTRACT(self);
PPCODE:
{
uint64_t snap[NDA_MAX_DIMS]; uint32_t ndim, d;
/* Snapshot ndim+shape under the read lock: reshape mutates them under
* the write lock, so an unlocked read could tear (a new ndim with a
* stale shape[]). Copy out, unlock, then build the SVs. */
nda_rwlock_rdlock(h);
ndim = h->hdr->ndim;
if (ndim > NDA_MAX_DIMS) ndim = NDA_MAX_DIMS; /* clamp a peer-corrupted ndim */
for (d = 0; d < ndim; d++) snap[d] = (uint64_t)h->hdr->shape[d];
nda_rwlock_rdunlock(h);
EXTEND(SP, (SSize_t)ndim);
for (d = 0; d < ndim; d++)
PUSHs(sv_2mortal(newSVuv((UV)snap[d])));
}
void
strides(self)
SV *self
PREINIT:
EXTRACT(self);
PPCODE:
{
uint64_t snap[NDA_MAX_DIMS]; uint32_t ndim, d;
/* Snapshot ndim+strides under the read lock (see shape): reshape mutates
* them under the write lock; an unlocked read could tear. */
nda_rwlock_rdlock(h);
ndim = h->hdr->ndim;
if (ndim > NDA_MAX_DIMS) ndim = NDA_MAX_DIMS; /* clamp a peer-corrupted ndim */
for (d = 0; d < ndim; d++) snap[d] = (uint64_t)h->hdr->strides[d];
nda_rwlock_rdunlock(h);
EXTEND(SP, (SSize_t)ndim);
( run in 0.617 second using v1.01-cache-2.11-cpan-92ad3014f07 )