NAME
PDL::CCS::Utils - Low-level utilities for compressed storage sparse PDLs
SYNOPSIS
use PDL;
use PDL::CCS::Utils;
##---------------------------------------------------------------------
## ... stuff happens
FUNCTIONS
Non-missing Value Counts
nnz
Signature: (a(N); int+ [o]nnz())
Get number of non-zero values in a PDL $a(); For 1d PDLs, should be equivalent to:
$nnz = nelem(which($a!=0));
For k>1 dimensional PDLs, projects via number of nonzero elements to N-1 dimensions by computing the number of nonzero elements along the the 1st dimension.
nnz does not process bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
nnza
Signature: (a(N); eps(); int+ [o]nnz())
Like nnz() using tolerance constant $eps(). For 1d PDLs, should be equivalent to:
$nnz = nelem(which(!$a->approx(0,$eps)));
nnza does not process bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Encoding Utilities
ccs_encode_pointers
Signature: (int ix(Nnz); int N(); int [o]ptr(Nplus1); int [o]ixix(Nnz))
General CCS encoding utility.
Get a compressed storage "pointer" vector $ptr for a dimension of size $N with non-missing values at indices $ix. Also returns a vector $ixix() which may be used as an index for $ix() to align its elements with $ptr() along the compressed dimension.
The induced vector $ix->index($ixix) is guaranteed to be stably sorted along dimension $N():
\forall $i,$j with 1 <= $i < $j <= $Nnz :
$ix->index($ixix)->at($i) < $ix->index($ixix)->at($j) ##-- primary sort on $ix()
or
$ixix->at($i) < $ixix->at($j) ##-- ... stable
ccs_encode_pointers does not process bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
Decoding Utilities
ccs_decode_pointer
Signature: (int ptr(Nplus1); int proj(Nproj); int [o]projix(NnzProj); int [o]nzix(NnzProj))
General CCS decoding utility.
Project indices $proj() from a compressed storage "pointer" vecotr $proj(). If unspecified, $proj() defaults to:
sequence($ptr->dim(0))
ccs_decode_pointer does not process bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
ccs_dump_which
Signature: (int which(Ndims,Nnz); SV *HANDLE; char *fmt; char *fsep; char *rsep)
Print a text dump of an index PDL to the filehandle HANDLE
, which default to STDUT
. $fmt
is a printf() format to use for output, which defaults to "%d". $fsep
and $rsep
are field-and record separators, which default to a single space and $/
, respectively.
ccs_dump_which does not process bad values. It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
ACKNOWLEDGEMENTS
Perl by Larry Wall.
PDL by Karl Glazebrook, Tuomas J. Lukka, Christian Soeller, and others.
KNOWN BUGS
Probably many.
AUTHOR
Bryan Jurish <moocow@cpan.org>
Copyright Policy
Copyright (C) 2007-2013, Bryan Jurish. All rights reserved.
This package is free software, and entirely without warranty. You may redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
perl(1), PDL(3perl)