New upstream version 1.23.8
Laurent Baillet
5 years ago
11 | 11 | use PDL::CCS::Ops; |
12 | 12 | use strict; |
13 | 13 | |
14 | our $VERSION = '1.23.7'; ##-- update with perl-reversion from Perl::Version module | |
14 | our $VERSION = '1.23.8'; ##-- update with perl-reversion from Perl::Version module | |
15 | 15 | our @ISA = ('PDL::Exporter'); |
16 | 16 | our @ccs_binops = (qw(plus minus mult divide modulo power), |
17 | 17 | qw(gt ge lt le eq ne spaceship), |
8 | 8 | our %EXPORT_TAGS = (config=>['%ccsConfig'], Func=>\@Export, default=>\@EXPORT, all=>\@EXPORT_OK); |
9 | 9 | |
10 | 10 | %ccsConfig = ( |
11 | 'INDX_CTYPE' => 'PDL_Indx', | |
12 | 'INDX_FUNC' => 'indx', | |
13 | 'INDX_FUNCDEF' => '*ccs_indx = \\&PDL::indx; ##-- typecasting for CCS indices | |
14 | ', | |
15 | 'INDX_SIG' => 'indx', | |
16 | 'INDX_TYPEDEF' => 'typedef PDL_Indx CCS_Indx; /**< typedef for CCS indices */ | |
17 | ', | |
11 | 18 | 'INT_TYPE_CHRS' => [ |
12 | 19 | 'B', |
13 | 20 | 'S', |
16 | 23 | 'N', |
17 | 24 | 'Q' |
18 | 25 | ], |
19 | 'INDX_TYPEDEF' => 'typedef PDL_Indx CCS_Indx; /**< typedef for CCS indices */ | |
20 | ', | |
21 | 'USE_PDL_INDX' => 1, | |
22 | 'INDX_SIG' => 'indx', | |
23 | 'INDX_FUNCDEF' => '*ccs_indx = \\&PDL::indx; ##-- typecasting for CCS indices | |
24 | ', | |
25 | 26 | 'INT_TYPE_KEYS' => [ |
26 | 27 | 'PDL_B', |
27 | 28 | 'PDL_S', |
30 | 31 | 'PDL_IND', |
31 | 32 | 'PDL_LL' |
32 | 33 | ], |
33 | 'INDX_CTYPE' => 'PDL_Indx', | |
34 | 'INDX_FUNC' => 'indx' | |
34 | 'USE_PDL_INDX' => 1 | |
35 | 35 | ); |
36 | 36 | |
37 | 37 | *PDL::ccs_indx = *ccs_indx = \&PDL::indx; ##-- typecasting for CCS indices |
8 | 8 | use PDL; |
9 | 9 | use strict; |
10 | 10 | |
11 | our $VERSION = '1.23.7'; ##-- update with perl-reversion from Perl::Version module | |
11 | our $VERSION = '1.23.8'; ##-- update with perl-reversion from Perl::Version module | |
12 | 12 | our @ISA = ('PDL::Exporter'); |
13 | 13 | our @EXPORT_OK = |
14 | 14 | ( |
8 | 8 | use Carp qw(confess); |
9 | 9 | use strict; |
10 | 10 | |
11 | our $VERSION = '1.23.7'; | |
11 | our $VERSION = '1.23.8'; | |
12 | 12 | our @ISA = ('PDL::Exporter'); |
13 | 13 | our @EXPORT_OK = |
14 | 14 | ( |
98 | 98 | my ($magic,$pdims,$vdims,$flags,$iotype) = map {chomp;$_} @$hlines; |
99 | 99 | return { |
100 | 100 | magic=>$magic, |
101 | (defined($pdims) && $pdims ne '' ? (pdims=>pdl(ccs_indx,[split(' ',$pdims)])) : qw()), | |
102 | (defined($vdims) && $vdims ne '' ? (vdims=>pdl(ccs_indx,[split(' ',$vdims)])) : qw()), | |
101 | (defined($pdims) && $pdims ne '' ? (pdims=>pdl(ccs_indx(),[split(' ',$pdims)])) : qw()), | |
102 | (defined($vdims) && $vdims ne '' ? (vdims=>pdl(ccs_indx(),[split(' ',$vdims)])) : qw()), | |
103 | 103 | (defined($flags) && $flags ne '' ? (flags=>$flags) : qw()), |
104 | 104 | (defined($iotype) && $iotype ne '' ? (iotype=>$iotype) : qw()), ##-- added in v1.22.6 |
105 | 105 | }; |
9 | 9 | use Carp qw(confess); |
10 | 10 | use strict; |
11 | 11 | |
12 | our $VERSION = '1.23.7'; | |
12 | our $VERSION = '1.23.8'; | |
13 | 13 | our @ISA = ('PDL::Exporter'); |
14 | 14 | our @EXPORT_OK = |
15 | 15 | ( |
11 | 11 | use Carp qw(confess); |
12 | 12 | use strict; |
13 | 13 | |
14 | our $VERSION = '1.23.7'; | |
14 | our $VERSION = '1.23.8'; | |
15 | 15 | our @ISA = ('PDL::Exporter'); |
16 | 16 | our @EXPORT_OK = qw(ccs_writefraw ccs_readfraw ccs_mapfraw); |
17 | 17 | our %EXPORT_TAGS = |
205 | 205 | or confess("ccs_mapfraw(): failed to read header-file $hFile: $!"); |
206 | 206 | $header->{$_} //= $hdr->{$_} foreach (keys %$hdr); |
207 | 207 | } |
208 | $header->{pdims} = PDL->topdl(ccs_indx,$header->{pdims}) if (!ref($header->{pdims})); | |
208 | $header->{pdims} = PDL->topdl(ccs_indx(),$header->{pdims}) if (!ref($header->{pdims})); | |
209 | 209 | $header->{vdims} = $header->{pdims}->sequence if (!defined($header->{vdims})); |
210 | $header->{vdims} = PDL->topdl(ccs_indx,$header->{vdims}) if (!ref($header->{vdims})); | |
210 | $header->{vdims} = PDL->topdl(ccs_indx(),$header->{vdims}) if (!ref($header->{vdims})); | |
211 | 211 | |
212 | 212 | ##-- get component options |
213 | 213 | my %defaults = (map {($_=>$opts->{$_})} grep {exists($opts->{$_})} qw(Creat Trunc ReadOnly)); |
12 | 12 | use Carp qw(confess); |
13 | 13 | use strict; |
14 | 14 | |
15 | our $VERSION = '1.23.7'; | |
15 | our $VERSION = '1.23.8'; | |
16 | 16 | our @ISA = ('PDL::Exporter'); |
17 | 17 | our @EXPORT_OK = |
18 | 18 | ( |
193 | 193 | ##-- get nnz (per doc) |
194 | 194 | seek($fh,0,SEEK_SET) |
195 | 195 | or confess("ccs_readldac(): seek() failed for input file '$file': $!"); |
196 | my $nnz0 = PDL->rcols($fh, [0], { TYPES=>[ccs_indx], IGNORE=>qr{^\s*[^0-9]} }); | |
196 | my $nnz0 = PDL->rcols($fh, [0], { TYPES=>[ccs_indx()], IGNORE=>qr{^\s*[^0-9]} }); | |
197 | 197 | my $nnz = $nnz0->sum; |
198 | 198 | my $nlines = $nnz0->nelem; |
199 | 199 | undef($nnz0); |
200 | 200 | |
201 | 201 | ##-- allocate output pdls |
202 | my $ix = zeroes(ccs_indx, 2,$nnz); | |
202 | my $ix = zeroes(ccs_indx(), 2,$nnz); | |
203 | 203 | my $nz = zeroes($type, $nnz+1); |
204 | 204 | |
205 | 205 | ##-- process input |
12 | 12 | use Carp qw(confess); |
13 | 13 | use strict; |
14 | 14 | |
15 | our $VERSION = '1.23.7'; | |
15 | our $VERSION = '1.23.8'; | |
16 | 16 | our @ISA = ('PDL::Exporter'); |
17 | 17 | our @EXPORT_OK = |
18 | 18 | ( |
232 | 232 | my $nnz = pop(@dims); |
233 | 233 | |
234 | 234 | ##-- update ccs header if required |
235 | my $mmdims = pdl(ccs_indx,\@dims); | |
235 | my $mmdims = pdl(ccs_indx(),\@dims); | |
236 | 236 | if (defined($header->{pdims}) && ($header->{pdims}->nelem != $mmdims->nelem || !all($header->{pdims}==$mmdims))) { |
237 | 237 | $header->{pdims} = $mmdims; |
238 | 238 | $header->{vdims} = undef; |
11 | 11 | use Carp qw(confess); |
12 | 12 | use strict; |
13 | 13 | |
14 | our $VERSION = '1.23.7'; | |
14 | our $VERSION = '1.23.8'; | |
15 | 15 | our @ISA = ('PDL::Exporter'); |
16 | 16 | our @EXPORT_OK = |
17 | 17 | ( |
201 | 201 | |
202 | 202 | ##-- read input data: row-lengths |
203 | 203 | # int *number nonzeros in each row |
204 | my $plen = zeroes(ccs_indx, $m); | |
204 | my $plen = zeroes(ccs_indx(), $m); | |
205 | 205 | my ($i,$j,$blen,$tmp); |
206 | 206 | for ($i=0; $i < $m; $i=$j+1) { |
207 | 207 | $j = $i+$ioblock; |
209 | 209 | $blen = $ilen * (1+$j-$i); |
210 | 210 | read($fh,$buf,$blen)==$blen |
211 | 211 | or confess("ccs_rpetsc(): failed to read $blen bytes of length data from '$file': $!"); |
212 | ($tmp=$plen->slice("$i:$j")) .= pdl(ccs_indx, [unpack("($pack_int)*", $buf)]); | |
212 | ($tmp=$plen->slice("$i:$j")) .= pdl(ccs_indx(), [unpack("($pack_int)*", $buf)]); | |
213 | 213 | } |
214 | 214 | |
215 | 215 | ##-- setup index pdl |
216 | my $ix = zeroes(ccs_indx,2,$nnz); | |
216 | my $ix = zeroes(ccs_indx(),2,$nnz); | |
217 | 217 | $plen->rld($plen->sequence, $ix->slice("(0),")); |
218 | 218 | undef $plen; |
219 | 219 | |
225 | 225 | $blen = $ilen * (1+$j-$i); |
226 | 226 | read($fh,$buf,$blen)==$blen |
227 | 227 | or confess("ccs_rpetsc(): failed to read $blen bytes of column-index data from '$file': $!"); |
228 | ($tmp=$ix->slice("(1),$i:$j")) .= pdl(ccs_indx, [unpack("($pack_int)*", $buf)]); | |
228 | ($tmp=$ix->slice("(1),$i:$j")) .= pdl(ccs_indx(), [unpack("($pack_int)*", $buf)]); | |
229 | 229 | } |
230 | 230 | |
231 | 231 | ##-- read input data: nzvals |
0 | ||
1 | # | |
2 | # GENERATED WITH PDL::PP! Don't modify! | |
3 | # | |
4 | package PDL::CCS::MatrixOps; | |
5 | ||
6 | @EXPORT_OK = qw( PDL::PP ccs_matmult2d_sdd PDL::PP ccs_matmult2d_zdd PDL::PP ccs_vnorm ccs_vcos_zdd PDL::PP _ccs_vcos_zdd PDL::PP ccs_vcos_pzd ); | |
7 | %EXPORT_TAGS = (Func=>[@EXPORT_OK]); | |
8 | ||
9 | use PDL::Core; | |
10 | use PDL::Exporter; | |
11 | use DynaLoader; | |
12 | ||
13 | ||
14 | ||
15 | $PDL::CCS::MatrixOps::VERSION = 1.23.7; | |
16 | @ISA = ( 'PDL::Exporter','DynaLoader' ); | |
17 | push @PDL::Core::PP, __PACKAGE__; | |
18 | bootstrap PDL::CCS::MatrixOps $VERSION; | |
19 | ||
20 | ||
21 | ||
22 | ||
23 | ||
24 | #use PDL::CCS::Version; | |
25 | use strict; | |
26 | ||
27 | =pod | |
28 | ||
29 | =head1 NAME | |
30 | ||
31 | PDL::CCS::MatrixOps - Low-level matrix operations for compressed storage sparse PDLs | |
32 | ||
33 | =head1 SYNOPSIS | |
34 | ||
35 | use PDL; | |
36 | use PDL::CCS::MatrixOps; | |
37 | ||
38 | ##--------------------------------------------------------------------- | |
39 | ## ... stuff happens | |
40 | ||
41 | =cut | |
42 | ||
43 | ||
44 | ||
45 | ||
46 | ||
47 | ||
48 | ||
49 | =head1 FUNCTIONS | |
50 | ||
51 | ||
52 | ||
53 | =cut | |
54 | ||
55 | ||
56 | ||
57 | ||
58 | *ccs_indx = \&PDL::indx; ##-- typecasting for CCS indices | |
59 | ||
60 | ||
61 | ||
62 | ||
63 | =head2 ccs_matmult2d_sdd | |
64 | ||
65 | =for sig | |
66 | ||
67 | Signature: ( | |
68 | indx ixa(NdimsA,NnzA); nza(NnzA); missinga(); | |
69 | b(O,M); | |
70 | zc(O); | |
71 | [o]c(O,N) | |
72 | ) | |
73 | ||
74 | ||
75 | Two-dimensional matrix multiplication of a sparse index-encoded PDL | |
76 | $a() with a dense pdl $b(), with output to a dense pdl $c(). | |
77 | ||
78 | The sparse input PDL $a() should be passed here with 0th | |
79 | dimension "M" and 1st dimension "N", just as for the | |
80 | built-in PDL::Primitive::matmult(). | |
81 | ||
82 | "Missing" values in $a() are treated as $missinga(), which shouldn't | |
83 | be BAD or infinite, but otherwise ought to be handled correctly. | |
84 | The input pdl $zc() is used to pass the cached contribution of | |
85 | a $missinga()-row ("M") to an output column ("O"), i.e. | |
86 | ||
87 | $zc = ((zeroes($M,1)+$missinga) x $b)->flat; | |
88 | ||
89 | $SIZE(Ndimsa) is assumed to be 2. | |
90 | ||
91 | ||
92 | =for bad | |
93 | ||
94 | ccs_matmult2d_sdd does not process bad values. | |
95 | It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. | |
96 | ||
97 | ||
98 | =cut | |
99 | ||
100 | ||
101 | ||
102 | ||
103 | ||
104 | ||
105 | *ccs_matmult2d_sdd = \&PDL::ccs_matmult2d_sdd; | |
106 | ||
107 | ||
108 | ||
109 | ||
110 | ||
111 | =head2 ccs_matmult2d_zdd | |
112 | ||
113 | =for sig | |
114 | ||
115 | Signature: ( | |
116 | indx ixa(Ndimsa,NnzA); nza(NnzA); | |
117 | b(O,M); | |
118 | [o]c(O,N) | |
119 | ) | |
120 | ||
121 | ||
122 | Two-dimensional matrix multiplication of a sparse index-encoded PDL | |
123 | $a() with a dense pdl $b(), with output to a dense pdl $c(). | |
124 | ||
125 | The sparse input PDL $a() should be passed here with 0th | |
126 | dimension "M" and 1st dimension "N", just as for the | |
127 | built-in PDL::Primitive::matmult(). | |
128 | ||
129 | "Missing" values in $a() are treated as zero. | |
130 | $SIZE(Ndimsa) is assumed to be 2. | |
131 | ||
132 | ||
133 | =for bad | |
134 | ||
135 | ccs_matmult2d_zdd does not process bad values. | |
136 | It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. | |
137 | ||
138 | ||
139 | =cut | |
140 | ||
141 | ||
142 | ||
143 | ||
144 | ||
145 | ||
146 | *ccs_matmult2d_zdd = \&PDL::ccs_matmult2d_zdd; | |
147 | ||
148 | ||
149 | ||
150 | ||
151 | ||
152 | =head2 ccs_vnorm | |
153 | ||
154 | =for sig | |
155 | ||
156 | Signature: ( | |
157 | indx acols(NnzA); avals(NnzA); | |
158 | float+ [o]vnorm(M); | |
159 | ; int sizeM=>M) | |
160 | ||
161 | ||
162 | Computes the Euclidean lengths of each column-vector $a(i,*) of a sparse index-encoded pdl $a() | |
163 | of logical dimensions (M,N), with output to a dense piddle $vnorm(). | |
164 | "Missing" values in $a() are treated as zero, | |
165 | and $acols() specifies the (unsorted) indices along the logical dimension M of the corresponding non-missing | |
166 | values in $avals(). | |
167 | This is basically the same thing as: | |
168 | ||
169 | $vnorm = ($a**2)->xchg(0,1)->sumover->sqrt; | |
170 | ||
171 | ... but should be must faster to compute for sparse index-encoded piddles. | |
172 | ||
173 | ||
174 | ||
175 | =for bad | |
176 | ||
177 | ccs_vnorm() always clears the bad-status flag on $vnorm(). | |
178 | ||
179 | =cut | |
180 | ||
181 | ||
182 | ||
183 | ||
184 | ||
185 | ||
186 | *ccs_vnorm = \&PDL::ccs_vnorm; | |
187 | ||
188 | ||
189 | ||
190 | ||
191 | =pod | |
192 | ||
193 | =head2 ccs_vcos_zdd | |
194 | ||
195 | =for sig | |
196 | ||
197 | Signature: ( | |
198 | indx ixa(2,NnzA); nza(NnzA); | |
199 | b(N); | |
200 | float+ [o]vcos(M); | |
201 | float+ [t]anorm(M); | |
202 | int sizeM=>M; | |
203 | ) | |
204 | ||
205 | ||
206 | Computes the vector cosine similarity of a dense row-vector $b(N) with respect to each column $a(i,*) | |
207 | of a sparse index-encoded PDL $a() of logical dimensions (M,N), with output to a dense piddle | |
208 | $vcos(M). | |
209 | "Missing" values in $a() are treated as zero, | |
210 | and magnitudes for $a() are passed in the optional parameter $anorm(), which will be implicitly | |
211 | computed using L<ccs_vnorm|/ccs_vnorm> if the $anorm() parameter is omitted or empty. | |
212 | This is basically the same thing as: | |
213 | ||
214 | $anorm //= ($a**2)->xchg(0,1)->sumover->sqrt; | |
215 | $vcos = ($a * $b->slice("*1,"))->xchg(0,1)->sumover / ($anorm * ($b**2)->sumover->sqrt); | |
216 | ||
217 | ... but should be must faster to compute. | |
218 | ||
219 | Output values in $vcos() are cosine similarities in the range [-1,1], | |
220 | except for zero-magnitude vectors which will result in NaN values in $vcos(). | |
221 | If you need non-negative distances, follow this up with a: | |
222 | ||
223 | $vcos->minus(1,$vcos,1) | |
224 | $vcos->inplace->setnantobad->inplace->setbadtoval(0); ##-- minimum distance for NaN values | |
225 | ||
226 | to get distances values in the range [0,2]. You can use PDL threading to batch-compute distances for | |
227 | multiple $b() vectors simultaneously: | |
228 | ||
229 | $bx = random($N, $NB); ##-- get $NB random vectors of size $N | |
230 | $vcos = ccs_vcos_zdd($ixa,$nza, $bx, $M); ##-- $vcos is now ($M,$NB) | |
231 | ||
232 | ||
233 | =for bad | |
234 | ||
235 | ccs_vcos_zdd() always clears the bad status flag on the output piddle $vcos. | |
236 | ||
237 | =cut | |
238 | ||
239 | sub ccs_vcos_zdd { | |
240 | my ($ixa,$nza,$b) = @_; | |
241 | barf("Usage: ccs_vcos_zdd(ixa, nza, b, vcos?, anorm?, M?)") if (grep {!defined($_)} ($ixa,$nza,$b)); | |
242 | ||
243 | my ($anorm,$vcos,$M); | |
244 | foreach (@_[3..$#_]) { | |
245 | if (!defined($M) && !UNIVERSAL::isa($_,"PDL")) { $M=$_; } | |
246 | elsif (!defined($vcos)) { $vcos = $_; } ##-- compat: pass $vcos() in first | |
247 | elsif (!defined($anorm)) { $anorm = $_; } | |
248 | } | |
249 | ||
250 | ##-- get M | |
251 | $M = $vcos->dim(0) if (!defined($M) && defined($vcos) && !$vcos->isempty); | |
252 | $M = $anorm->dim(0) if (!defined($M) && defined($anorm) && !$anorm->isempty); | |
253 | $M = $ixa->slice("(0),")->max+1 if (!defined($M)); | |
254 | ||
255 | ##-- compat: create output piddles, implicitly computing anorm() if required | |
256 | $anorm = $ixa->slice("(0),")->ccs_vnorm($nza, $M) if (!defined($anorm) || $anorm->isempty); | |
257 | $vcos = PDL->zeroes($anorm->type, $M, ($b->dims)[1..$b->ndims-1]) if (!defined($vcos) || $vcos->isempty); | |
258 | ||
259 | ##-- guts | |
260 | $ixa->_ccs_vcos_zdd($nza,$b, $anorm, $vcos); | |
261 | return $vcos; | |
262 | } | |
263 | ||
264 | *PDL::ccs_vcos_zdd = \&ccs_vcos_zdd; | |
265 | ||
266 | ||
267 | ||
268 | ||
269 | ||
270 | =head2 _ccs_vcos_zdd | |
271 | ||
272 | =for sig | |
273 | ||
274 | Signature: ( | |
275 | indx ixa(Two,NnzA); nza(NnzA); | |
276 | b(N); | |
277 | float+ anorm(M); | |
278 | float+ [o]vcos(M);) | |
279 | ||
280 | =for ref | |
281 | ||
282 | Guts for L<ccs_vcos_zdd()|/ccs_vcos_zdd>, with slightly different calling conventions. | |
283 | ||
284 | =for bad | |
285 | ||
286 | Always clears the bad status flag on the output piddle $vcos. | |
287 | ||
288 | =cut | |
289 | ||
290 | ||
291 | ||
292 | ||
293 | ||
294 | ||
295 | *_ccs_vcos_zdd = \&PDL::_ccs_vcos_zdd; | |
296 | ||
297 | ||
298 | ||
299 | ||
300 | ||
301 | =head2 ccs_vcos_pzd | |
302 | ||
303 | =for sig | |
304 | ||
305 | Signature: ( | |
306 | indx aptr(Nplus1); indx acols(NnzA); avals(NnzA); | |
307 | indx brows(NnzB); bvals(NnzB); | |
308 | anorm(M); | |
309 | float+ [o]vcos(M);) | |
310 | ||
311 | ||
312 | Computes the vector cosine similarity of a sparse index-encoded row-vector $b() of logical dimension (N) | |
313 | with respect to each column $a(i,*) a sparse Harwell-Boeing row-encoded PDL $a() of logical dimensions (M,N), | |
314 | with output to a dense piddle $vcos(M). | |
315 | "Missing" values in $a() are treated as zero, | |
316 | and magnitudes for $a() are passed in the obligatory parameter $anorm(). | |
317 | Usually much faster than L<ccs_vcos_zdd()|/ccs_vcos_zdd> if a CRS pointer over logical dimension (N) is available | |
318 | for $a(). | |
319 | ||
320 | ||
321 | =for bad | |
322 | ||
323 | ccs_vcos_pzd() always clears the bad status flag on the output piddle $vcos. | |
324 | ||
325 | =cut | |
326 | ||
327 | ||
328 | ||
329 | ||
330 | ||
331 | ||
332 | *ccs_vcos_pzd = \&PDL::ccs_vcos_pzd; | |
333 | ||
334 | ||
335 | ||
336 | ||
337 | ##--------------------------------------------------------------------- | |
338 | =pod | |
339 | ||
340 | =head1 ACKNOWLEDGEMENTS | |
341 | ||
342 | Perl by Larry Wall. | |
343 | ||
344 | PDL by Karl Glazebrook, Tuomas J. Lukka, Christian Soeller, and others. | |
345 | ||
346 | =cut | |
347 | ||
348 | ##---------------------------------------------------------------------- | |
349 | =pod | |
350 | ||
351 | =head1 KNOWN BUGS | |
352 | ||
353 | We should really implement matrix multiplication in terms of | |
354 | inner product, and have a good sparse-matrix only implementation | |
355 | of the former. | |
356 | ||
357 | =cut | |
358 | ||
359 | ||
360 | ##--------------------------------------------------------------------- | |
361 | =pod | |
362 | ||
363 | =head1 AUTHOR | |
364 | ||
365 | Bryan Jurish E<lt>moocow@cpan.orgE<gt> | |
366 | ||
367 | =head2 Copyright Policy | |
368 | ||
369 | All other parts Copyright (C) 2009-2015, Bryan Jurish. All rights reserved. | |
370 | ||
371 | This package is free software, and entirely without warranty. | |
372 | You may redistribute it and/or modify it under the same terms | |
373 | as Perl itself. | |
374 | ||
375 | =head1 SEE ALSO | |
376 | ||
377 | perl(1), PDL(3perl) | |
378 | ||
379 | =cut | |
380 | ||
381 | ||
382 | ||
383 | ; | |
384 | ||
385 | ||
386 | ||
387 | # Exit with OK status | |
388 | ||
389 | 1; | |
390 | ||
391 | ⏎ |
4 | 4 | ##====================================================================== |
5 | 5 | |
6 | 6 | use PDL::VectorValued::Dev; |
7 | my $VERSION = '1.23.7'; ##-- update with perl-reversion from Perl::Version module | |
7 | my $VERSION = '1.23.8'; ##-- update with perl-reversion from Perl::Version module | |
8 | 8 | pp_setversion($VERSION); |
9 | 9 | |
10 | 10 | ##-- for integer-type keys |
2 | 2 | ## Description: N-dimensional CCS-encoded pseudo-PDL |
3 | 3 | |
4 | 4 | package PDL::CCS::Nd; |
5 | use PDL::Lite; | |
5 | use PDL::Lite qw(); | |
6 | 6 | use PDL::VectorValued; |
7 | 7 | use PDL::CCS::Config qw(ccs_indx); |
8 | 8 | use PDL::CCS::Functions qw(ccs_decode ccs_pointerlen ccs_qsort); |
18 | 18 | *can = \&UNIVERSAL::can; |
19 | 19 | } |
20 | 20 | |
21 | our $VERSION = '1.23.7'; ##-- update with perl-reversion from Perl::Version module | |
21 | our $VERSION = '1.23.8'; ##-- update with perl-reversion from Perl::Version module | |
22 | 22 | our @ISA = qw(); |
23 | 23 | our %EXPORT_TAGS = |
24 | 24 | ( |
202 | 202 | |
203 | 203 | ##-- sanity check |
204 | 204 | if ($which->dim(0) != $ccs->[$WHICH]->dim(0)) { |
205 | barf(ref($ccs)."::insertWhich(): wrong number of index dimensions in whichND argument:", | |
205 | PDL::Lite::barf(ref($ccs)."::insertWhich(): wrong number of index dimensions in whichND argument:", | |
206 | 206 | " is ", $which->dim(0), ", should be ", $ccs->[$WHICH]->dim(0)); |
207 | 207 | } |
208 | 208 | |
230 | 230 | #if ($which->dim(0) != $ccs->[$WHICH]->dim(0)) |
231 | 231 | if ($which->dim(0) != $ccs->[$PDIMS]->nelem) |
232 | 232 | { |
233 | barf(ref($ccs)."::appendWhich(): wrong number of index dimensions in whichND argument:", | |
233 | PDL::Lite::barf(ref($ccs)."::appendWhich(): wrong number of index dimensions in whichND argument:", | |
234 | 234 | " is ", $which->dim(0), ", should be ", $ccs->[$PDIMS]->nelem); |
235 | 235 | } |
236 | 236 | |
740 | 740 | $vdimi = 0 if (!defined($vdimi)); |
741 | 741 | $vdimi = @vdims + $vdimi + 1 if ($vdimi < 0); |
742 | 742 | if ($vdimi < 0) { |
743 | barf(ref($ccs). "::dummy(): negative dimension number ", ($vdimi+@vdims), " exceeds number of dims ", scalar(@vdims)); | |
743 | PDL::Lite::barf(ref($ccs). "::dummy(): negative dimension number ", ($vdimi+@vdims), " exceeds number of dims ", scalar(@vdims)); | |
744 | 744 | } |
745 | 745 | splice(@vdims,$vdimi,0,-$vdimsize); |
746 | 746 | my $ccs2 = $ccs->copyShallow; |
797 | 797 | ## PDL API: Indexing |
798 | 798 | |
799 | 799 | sub slice { #:lvalue |
800 | barf(ref($_[0])."::slice() is not implemented yet (try dummy, dice_axis, indexND, etc.)"); | |
800 | PDL::Lite::barf(ref($_[0])."::slice() is not implemented yet (try dummy, dice_axis, indexND, etc.)"); | |
801 | 801 | } |
802 | 802 | |
803 | 803 | ## $nzi = $ccs->indexNDi($ndi) |
919 | 919 | ##-- get |
920 | 920 | my $ndims = $ccs->ndims; |
921 | 921 | $axis_v = $ndims + $axis_v if ($axis_v < 0); |
922 | barf(ref($ccs)."::dice_axis(): axis ".($axis_v<0 ? ($axis_v+$ndims) : $axis_v)." out of range: should be 0<=dim<$ndims") | |
922 | PDL::Lite::barf(ref($ccs)."::dice_axis(): axis ".($axis_v<0 ? ($axis_v+$ndims) : $axis_v)." out of range: should be 0<=dim<$ndims") | |
923 | 923 | if ($axis_v < 0 || $axis_v >= $ndims); |
924 | 924 | my $axis = $ccs->[$VDIMS]->at($axis_v); |
925 | 925 | my $asize = $axis < 0 ? -$axis : $ccs->[$PDIMS]->at($axis); |
926 | 926 | $axisi = PDL->topdl($axisi); |
927 | 927 | my ($aimin,$aimax) = $axisi->minmax; |
928 | barf(ref($ccs)."::dice_axis(): invalid index $aimin (valid range 0..".($asize-1).")") if ($aimin < 0); | |
929 | barf(ref($ccs)."::dice_axis(): invalid index $aimax (valid range 0..".($asize-1).")") if ($aimax >= $asize); | |
928 | PDL::Lite::barf(ref($ccs)."::dice_axis(): invalid index $aimin (valid range 0..".($asize-1).")") if ($aimin < 0); | |
929 | PDL::Lite::barf(ref($ccs)."::dice_axis(): invalid index $aimax (valid range 0..".($asize-1).")") if ($aimax >= $asize); | |
930 | 930 | ## |
931 | 931 | ##-- check for virtual |
932 | 932 | if ($axis < 0) { |
1048 | 1048 | ## $ufunc_sub = _ufuncsub($subname, \&ccs_accum_sub, $allow_bad_missing) |
1049 | 1049 | sub _ufuncsub { |
1050 | 1050 | my ($subname,$accumsub,$allow_bad_missing) = @_; |
1051 | barf(__PACKAGE__, "::_ufuncsub($subname): no underlying CCS accumulator func!") if (!defined($accumsub)); | |
1051 | PDL::Lite::barf(__PACKAGE__, "::_ufuncsub($subname): no underlying CCS accumulator func!") if (!defined($accumsub)); | |
1052 | 1052 | return sub :lvalue { |
1053 | 1053 | my $ccs = shift; |
1054 | 1054 | ## |
1151 | 1151 | |
1152 | 1152 | sub _ufunc_ind_sub { |
1153 | 1153 | my ($subname,$accumsub,$allow_bad_missing) = @_; |
1154 | barf(__PACKAGE__, "::_ufuncsub($subname): no underlying CCS accumulator func!") if (!defined($accumsub)); | |
1154 | PDL::Lite::barf(__PACKAGE__, "::_ufuncsub($subname): no underlying CCS accumulator func!") if (!defined($accumsub)); | |
1155 | 1155 | return sub :lvalue { |
1156 | 1156 | my $ccs = shift; |
1157 | 1157 | ## |
1295 | 1295 | |
1296 | 1296 | ##-- check for (virtual) size mismatch |
1297 | 1297 | next if ($dimsza==1 || $dimszb==1); ##... ignoring (virtual) dims of size 1 |
1298 | barf( __PACKAGE__ , "::$opname(): dimension size mismatch on dim($_): $dimsza != $dimszb") | |
1298 | PDL::Lite::barf( __PACKAGE__ , "::$opname(): dimension size mismatch on dim($_): $dimsza != $dimszb") | |
1299 | 1299 | if ($dimsza != $dimszb); |
1300 | 1300 | |
1301 | 1301 | ##-- dims match: only align if both are physical |
1775 | 1775 | ## $c = $a->matmult($b) |
1776 | 1776 | ## + mostly ganked from PDL::Primitive::matmult |
1777 | 1777 | sub matmult :lvalue { |
1778 | barf("Invalid number of arguments for ", __PACKAGE__, "::matmult") if ($#_ < 1); | |
1778 | PDL::Lite::barf("Invalid number of arguments for ", __PACKAGE__, "::matmult") if ($#_ < 1); | |
1779 | 1779 | my ($a,$b,$c) = @_; ##-- no $c! |
1780 | 1780 | $c = undef if (!ref($c) && defined($c) && $c eq ''); ##-- strangeness: getting $c='' |
1781 | 1781 | |
1792 | 1792 | } |
1793 | 1793 | |
1794 | 1794 | if ($b->dim(1) != $a->dim(0)) { |
1795 | barf(sprintf("Dim mismatch in ", __PACKAGE__ , "::matmult of [%dx%d] x [%dx%d]: %d != %d", | |
1795 | PDL::Lite::barf(sprintf("Dim mismatch in ", __PACKAGE__ , "::matmult of [%dx%d] x [%dx%d]: %d != %d", | |
1796 | 1796 | $a->dim(0),$a->dim(1),$b->dim(0),$b->dim(1),$a->dim(0),$b->dim(1))); |
1797 | 1797 | } |
1798 | 1798 | |
1823 | 1823 | |
1824 | 1824 | ##-- check dim sizes |
1825 | 1825 | if ($b->dim(1) != $a->dim(0)) { |
1826 | barf(sprintf("Dim mismatch in ", __PACKAGE__, "::matmult2d [%dx%d] x [%dx%d] : %d != %d", | |
1826 | PDL::Lite::barf(sprintf("Dim mismatch in ", __PACKAGE__, "::matmult2d [%dx%d] x [%dx%d] : %d != %d", | |
1827 | 1827 | $a->dims,$b->dims, $a->dim(0),$b->dim(1))); |
1828 | 1828 | } |
1829 | 1829 | |
1864 | 1864 | |
1865 | 1865 | ##-- check dim sizes |
1866 | 1866 | if ($b->dim(1) != $a->dim(0)) { |
1867 | barf(sprintf("Dim mismatch in ", __PACKAGE__, "::matmult2d [%dx%d] x [%dx%d] : %d != %d", | |
1867 | PDL::Lite::barf(sprintf("Dim mismatch in ", __PACKAGE__, "::matmult2d [%dx%d] x [%dx%d] : %d != %d", | |
1868 | 1868 | $a->dims,$b->dims, $a->dim(0),$b->dim(1))); |
1869 | 1869 | } |
1870 | 1870 |
0 | ||
1 | # | |
2 | # GENERATED WITH PDL::PP! Don't modify! | |
3 | # | |
4 | package PDL::CCS::Ops; | |
5 | ||
6 | @EXPORT_OK = qw( PDL::PP ccs_binop_align_block_mia ); | |
7 | %EXPORT_TAGS = (Func=>[@EXPORT_OK]); | |
8 | ||
9 | use PDL::Core; | |
10 | use PDL::Exporter; | |
11 | use DynaLoader; | |
12 | ||
13 | ||
14 | ||
15 | $PDL::CCS::Ops::VERSION = 1.23.7; | |
16 | @ISA = ( 'PDL::Exporter','DynaLoader' ); | |
17 | push @PDL::Core::PP, __PACKAGE__; | |
18 | bootstrap PDL::CCS::Ops $VERSION; | |
19 | ||
20 | ||
21 | ||
22 | ||
23 | ||
24 | #use PDL::CCS::Version; | |
25 | use strict; | |
26 | ||
27 | =pod | |
28 | ||
29 | =head1 NAME | |
30 | ||
31 | PDL::CCS::Ops - Low-level binary operations for compressed storage sparse PDLs | |
32 | ||
33 | =head1 SYNOPSIS | |
34 | ||
35 | use PDL; | |
36 | use PDL::CCS::Utils; | |
37 | ||
38 | ##--------------------------------------------------------------------- | |
39 | ## ... stuff happens | |
40 | ||
41 | =cut | |
42 | ||
43 | ||
44 | ||
45 | ||
46 | ||
47 | ||
48 | ||
49 | =head1 FUNCTIONS | |
50 | ||
51 | ||
52 | ||
53 | =cut | |
54 | ||
55 | ||
56 | ||
57 | ||
58 | *ccs_indx = \&PDL::indx; ##-- typecasting for CCS indices | |
59 | ||
60 | ||
61 | ||
62 | ||
63 | =head2 ccs_binop_align_block_mia | |
64 | ||
65 | =for sig | |
66 | ||
67 | Signature: ( | |
68 | indx ixa(Ndims,NnzA); indx ixb(Ndims,NnzB); indx istate(State); | |
69 | indx [o]nzai(NnzC); indx [o]nzbi(NnzC); indx [o]ostate(State); | |
70 | ) | |
71 | ||
72 | ||
73 | Partially aligns a pair of lexicographically sorted index-vector lists C<$ixa()> and C<$ixb()>, | |
74 | e.g. for block-wise incremental computation of binary operations over sparse index-encoded PDLs, | |
75 | assuming missing indices correspond to annihilators. | |
76 | ||
77 | On return, the vectors C<$nzai> and C<$nzbi> hold indices into C<NnzA> and C<NnzB> | |
78 | respectively, and are constructed such that: | |
79 | ||
80 | ($ixa(,$nzai->slice("0:$nzci_max")) == $ixb(,$nzbi->slice("0:$nzci_max")) | |
81 | ||
82 | At most C<NnzC> alignments are performed, and alignment ceases | |
83 | as soon as any of the PDLs C<$ixa()>, C<$ixb()>, C<$nzai()>, or C<$nzbi()> | |
84 | has been exhausted. | |
85 | ||
86 | The parameters C<$istate()> and C<$ostate()> hold the state of the algorithm, | |
87 | for incremental block-wise computation at the perl level. Each state PDL | |
88 | is a 7-element PDL containing the following values: | |
89 | ||
90 | INDEX LABEL DESCRIPTION | |
91 | ----------------------------------------------------------------------- | |
92 | 0 nnzai minimum offset in NnzA of current $ixa() value | |
93 | 1 nnzai_nxt minimum offset in NnzA of next $ixa() value | |
94 | 2 nnzbi minimum offset in NnzB of current $ixb() value | |
95 | 3 nnzbi_nxt minimum offset in NnzB of next $ixb() value | |
96 | 4 nnzci minimum offset in NnzC of current ($ixa(),$ixb()) value pair | |
97 | 5 nnzci_nxt minimum offset in NnzC of next ($ixa(),$ixb()) value pair | |
98 | 6 cmpval 3-way comparison value for current ($ixa(),$ixb()) value pair | |
99 | ||
100 | For computation of the first block, $istate() can be safely set to C<zeroes(long,7)>. | |
101 | ||
102 | Repetitions may occur in input index PDLs C<$ixa()> and C<$ixb()>. | |
103 | If an index-match occurs on such a "run", I<all pairs> of matching values are | |
104 | added to the output PDLs. | |
105 | ||
106 | All alignments have been performed if: | |
107 | ||
108 | $ostate(0)==$NnzA && $ostate(1)==$NnzB | |
109 | ||
110 | B<WARNING:> this alignment method ignores index-vectors which are not present | |
111 | in I<both> C<$ixa()> and C<$ixb()>, which is a Good Thing if your are feeding | |
112 | the aligned values into an operation for which missing values are annihilators: | |
113 | ||
114 | $missinga * $bval == ($missinga * $missingb) for each $bval \in $b, and | |
115 | $aval * $missingb == ($missinga * $missingb) for each $aval \in $a | |
116 | ||
117 | This ought to be the case for all operations if missing values are C<BAD> (see L<PDL::Bad>), | |
118 | but might cause unexpected results if e.g. missing values are zero and the operation | |
119 | in question is addition. | |
120 | ||
121 | ||
122 | ||
123 | =for bad | |
124 | ||
125 | ccs_binop_align_block_mia does not process bad values. | |
126 | It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. | |
127 | ||
128 | ||
129 | =cut | |
130 | ||
131 | ||
132 | ||
133 | ||
134 | ||
135 | ||
136 | *ccs_binop_align_block_mia = \&PDL::ccs_binop_align_block_mia; | |
137 | ||
138 | ||
139 | ||
140 | ||
141 | ##--------------------------------------------------------------------- | |
142 | =pod | |
143 | ||
144 | =head1 ACKNOWLEDGEMENTS | |
145 | ||
146 | Perl by Larry Wall. | |
147 | ||
148 | PDL by Karl Glazebrook, Tuomas J. Lukka, Christian Soeller, and others. | |
149 | ||
150 | =cut | |
151 | ||
152 | ##---------------------------------------------------------------------- | |
153 | =pod | |
154 | ||
155 | =head1 KNOWN BUGS | |
156 | ||
157 | No support for (pseudo)-threading. | |
158 | ||
159 | =cut | |
160 | ||
161 | ||
162 | ##--------------------------------------------------------------------- | |
163 | =pod | |
164 | ||
165 | =head1 AUTHOR | |
166 | ||
167 | Bryan Jurish E<lt>moocow@cpan.orgE<gt> | |
168 | ||
169 | =head2 Copyright Policy | |
170 | ||
171 | All other parts Copyright (C) 2007-2013, Bryan Jurish. All rights reserved. | |
172 | ||
173 | This package is free software, and entirely without warranty. | |
174 | You may redistribute it and/or modify it under the same terms | |
175 | as Perl itself. | |
176 | ||
177 | =head1 SEE ALSO | |
178 | ||
179 | perl(1), PDL(3perl) | |
180 | ||
181 | =cut | |
182 | ||
183 | ||
184 | ||
185 | ; | |
186 | ||
187 | ||
188 | ||
189 | # Exit with OK status | |
190 | ||
191 | 1; | |
192 | ||
193 | ⏎ |
4 | 4 | ##====================================================================== |
5 | 5 | |
6 | 6 | use PDL::VectorValued::Dev; |
7 | my $VERSION = '1.23.7'; ##-- update with perl-reversion from Perl::Version module | |
7 | my $VERSION = '1.23.8'; ##-- update with perl-reversion from Perl::Version module | |
8 | 8 | pp_setversion($VERSION); |
9 | 9 | |
10 | 10 | ##------------------------------------------------------ |
0 | ||
1 | # | |
2 | # GENERATED WITH PDL::PP! Don't modify! | |
3 | # | |
4 | package PDL::CCS::Ufunc; | |
5 | ||
6 | @EXPORT_OK = qw( PDL::PP ccs_accum_prod PDL::PP ccs_accum_dprod PDL::PP ccs_accum_sum PDL::PP ccs_accum_dsum PDL::PP ccs_accum_or PDL::PP ccs_accum_and PDL::PP ccs_accum_bor PDL::PP ccs_accum_band PDL::PP ccs_accum_maximum PDL::PP ccs_accum_minimum PDL::PP ccs_accum_maximum_nz_ind PDL::PP ccs_accum_minimum_nz_ind PDL::PP ccs_accum_nbad PDL::PP ccs_accum_ngood PDL::PP ccs_accum_nnz PDL::PP ccs_accum_average ); | |
7 | %EXPORT_TAGS = (Func=>[@EXPORT_OK]); | |
8 | ||
9 | use PDL::Core; | |
10 | use PDL::Exporter; | |
11 | use DynaLoader; | |
12 | ||
13 | ||
14 | ||
15 | $PDL::CCS::Ufunc::VERSION = 1.23.7; | |
16 | @ISA = ( 'PDL::Exporter','DynaLoader' ); | |
17 | push @PDL::Core::PP, __PACKAGE__; | |
18 | bootstrap PDL::CCS::Ufunc $VERSION; | |
19 | ||
20 | ||
21 | ||
22 | ||
23 | ||
24 | #use PDL::CCS::Version; | |
25 | use strict; | |
26 | ||
27 | =pod | |
28 | ||
29 | =head1 NAME | |
30 | ||
31 | PDL::CCS::Ufunc - Ufuncs for compressed storage sparse PDLs | |
32 | ||
33 | =head1 SYNOPSIS | |
34 | ||
35 | use PDL; | |
36 | use PDL::CCS::Ufunc; | |
37 | ||
38 | ##--------------------------------------------------------------------- | |
39 | ## ... stuff happens | |
40 | ||
41 | =cut | |
42 | ||
43 | ||
44 | ||
45 | ||
46 | ||
47 | ||
48 | ||
49 | =head1 FUNCTIONS | |
50 | ||
51 | ||
52 | ||
53 | =cut | |
54 | ||
55 | ||
56 | ||
57 | ||
58 | *ccs_indx = \&PDL::indx; ##-- typecasting for CCS indices | |
59 | ||
60 | ||
61 | ||
62 | ||
63 | =head2 ccs_accum_prod | |
64 | ||
65 | =for sig | |
66 | ||
67 | Signature: ( | |
68 | indx ixIn(Ndims,NnzIn); | |
69 | nzvalsIn(NnzIn); | |
70 | missing(); | |
71 | indx N(); | |
72 | indx [o]ixOut(Ndims,NnzOut); | |
73 | [o]nzvalsOut(NnzOut); | |
74 | indx [o]nOut(); | |
75 | ) | |
76 | ||
77 | ||
78 | Accumulated product over values $nzvalsIn() associated with vector-valued keys $ixIn(). | |
79 | On return, | |
80 | $ixOut() holds the unique non-"missing" values of $ixIn(), | |
81 | $nzvalsOut() holds the associated values, | |
82 | and | |
83 | $nOut() stores the number of unique non-missing values computed. | |
84 | ||
85 | ||
86 | If $N() is specified and greater than zero, then the quantity: | |
87 | ||
88 | $missing ** ($N - (rlevec($ixIn))[0]) | |
89 | ||
90 | is multiplied into $nzvalsOut: this is probably What You Want if you are computing the product over a virtual | |
91 | dimension in a sparse index-encoded PDL (see PDL::CCS::Nd for a wrapper class). | |
92 | ||
93 | ||
94 | ||
95 | Returned PDLs are implicitly sliced such that NnzOut==$nOut(). | |
96 | ||
97 | In scalar context, returns only $nzvalsOut(). | |
98 | ||
99 | ||
100 | ||
101 | =for bad | |
102 | ||
103 | ccs_accum_prod processes bad values. | |
104 | The state of the bad-value flag of the output piddles is unknown. | |
105 | ||
106 | ||
107 | =cut | |
108 | ||
109 | ||
110 | ||
111 | ||
112 | ||
113 | sub PDL::ccs_accum_prod { | |
114 | my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; | |
115 | my ($ndims,@nnzIn) = $ixIn->dims; | |
116 | my (@nnzOut); | |
117 | if (defined($ixOut)) { | |
118 | @nnzOut = $ixOut->dims; | |
119 | shift(@nnzOut); | |
120 | } | |
121 | ||
122 | @nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); | |
123 | @nnzOut = @nnzIn if (!@nnzOut); | |
124 | $ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) | |
125 | if (!defined($ixOut) || $ixOut->isempty); | |
126 | ||
127 | $nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) | |
128 | if (!defined($nzvalsOut) || $nzvalsOut->isempty); | |
129 | ||
130 | $nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); | |
131 | ## | |
132 | ##-- guts | |
133 | &PDL::_ccs_accum_prod_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); | |
134 | ## | |
135 | ##-- auto-trim | |
136 | $ixOut = $ixOut->slice(",0:".($nOut->max-1)); | |
137 | $nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); | |
138 | ## | |
139 | ##-- return | |
140 | return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; | |
141 | } | |
142 | ||
143 | ||
144 | *ccs_accum_prod = \&PDL::ccs_accum_prod; | |
145 | ||
146 | ||
147 | ||
148 | ||
149 | ||
150 | =head2 ccs_accum_dprod | |
151 | ||
152 | =for sig | |
153 | ||
154 | Signature: ( | |
155 | indx ixIn(Ndims,NnzIn); | |
156 | nzvalsIn(NnzIn); | |
157 | missing(); | |
158 | indx N(); | |
159 | indx [o]ixOut(Ndims,NnzOut); | |
160 | double [o]nzvalsOut(NnzOut); | |
161 | indx [o]nOut(); | |
162 | ) | |
163 | ||
164 | ||
165 | Accumulated double-precision product over values $nzvalsIn() associated with vector-valued keys $ixIn(). | |
166 | On return, | |
167 | $ixOut() holds the unique non-"missing" values of $ixIn(), | |
168 | $nzvalsOut() holds the associated values, | |
169 | and | |
170 | $nOut() stores the number of unique non-missing values computed. | |
171 | ||
172 | ||
173 | If $N() is specified and greater than zero, then the quantity: | |
174 | ||
175 | $missing ** ($N - (rlevec($ixIn))[0]) | |
176 | ||
177 | is multiplied into $nzvalsOut: this is probably What You Want if you are computing the product over a virtual | |
178 | dimension in a sparse index-encoded PDL (see PDL::CCS::Nd for a wrapper class). | |
179 | ||
180 | ||
181 | ||
182 | Returned PDLs are implicitly sliced such that NnzOut==$nOut(). | |
183 | ||
184 | In scalar context, returns only $nzvalsOut(). | |
185 | ||
186 | ||
187 | ||
188 | =for bad | |
189 | ||
190 | ccs_accum_dprod processes bad values. | |
191 | The state of the bad-value flag of the output piddles is unknown. | |
192 | ||
193 | ||
194 | =cut | |
195 | ||
196 | ||
197 | ||
198 | ||
199 | ||
200 | sub PDL::ccs_accum_dprod { | |
201 | my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; | |
202 | my ($ndims,@nnzIn) = $ixIn->dims; | |
203 | my (@nnzOut); | |
204 | if (defined($ixOut)) { | |
205 | @nnzOut = $ixOut->dims; | |
206 | shift(@nnzOut); | |
207 | } | |
208 | ||
209 | @nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); | |
210 | @nnzOut = @nnzIn if (!@nnzOut); | |
211 | $ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) | |
212 | if (!defined($ixOut) || $ixOut->isempty); | |
213 | ||
214 | $nzvalsOut = PDL->zeroes((PDL::double()), @nnzOut) | |
215 | if (!defined($nzvalsOut) || $nzvalsOut->isempty); | |
216 | ||
217 | $nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); | |
218 | ## | |
219 | ##-- guts | |
220 | &PDL::_ccs_accum_dprod_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); | |
221 | ## | |
222 | ##-- auto-trim | |
223 | $ixOut = $ixOut->slice(",0:".($nOut->max-1)); | |
224 | $nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); | |
225 | ## | |
226 | ##-- return | |
227 | return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; | |
228 | } | |
229 | ||
230 | ||
231 | *ccs_accum_dprod = \&PDL::ccs_accum_dprod; | |
232 | ||
233 | ||
234 | ||
235 | ||
236 | ||
237 | =head2 ccs_accum_sum | |
238 | ||
239 | =for sig | |
240 | ||
241 | Signature: ( | |
242 | indx ixIn(Ndims,NnzIn); | |
243 | nzvalsIn(NnzIn); | |
244 | missing(); | |
245 | indx N(); | |
246 | indx [o]ixOut(Ndims,NnzOut); | |
247 | [o]nzvalsOut(NnzOut); | |
248 | indx [o]nOut(); | |
249 | ) | |
250 | ||
251 | ||
252 | Accumulated sum over values $nzvalsIn() associated with vector-valued keys $ixIn(). | |
253 | On return, | |
254 | $ixOut() holds the unique non-"missing" values of $ixIn(), | |
255 | $nzvalsOut() holds the associated values, | |
256 | and | |
257 | $nOut() stores the number of unique non-missing values computed. | |
258 | ||
259 | ||
260 | If $N() is specified and greater than zero, then the quantity: | |
261 | ||
262 | $missing * ($N - (rlevec($ixIn))[0]) | |
263 | ||
264 | is added to $nzvalsOut: this is probably What You Want if you are summing over a virtual | |
265 | dimension in a sparse index-encoded PDL (see PDL::CCS::Nd for a wrapper class). | |
266 | ||
267 | ||
268 | ||
269 | Returned PDLs are implicitly sliced such that NnzOut==$nOut(). | |
270 | ||
271 | In scalar context, returns only $nzvalsOut(). | |
272 | ||
273 | ||
274 | ||
275 | =for bad | |
276 | ||
277 | ccs_accum_sum processes bad values. | |
278 | The state of the bad-value flag of the output piddles is unknown. | |
279 | ||
280 | ||
281 | =cut | |
282 | ||
283 | ||
284 | ||
285 | ||
286 | ||
287 | sub PDL::ccs_accum_sum { | |
288 | my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; | |
289 | my ($ndims,@nnzIn) = $ixIn->dims; | |
290 | my (@nnzOut); | |
291 | if (defined($ixOut)) { | |
292 | @nnzOut = $ixOut->dims; | |
293 | shift(@nnzOut); | |
294 | } | |
295 | ||
296 | @nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); | |
297 | @nnzOut = @nnzIn if (!@nnzOut); | |
298 | $ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) | |
299 | if (!defined($ixOut) || $ixOut->isempty); | |
300 | ||
301 | $nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) | |
302 | if (!defined($nzvalsOut) || $nzvalsOut->isempty); | |
303 | ||
304 | $nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); | |
305 | ## | |
306 | ##-- guts | |
307 | &PDL::_ccs_accum_sum_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); | |
308 | ## | |
309 | ##-- auto-trim | |
310 | $ixOut = $ixOut->slice(",0:".($nOut->max-1)); | |
311 | $nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); | |
312 | ## | |
313 | ##-- return | |
314 | return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; | |
315 | } | |
316 | ||
317 | ||
318 | *ccs_accum_sum = \&PDL::ccs_accum_sum; | |
319 | ||
320 | ||
321 | ||
322 | ||
323 | ||
324 | =head2 ccs_accum_dsum | |
325 | ||
326 | =for sig | |
327 | ||
328 | Signature: ( | |
329 | indx ixIn(Ndims,NnzIn); | |
330 | nzvalsIn(NnzIn); | |
331 | missing(); | |
332 | indx N(); | |
333 | indx [o]ixOut(Ndims,NnzOut); | |
334 | double [o]nzvalsOut(NnzOut); | |
335 | indx [o]nOut(); | |
336 | ) | |
337 | ||
338 | ||
339 | Accumulated double-precision sum over values $nzvalsIn() associated with vector-valued keys $ixIn(). | |
340 | On return, | |
341 | $ixOut() holds the unique non-"missing" values of $ixIn(), | |
342 | $nzvalsOut() holds the associated values, | |
343 | and | |
344 | $nOut() stores the number of unique non-missing values computed. | |
345 | ||
346 | ||
347 | If $N() is specified and greater than zero, then the quantity: | |
348 | ||
349 | $missing * ($N - (rlevec($ixIn))[0]) | |
350 | ||
351 | is added to $nzvalsOut: this is probably What You Want if you are summing over a virtual | |
352 | dimension in a sparse index-encoded PDL (see PDL::CCS::Nd for a wrapper class). | |
353 | ||
354 | ||
355 | ||
356 | Returned PDLs are implicitly sliced such that NnzOut==$nOut(). | |
357 | ||
358 | In scalar context, returns only $nzvalsOut(). | |
359 | ||
360 | ||
361 | ||
362 | =for bad | |
363 | ||
364 | ccs_accum_dsum processes bad values. | |
365 | The state of the bad-value flag of the output piddles is unknown. | |
366 | ||
367 | ||
368 | =cut | |
369 | ||
370 | ||
371 | ||
372 | ||
373 | ||
374 | sub PDL::ccs_accum_dsum { | |
375 | my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; | |
376 | my ($ndims,@nnzIn) = $ixIn->dims; | |
377 | my (@nnzOut); | |
378 | if (defined($ixOut)) { | |
379 | @nnzOut = $ixOut->dims; | |
380 | shift(@nnzOut); | |
381 | } | |
382 | ||
383 | @nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); | |
384 | @nnzOut = @nnzIn if (!@nnzOut); | |
385 | $ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) | |
386 | if (!defined($ixOut) || $ixOut->isempty); | |
387 | ||
388 | $nzvalsOut = PDL->zeroes((PDL::double()), @nnzOut) | |
389 | if (!defined($nzvalsOut) || $nzvalsOut->isempty); | |
390 | ||
391 | $nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); | |
392 | ## | |
393 | ##-- guts | |
394 | &PDL::_ccs_accum_dsum_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); | |
395 | ## | |
396 | ##-- auto-trim | |
397 | $ixOut = $ixOut->slice(",0:".($nOut->max-1)); | |
398 | $nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); | |
399 | ## | |
400 | ##-- return | |
401 | return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; | |
402 | } | |
403 | ||
404 | ||
405 | *ccs_accum_dsum = \&PDL::ccs_accum_dsum; | |
406 | ||
407 | ||
408 | ||
409 | ||
410 | ||
411 | =head2 ccs_accum_or | |
412 | ||
413 | =for sig | |
414 | ||
415 | Signature: ( | |
416 | indx ixIn(Ndims,NnzIn); | |
417 | nzvalsIn(NnzIn); | |
418 | missing(); | |
419 | indx N(); | |
420 | indx [o]ixOut(Ndims,NnzOut); | |
421 | [o]nzvalsOut(NnzOut); | |
422 | indx [o]nOut(); | |
423 | ) | |
424 | ||
425 | ||
426 | Accumulated logical "or" over values $nzvalsIn() associated with vector-valued keys $ixIn(). | |
427 | On return, | |
428 | $ixOut() holds the unique non-"missing" values of $ixIn(), | |
429 | $nzvalsOut() holds the associated values, | |
430 | and | |
431 | $nOut() stores the number of unique non-missing values computed. | |
432 | ||
433 | ||
434 | If $N() is specified and greater than zero, $missing() is logically (or)ed | |
435 | into each result value at each output index with a run length of less than $N() in $ixIn(). | |
436 | This is probably What You Want. | |
437 | ||
438 | ||
439 | ||
440 | Returned PDLs are implicitly sliced such that NnzOut==$nOut(). | |
441 | ||
442 | In scalar context, returns only $nzvalsOut(). | |
443 | ||
444 | ||
445 | ||
446 | =for bad | |
447 | ||
448 | ccs_accum_or processes bad values. | |
449 | The state of the bad-value flag of the output piddles is unknown. | |
450 | ||
451 | ||
452 | =cut | |
453 | ||
454 | ||
455 | ||
456 | ||
457 | ||
458 | sub PDL::ccs_accum_or { | |
459 | my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; | |
460 | my ($ndims,@nnzIn) = $ixIn->dims; | |
461 | my (@nnzOut); | |
462 | if (defined($ixOut)) { | |
463 | @nnzOut = $ixOut->dims; | |
464 | shift(@nnzOut); | |
465 | } | |
466 | ||
467 | @nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); | |
468 | @nnzOut = @nnzIn if (!@nnzOut); | |
469 | $ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) | |
470 | if (!defined($ixOut) || $ixOut->isempty); | |
471 | ||
472 | $nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) | |
473 | if (!defined($nzvalsOut) || $nzvalsOut->isempty); | |
474 | ||
475 | $nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); | |
476 | ## | |
477 | ##-- guts | |
478 | &PDL::_ccs_accum_or_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); | |
479 | ## | |
480 | ##-- auto-trim | |
481 | $ixOut = $ixOut->slice(",0:".($nOut->max-1)); | |
482 | $nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); | |
483 | ## | |
484 | ##-- return | |
485 | return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; | |
486 | } | |
487 | ||
488 | ||
489 | *ccs_accum_or = \&PDL::ccs_accum_or; | |
490 | ||
491 | ||
492 | ||
493 | ||
494 | ||
495 | =head2 ccs_accum_and | |
496 | ||
497 | =for sig | |
498 | ||
499 | Signature: ( | |
500 | indx ixIn(Ndims,NnzIn); | |
501 | nzvalsIn(NnzIn); | |
502 | missing(); | |
503 | indx N(); | |
504 | indx [o]ixOut(Ndims,NnzOut); | |
505 | [o]nzvalsOut(NnzOut); | |
506 | indx [o]nOut(); | |
507 | ) | |
508 | ||
509 | ||
510 | Accumulated logical "and" over values $nzvalsIn() associated with vector-valued keys $ixIn(). | |
511 | On return, | |
512 | $ixOut() holds the unique non-"missing" values of $ixIn(), | |
513 | $nzvalsOut() holds the associated values, | |
514 | and | |
515 | $nOut() stores the number of unique non-missing values computed. | |
516 | ||
517 | ||
518 | If $N() is specified and greater than zero, $missing() is logically (and)ed | |
519 | into each result value at each output index with a run length of less than $N() in $ixIn(). | |
520 | This is probably What You Want. | |
521 | ||
522 | ||
523 | ||
524 | Returned PDLs are implicitly sliced such that NnzOut==$nOut(). | |
525 | ||
526 | In scalar context, returns only $nzvalsOut(). | |
527 | ||
528 | ||
529 | ||
530 | =for bad | |
531 | ||
532 | ccs_accum_and processes bad values. | |
533 | The state of the bad-value flag of the output piddles is unknown. | |
534 | ||
535 | ||
536 | =cut | |
537 | ||
538 | ||
539 | ||
540 | ||
541 | ||
542 | sub PDL::ccs_accum_and { | |
543 | my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; | |
544 | my ($ndims,@nnzIn) = $ixIn->dims; | |
545 | my (@nnzOut); | |
546 | if (defined($ixOut)) { | |
547 | @nnzOut = $ixOut->dims; | |
548 | shift(@nnzOut); | |
549 | } | |
550 | ||
551 | @nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); | |
552 | @nnzOut = @nnzIn if (!@nnzOut); | |
553 | $ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) | |
554 | if (!defined($ixOut) || $ixOut->isempty); | |
555 | ||
556 | $nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) | |
557 | if (!defined($nzvalsOut) || $nzvalsOut->isempty); | |
558 | ||
559 | $nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); | |
560 | ## | |
561 | ##-- guts | |
562 | &PDL::_ccs_accum_and_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); | |
563 | ## | |
564 | ##-- auto-trim | |
565 | $ixOut = $ixOut->slice(",0:".($nOut->max-1)); | |
566 | $nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); | |
567 | ## | |
568 | ##-- return | |
569 | return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; | |
570 | } | |
571 | ||
572 | ||
573 | *ccs_accum_and = \&PDL::ccs_accum_and; | |
574 | ||
575 | ||
576 | ||
577 | ||
578 | ||
579 | =head2 ccs_accum_bor | |
580 | ||
581 | =for sig | |
582 | ||
583 | Signature: ( | |
584 | indx ixIn(Ndims,NnzIn); | |
585 | nzvalsIn(NnzIn); | |
586 | missing(); | |
587 | indx N(); | |
588 | indx [o]ixOut(Ndims,NnzOut); | |
589 | [o]nzvalsOut(NnzOut); | |
590 | indx [o]nOut(); | |
591 | ) | |
592 | ||
593 | ||
594 | Accumulated bitwise "or" over values $nzvalsIn() associated with vector-valued keys $ixIn(). | |
595 | On return, | |
596 | $ixOut() holds the unique non-"missing" values of $ixIn(), | |
597 | $nzvalsOut() holds the associated values, | |
598 | and | |
599 | $nOut() stores the number of unique non-missing values computed. | |
600 | ||
601 | ||
602 | If $N() is specified and greater than zero, $missing() is bitwise (or)ed | |
603 | into each result value at each output index with a run length of less than $N() in $ixIn(). | |
604 | This is probably What You Want. | |
605 | ||
606 | ||
607 | ||
608 | Returned PDLs are implicitly sliced such that NnzOut==$nOut(). | |
609 | ||
610 | In scalar context, returns only $nzvalsOut(). | |
611 | ||
612 | ||
613 | ||
614 | =for bad | |
615 | ||
616 | ccs_accum_bor processes bad values. | |
617 | The state of the bad-value flag of the output piddles is unknown. | |
618 | ||
619 | ||
620 | =cut | |
621 | ||
622 | ||
623 | ||
624 | ||
625 | ||
626 | sub PDL::ccs_accum_bor { | |
627 | my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; | |
628 | my ($ndims,@nnzIn) = $ixIn->dims; | |
629 | my (@nnzOut); | |
630 | if (defined($ixOut)) { | |
631 | @nnzOut = $ixOut->dims; | |
632 | shift(@nnzOut); | |
633 | } | |
634 | ||
635 | $nzvalsIn = ccs_indx($nzvalsIn) if ($nzvalsIn->type > ccs_indx()); ##-- max_type_perl=ccs_indx | |
636 | @nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); | |
637 | @nnzOut = @nnzIn if (!@nnzOut); | |
638 | $ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) | |
639 | if (!defined($ixOut) || $ixOut->isempty); | |
640 | ||
641 | $nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) | |
642 | if (!defined($nzvalsOut) || $nzvalsOut->isempty); | |
643 | ||
644 | $nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); | |
645 | ## | |
646 | ##-- guts | |
647 | &PDL::_ccs_accum_bor_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); | |
648 | ## | |
649 | ##-- auto-trim | |
650 | $ixOut = $ixOut->slice(",0:".($nOut->max-1)); | |
651 | $nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); | |
652 | ## | |
653 | ##-- return | |
654 | return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; | |
655 | } | |
656 | ||
657 | ||
658 | *ccs_accum_bor = \&PDL::ccs_accum_bor; | |
659 | ||
660 | ||
661 | ||
662 | ||
663 | ||
664 | =head2 ccs_accum_band | |
665 | ||
666 | =for sig | |
667 | ||
668 | Signature: ( | |
669 | indx ixIn(Ndims,NnzIn); | |
670 | nzvalsIn(NnzIn); | |
671 | missing(); | |
672 | indx N(); | |
673 | indx [o]ixOut(Ndims,NnzOut); | |
674 | [o]nzvalsOut(NnzOut); | |
675 | indx [o]nOut(); | |
676 | ) | |
677 | ||
678 | ||
679 | Accumulated bitwise "and" over values $nzvalsIn() associated with vector-valued keys $ixIn(). | |
680 | On return, | |
681 | $ixOut() holds the unique non-"missing" values of $ixIn(), | |
682 | $nzvalsOut() holds the associated values, | |
683 | and | |
684 | $nOut() stores the number of unique non-missing values computed. | |
685 | ||
686 | ||
687 | If $N() is specified and greater than zero, $missing() is bitwise (and)ed | |
688 | into each result value at each output index with a run length of less than $N() in $ixIn(). | |
689 | This is probably What You Want. | |
690 | ||
691 | ||
692 | ||
693 | Returned PDLs are implicitly sliced such that NnzOut==$nOut(). | |
694 | ||
695 | In scalar context, returns only $nzvalsOut(). | |
696 | ||
697 | ||
698 | ||
699 | =for bad | |
700 | ||
701 | ccs_accum_band processes bad values. | |
702 | The state of the bad-value flag of the output piddles is unknown. | |
703 | ||
704 | ||
705 | =cut | |
706 | ||
707 | ||
708 | ||
709 | ||
710 | ||
711 | sub PDL::ccs_accum_band { | |
712 | my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; | |
713 | my ($ndims,@nnzIn) = $ixIn->dims; | |
714 | my (@nnzOut); | |
715 | if (defined($ixOut)) { | |
716 | @nnzOut = $ixOut->dims; | |
717 | shift(@nnzOut); | |
718 | } | |
719 | ||
720 | $nzvalsIn = ccs_indx($nzvalsIn) if ($nzvalsIn->type > ccs_indx()); ##-- max_type_perl=ccs_indx | |
721 | @nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); | |
722 | @nnzOut = @nnzIn if (!@nnzOut); | |
723 | $ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) | |
724 | if (!defined($ixOut) || $ixOut->isempty); | |
725 | ||
726 | $nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) | |
727 | if (!defined($nzvalsOut) || $nzvalsOut->isempty); | |
728 | ||
729 | $nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); | |
730 | ## | |
731 | ##-- guts | |
732 | &PDL::_ccs_accum_band_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); | |
733 | ## | |
734 | ##-- auto-trim | |
735 | $ixOut = $ixOut->slice(",0:".($nOut->max-1)); | |
736 | $nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); | |
737 | ## | |
738 | ##-- return | |
739 | return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; | |
740 | } | |
741 | ||
742 | ||
743 | *ccs_accum_band = \&PDL::ccs_accum_band; | |
744 | ||
745 | ||
746 | ||
747 | ||
748 | ||
749 | =head2 ccs_accum_maximum | |
750 | ||
751 | =for sig | |
752 | ||
753 | Signature: ( | |
754 | indx ixIn(Ndims,NnzIn); | |
755 | nzvalsIn(NnzIn); | |
756 | missing(); | |
757 | indx N(); | |
758 | indx [o]ixOut(Ndims,NnzOut); | |
759 | [o]nzvalsOut(NnzOut); | |
760 | indx [o]nOut(); | |
761 | ) | |
762 | ||
763 | ||
764 | Accumulated maximum over values $nzvalsIn() associated with vector-valued keys $ixIn(). | |
765 | On return, | |
766 | $ixOut() holds the unique non-"missing" values of $ixIn(), | |
767 | $nzvalsOut() holds the associated values, | |
768 | and | |
769 | $nOut() stores the number of unique non-missing values computed. | |
770 | ||
771 | ||
772 | If $N() is specified and greater than zero, | |
773 | and if $missing() is greater than any listed value for a vector key with a run-length | |
774 | of less than $N(), then $missing() is used as the output value for that key. | |
775 | This is probably What You Want. | |
776 | ||
777 | ||
778 | ||
779 | Returned PDLs are implicitly sliced such that NnzOut==$nOut(). | |
780 | ||
781 | In scalar context, returns only $nzvalsOut(). | |
782 | ||
783 | ||
784 | ||
785 | =for bad | |
786 | ||
787 | ccs_accum_maximum processes bad values. | |
788 | The state of the bad-value flag of the output piddles is unknown. | |
789 | ||
790 | ||
791 | =cut | |
792 | ||
793 | ||
794 | ||
795 | ||
796 | ||
797 | sub PDL::ccs_accum_maximum { | |
798 | my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; | |
799 | my ($ndims,@nnzIn) = $ixIn->dims; | |
800 | my (@nnzOut); | |
801 | if (defined($ixOut)) { | |
802 | @nnzOut = $ixOut->dims; | |
803 | shift(@nnzOut); | |
804 | } | |
805 | ||
806 | @nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); | |
807 | @nnzOut = @nnzIn if (!@nnzOut); | |
808 | $ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) | |
809 | if (!defined($ixOut) || $ixOut->isempty); | |
810 | ||
811 | $nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) | |
812 | if (!defined($nzvalsOut) || $nzvalsOut->isempty); | |
813 | ||
814 | $nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); | |
815 | ## | |
816 | ##-- guts | |
817 | &PDL::_ccs_accum_maximum_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); | |
818 | ## | |
819 | ##-- auto-trim | |
820 | $ixOut = $ixOut->slice(",0:".($nOut->max-1)); | |
821 | $nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); | |
822 | ## | |
823 | ##-- return | |
824 | return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; | |
825 | } | |
826 | ||
827 | ||
828 | *ccs_accum_maximum = \&PDL::ccs_accum_maximum; | |
829 | ||
830 | ||
831 | ||
832 | ||
833 | ||
834 | =head2 ccs_accum_minimum | |
835 | ||
836 | =for sig | |
837 | ||
838 | Signature: ( | |
839 | indx ixIn(Ndims,NnzIn); | |
840 | nzvalsIn(NnzIn); | |
841 | missing(); | |
842 | indx N(); | |
843 | indx [o]ixOut(Ndims,NnzOut); | |
844 | [o]nzvalsOut(NnzOut); | |
845 | indx [o]nOut(); | |
846 | ) | |
847 | ||
848 | ||
849 | Accumulated minimum over values $nzvalsIn() associated with vector-valued keys $ixIn(). | |
850 | On return, | |
851 | $ixOut() holds the unique non-"missing" values of $ixIn(), | |
852 | $nzvalsOut() holds the associated values, | |
853 | and | |
854 | $nOut() stores the number of unique non-missing values computed. | |
855 | ||
856 | ||
857 | If $N() is specified and greater than zero, | |
858 | and if $missing() is less than any listed value for a vector key with a run-length | |
859 | of less than $N(), then $missing() is used as the output value for that key. | |
860 | This is probably What You Want. | |
861 | ||
862 | ||
863 | ||
864 | Returned PDLs are implicitly sliced such that NnzOut==$nOut(). | |
865 | ||
866 | In scalar context, returns only $nzvalsOut(). | |
867 | ||
868 | ||
869 | ||
870 | =for bad | |
871 | ||
872 | ccs_accum_minimum processes bad values. | |
873 | The state of the bad-value flag of the output piddles is unknown. | |
874 | ||
875 | ||
876 | =cut | |
877 | ||
878 | ||
879 | ||
880 | ||
881 | ||
882 | sub PDL::ccs_accum_minimum { | |
883 | my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; | |
884 | my ($ndims,@nnzIn) = $ixIn->dims; | |
885 | my (@nnzOut); | |
886 | if (defined($ixOut)) { | |
887 | @nnzOut = $ixOut->dims; | |
888 | shift(@nnzOut); | |
889 | } | |
890 | ||
891 | @nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); | |
892 | @nnzOut = @nnzIn if (!@nnzOut); | |
893 | $ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) | |
894 | if (!defined($ixOut) || $ixOut->isempty); | |
895 | ||
896 | $nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) | |
897 | if (!defined($nzvalsOut) || $nzvalsOut->isempty); | |
898 | ||
899 | $nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); | |
900 | ## | |
901 | ##-- guts | |
902 | &PDL::_ccs_accum_minimum_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); | |
903 | ## | |
904 | ##-- auto-trim | |
905 | $ixOut = $ixOut->slice(",0:".($nOut->max-1)); | |
906 | $nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); | |
907 | ## | |
908 | ##-- return | |
909 | return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; | |
910 | } | |
911 | ||
912 | ||
913 | *ccs_accum_minimum = \&PDL::ccs_accum_minimum; | |
914 | ||
915 | ||
916 | ||
917 | ||
918 | ||
919 | =head2 ccs_accum_maximum_nz_ind | |
920 | ||
921 | =for sig | |
922 | ||
923 | Signature: ( | |
924 | indx ixIn(Ndims,NnzIn); | |
925 | nzvalsIn(NnzIn); | |
926 | missing(); | |
927 | indx N(); | |
928 | indx [o]ixOut(Ndims,NnzOut); | |
929 | indx [o]nzvalsOut(NnzOut); | |
930 | indx [o]nOut(); | |
931 | ) | |
932 | ||
933 | ||
934 | Accumulated maximum_nz_ind over values $nzvalsIn() associated with vector-valued keys $ixIn(). | |
935 | On return, | |
936 | $ixOut() holds the unique non-"missing" values of $ixIn(), | |
937 | $nzvalsOut() holds the associated values, | |
938 | and | |
939 | $nOut() stores the number of unique non-missing values computed. | |
940 | ||
941 | ||
942 | Output indices index $nzvalsIn, -1 indicates that the missing value is maximal. | |
943 | ||
944 | ||
945 | ||
946 | Returned PDLs are implicitly sliced such that NnzOut==$nOut(). | |
947 | ||
948 | In scalar context, returns only $nzvalsOut(). | |
949 | ||
950 | ||
951 | ||
952 | =for bad | |
953 | ||
954 | ccs_accum_maximum_nz_ind processes bad values. | |
955 | The state of the bad-value flag of the output piddles is unknown. | |
956 | ||
957 | ||
958 | =cut | |
959 | ||
960 | ||
961 | ||
962 | ||
963 | ||
964 | sub PDL::ccs_accum_maximum_nz_ind { | |
965 | my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; | |
966 | my ($ndims,@nnzIn) = $ixIn->dims; | |
967 | my (@nnzOut); | |
968 | if (defined($ixOut)) { | |
969 | @nnzOut = $ixOut->dims; | |
970 | shift(@nnzOut); | |
971 | } | |
972 | ||
973 | @nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); | |
974 | @nnzOut = @nnzIn if (!@nnzOut); | |
975 | $ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) | |
976 | if (!defined($ixOut) || $ixOut->isempty); | |
977 | ||
978 | $nzvalsOut = PDL->zeroes((ccs_indx()), @nnzOut) | |
979 | if (!defined($nzvalsOut) || $nzvalsOut->isempty); | |
980 | ||
981 | $nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); | |
982 | ## | |
983 | ##-- guts | |
984 | &PDL::_ccs_accum_maximum_nz_ind_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); | |
985 | ## | |
986 | ##-- auto-trim | |
987 | $ixOut = $ixOut->slice(",0:".($nOut->max-1)); | |
988 | $nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); | |
989 | ## | |
990 | ##-- return | |
991 | return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; | |
992 | } | |
993 | ||
994 | ||
995 | *ccs_accum_maximum_nz_ind = \&PDL::ccs_accum_maximum_nz_ind; | |
996 | ||
997 | ||
998 | ||
999 | ||
1000 | ||
1001 | =head2 ccs_accum_minimum_nz_ind | |
1002 | ||
1003 | =for sig | |
1004 | ||
1005 | Signature: ( | |
1006 | indx ixIn(Ndims,NnzIn); | |
1007 | nzvalsIn(NnzIn); | |
1008 | missing(); | |
1009 | indx N(); | |
1010 | indx [o]ixOut(Ndims,NnzOut); | |
1011 | indx [o]nzvalsOut(NnzOut); | |
1012 | indx [o]nOut(); | |
1013 | ) | |
1014 | ||
1015 | ||
1016 | Accumulated minimum_nz_ind over values $nzvalsIn() associated with vector-valued keys $ixIn(). | |
1017 | On return, | |
1018 | $ixOut() holds the unique non-"missing" values of $ixIn(), | |
1019 | $nzvalsOut() holds the associated values, | |
1020 | and | |
1021 | $nOut() stores the number of unique non-missing values computed. | |
1022 | ||
1023 | ||
1024 | Output indices index $nzvalsIn, -1 indicates that the missing value is minimal. | |
1025 | ||
1026 | ||
1027 | ||
1028 | Returned PDLs are implicitly sliced such that NnzOut==$nOut(). | |
1029 | ||
1030 | In scalar context, returns only $nzvalsOut(). | |
1031 | ||
1032 | ||
1033 | ||
1034 | =for bad | |
1035 | ||
1036 | ccs_accum_minimum_nz_ind processes bad values. | |
1037 | The state of the bad-value flag of the output piddles is unknown. | |
1038 | ||
1039 | ||
1040 | =cut | |
1041 | ||
1042 | ||
1043 | ||
1044 | ||
1045 | ||
1046 | sub PDL::ccs_accum_minimum_nz_ind { | |
1047 | my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; | |
1048 | my ($ndims,@nnzIn) = $ixIn->dims; | |
1049 | my (@nnzOut); | |
1050 | if (defined($ixOut)) { | |
1051 | @nnzOut = $ixOut->dims; | |
1052 | shift(@nnzOut); | |
1053 | } | |
1054 | ||
1055 | @nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); | |
1056 | @nnzOut = @nnzIn if (!@nnzOut); | |
1057 | $ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) | |
1058 | if (!defined($ixOut) || $ixOut->isempty); | |
1059 | ||
1060 | $nzvalsOut = PDL->zeroes((ccs_indx()), @nnzOut) | |
1061 | if (!defined($nzvalsOut) || $nzvalsOut->isempty); | |
1062 | ||
1063 | $nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); | |
1064 | ## | |
1065 | ##-- guts | |
1066 | &PDL::_ccs_accum_minimum_nz_ind_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); | |
1067 | ## | |
1068 | ##-- auto-trim | |
1069 | $ixOut = $ixOut->slice(",0:".($nOut->max-1)); | |
1070 | $nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); | |
1071 | ## | |
1072 | ##-- return | |
1073 | return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; | |
1074 | } | |
1075 | ||
1076 | ||
1077 | *ccs_accum_minimum_nz_ind = \&PDL::ccs_accum_minimum_nz_ind; | |
1078 | ||
1079 | ||
1080 | ||
1081 | ||
1082 | ||
1083 | =head2 ccs_accum_nbad | |
1084 | ||
1085 | =for sig | |
1086 | ||
1087 | Signature: ( | |
1088 | indx ixIn(Ndims,NnzIn); | |
1089 | nzvalsIn(NnzIn); | |
1090 | missing(); | |
1091 | indx N(); | |
1092 | indx [o]ixOut(Ndims,NnzOut); | |
1093 | int+ [o]nzvalsOut(NnzOut); | |
1094 | indx [o]nOut(); | |
1095 | ) | |
1096 | ||
1097 | ||
1098 | Accumulated number of bad values over values $nzvalsIn() associated with vector-valued keys $ixIn(). | |
1099 | On return, | |
1100 | $ixOut() holds the unique non-"missing" values of $ixIn(), | |
1101 | $nzvalsOut() holds the associated values, | |
1102 | and | |
1103 | $nOut() stores the number of unique non-missing values computed. | |
1104 | ||
1105 | ||
1106 | Should handle missing values appropriately. | |
1107 | ||
1108 | ||
1109 | ||
1110 | Returned PDLs are implicitly sliced such that NnzOut==$nOut(). | |
1111 | ||
1112 | In scalar context, returns only $nzvalsOut(). | |
1113 | ||
1114 | ||
1115 | ||
1116 | =for bad | |
1117 | ||
1118 | ccs_accum_nbad processes bad values. | |
1119 | The state of the bad-value flag of the output piddles is unknown. | |
1120 | ||
1121 | ||
1122 | =cut | |
1123 | ||
1124 | ||
1125 | ||
1126 | ||
1127 | ||
1128 | sub PDL::ccs_accum_nbad { | |
1129 | my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; | |
1130 | my ($ndims,@nnzIn) = $ixIn->dims; | |
1131 | my (@nnzOut); | |
1132 | if (defined($ixOut)) { | |
1133 | @nnzOut = $ixOut->dims; | |
1134 | shift(@nnzOut); | |
1135 | } | |
1136 | ||
1137 | $nzvalsIn = ccs_indx($nzvalsIn) if ($nzvalsIn->type > ccs_indx()); ##-- max_type_perl=ccs_indx | |
1138 | @nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); | |
1139 | @nnzOut = @nnzIn if (!@nnzOut); | |
1140 | $ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) | |
1141 | if (!defined($ixOut) || $ixOut->isempty); | |
1142 | ||
1143 | $nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) | |
1144 | if (!defined($nzvalsOut) || $nzvalsOut->isempty); | |
1145 | ||
1146 | $nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); | |
1147 | ## | |
1148 | ##-- guts | |
1149 | &PDL::_ccs_accum_nbad_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); | |
1150 | ## | |
1151 | ##-- auto-trim | |
1152 | $ixOut = $ixOut->slice(",0:".($nOut->max-1)); | |
1153 | $nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); | |
1154 | ## | |
1155 | ##-- return | |
1156 | return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; | |
1157 | } | |
1158 | ||
1159 | ||
1160 | *ccs_accum_nbad = \&PDL::ccs_accum_nbad; | |
1161 | ||
1162 | ||
1163 | ||
1164 | ||
1165 | ||
1166 | =head2 ccs_accum_ngood | |
1167 | ||
1168 | =for sig | |
1169 | ||
1170 | Signature: ( | |
1171 | indx ixIn(Ndims,NnzIn); | |
1172 | nzvalsIn(NnzIn); | |
1173 | missing(); | |
1174 | indx N(); | |
1175 | indx [o]ixOut(Ndims,NnzOut); | |
1176 | int+ [o]nzvalsOut(NnzOut); | |
1177 | indx [o]nOut(); | |
1178 | ) | |
1179 | ||
1180 | ||
1181 | Accumulated number of good values over values $nzvalsIn() associated with vector-valued keys $ixIn(). | |
1182 | On return, | |
1183 | $ixOut() holds the unique non-"missing" values of $ixIn(), | |
1184 | $nzvalsOut() holds the associated values, | |
1185 | and | |
1186 | $nOut() stores the number of unique non-missing values computed. | |
1187 | ||
1188 | ||
1189 | Should handle missing values appropriately. | |
1190 | ||
1191 | ||
1192 | ||
1193 | Returned PDLs are implicitly sliced such that NnzOut==$nOut(). | |
1194 | ||
1195 | In scalar context, returns only $nzvalsOut(). | |
1196 | ||
1197 | ||
1198 | ||
1199 | =for bad | |
1200 | ||
1201 | ccs_accum_ngood processes bad values. | |
1202 | The state of the bad-value flag of the output piddles is unknown. | |
1203 | ||
1204 | ||
1205 | =cut | |
1206 | ||
1207 | ||
1208 | ||
1209 | ||
1210 | ||
1211 | sub PDL::ccs_accum_ngood { | |
1212 | my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; | |
1213 | my ($ndims,@nnzIn) = $ixIn->dims; | |
1214 | my (@nnzOut); | |
1215 | if (defined($ixOut)) { | |
1216 | @nnzOut = $ixOut->dims; | |
1217 | shift(@nnzOut); | |
1218 | } | |
1219 | ||
1220 | $nzvalsIn = ccs_indx($nzvalsIn) if ($nzvalsIn->type > ccs_indx()); ##-- max_type_perl=ccs_indx | |
1221 | @nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); | |
1222 | @nnzOut = @nnzIn if (!@nnzOut); | |
1223 | $ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) | |
1224 | if (!defined($ixOut) || $ixOut->isempty); | |
1225 | ||
1226 | $nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) | |
1227 | if (!defined($nzvalsOut) || $nzvalsOut->isempty); | |
1228 | ||
1229 | $nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); | |
1230 | ## | |
1231 | ##-- guts | |
1232 | &PDL::_ccs_accum_ngood_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); | |
1233 | ## | |
1234 | ##-- auto-trim | |
1235 | $ixOut = $ixOut->slice(",0:".($nOut->max-1)); | |
1236 | $nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); | |
1237 | ## | |
1238 | ##-- return | |
1239 | return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; | |
1240 | } | |
1241 | ||
1242 | ||
1243 | *ccs_accum_ngood = \&PDL::ccs_accum_ngood; | |
1244 | ||
1245 | ||
1246 | ||
1247 | ||
1248 | ||
1249 | =head2 ccs_accum_nnz | |
1250 | ||
1251 | =for sig | |
1252 | ||
1253 | Signature: ( | |
1254 | indx ixIn(Ndims,NnzIn); | |
1255 | nzvalsIn(NnzIn); | |
1256 | missing(); | |
1257 | indx N(); | |
1258 | indx [o]ixOut(Ndims,NnzOut); | |
1259 | int+ [o]nzvalsOut(NnzOut); | |
1260 | indx [o]nOut(); | |
1261 | ) | |
1262 | ||
1263 | ||
1264 | Accumulated number of non-zero values over values $nzvalsIn() associated with vector-valued keys $ixIn(). | |
1265 | On return, | |
1266 | $ixOut() holds the unique non-"missing" values of $ixIn(), | |
1267 | $nzvalsOut() holds the associated values, | |
1268 | and | |
1269 | $nOut() stores the number of unique non-missing values computed. | |
1270 | ||
1271 | ||
1272 | Should handle missing values appropriately. | |
1273 | ||
1274 | ||
1275 | ||
1276 | Returned PDLs are implicitly sliced such that NnzOut==$nOut(). | |
1277 | ||
1278 | In scalar context, returns only $nzvalsOut(). | |
1279 | ||
1280 | ||
1281 | ||
1282 | =for bad | |
1283 | ||
1284 | ccs_accum_nnz processes bad values. | |
1285 | The state of the bad-value flag of the output piddles is unknown. | |
1286 | ||
1287 | ||
1288 | =cut | |
1289 | ||
1290 | ||
1291 | ||
1292 | ||
1293 | ||
1294 | sub PDL::ccs_accum_nnz { | |
1295 | my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; | |
1296 | my ($ndims,@nnzIn) = $ixIn->dims; | |
1297 | my (@nnzOut); | |
1298 | if (defined($ixOut)) { | |
1299 | @nnzOut = $ixOut->dims; | |
1300 | shift(@nnzOut); | |
1301 | } | |
1302 | ||
1303 | $nzvalsIn = ccs_indx($nzvalsIn) if ($nzvalsIn->type > ccs_indx()); ##-- max_type_perl=ccs_indx | |
1304 | @nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); | |
1305 | @nnzOut = @nnzIn if (!@nnzOut); | |
1306 | $ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) | |
1307 | if (!defined($ixOut) || $ixOut->isempty); | |
1308 | ||
1309 | $nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) | |
1310 | if (!defined($nzvalsOut) || $nzvalsOut->isempty); | |
1311 | ||
1312 | $nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); | |
1313 | ## | |
1314 | ##-- guts | |
1315 | &PDL::_ccs_accum_nnz_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); | |
1316 | ## | |
1317 | ##-- auto-trim | |
1318 | $ixOut = $ixOut->slice(",0:".($nOut->max-1)); | |
1319 | $nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); | |
1320 | ## | |
1321 | ##-- return | |
1322 | return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; | |
1323 | } | |
1324 | ||
1325 | ||
1326 | *ccs_accum_nnz = \&PDL::ccs_accum_nnz; | |
1327 | ||
1328 | ||
1329 | ||
1330 | ||
1331 | ||
1332 | =head2 ccs_accum_average | |
1333 | ||
1334 | =for sig | |
1335 | ||
1336 | Signature: ( | |
1337 | indx ixIn(Ndims,NnzIn); | |
1338 | nzvalsIn(NnzIn); | |
1339 | missing(); | |
1340 | indx N(); | |
1341 | indx [o]ixOut(Ndims,NnzOut); | |
1342 | float+ [o]nzvalsOut(NnzOut); | |
1343 | indx [o]nOut(); | |
1344 | ) | |
1345 | ||
1346 | ||
1347 | Accumulated average over values $nzvalsIn() associated with vector-valued keys $ixIn(). | |
1348 | On return, | |
1349 | $ixOut() holds the unique non-"missing" values of $ixIn(), | |
1350 | $nzvalsOut() holds the associated values, | |
1351 | and | |
1352 | $nOut() stores the number of unique non-missing values computed. | |
1353 | ||
1354 | ||
1355 | If $N() is specified and greater than zero, then the quantity: | |
1356 | ||
1357 | $missing * ($N - (rlevec($ixIn))[0]) / $N | |
1358 | ||
1359 | is added to $nzvalsOut: this is probably What You Want if you are averaging over a virtual | |
1360 | dimension in a sparse index-encoded PDL (see PDL::CCS::Nd for a wrapper class). | |
1361 | ||
1362 | ||
1363 | ||
1364 | Returned PDLs are implicitly sliced such that NnzOut==$nOut(). | |
1365 | ||
1366 | In scalar context, returns only $nzvalsOut(). | |
1367 | ||
1368 | ||
1369 | ||
1370 | =for bad | |
1371 | ||
1372 | ccs_accum_average processes bad values. | |
1373 | The state of the bad-value flag of the output piddles is unknown. | |
1374 | ||
1375 | ||
1376 | =cut | |
1377 | ||
1378 | ||
1379 | ||
1380 | ||
1381 | ||
1382 | sub PDL::ccs_accum_average { | |
1383 | my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; | |
1384 | my ($ndims,@nnzIn) = $ixIn->dims; | |
1385 | my (@nnzOut); | |
1386 | if (defined($ixOut)) { | |
1387 | @nnzOut = $ixOut->dims; | |
1388 | shift(@nnzOut); | |
1389 | } | |
1390 | ||
1391 | @nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); | |
1392 | @nnzOut = @nnzIn if (!@nnzOut); | |
1393 | $ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) | |
1394 | if (!defined($ixOut) || $ixOut->isempty); | |
1395 | ||
1396 | $nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) | |
1397 | if (!defined($nzvalsOut) || $nzvalsOut->isempty); | |
1398 | ||
1399 | $nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); | |
1400 | ## | |
1401 | ##-- guts | |
1402 | &PDL::_ccs_accum_average_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); | |
1403 | ## | |
1404 | ##-- auto-trim | |
1405 | $ixOut = $ixOut->slice(",0:".($nOut->max-1)); | |
1406 | $nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); | |
1407 | ## | |
1408 | ##-- return | |
1409 | return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; | |
1410 | } | |
1411 | ||
1412 | ||
1413 | *ccs_accum_average = \&PDL::ccs_accum_average; | |
1414 | ||
1415 | ||
1416 | ||
1417 | ||
1418 | =pod | |
1419 | ||
1420 | =head1 TODO / NOT YET IMPLEMENTED | |
1421 | ||
1422 | =over 4 | |
1423 | ||
1424 | =item extrema indices | |
1425 | ||
1426 | maximum_ind, minimum_ind: not quite compatible... | |
1427 | ||
1428 | =item statistical aggregates | |
1429 | ||
1430 | daverage, medover, oddmedover, pctover, ... | |
1431 | ||
1432 | =item cumulative functions | |
1433 | ||
1434 | cumusumover, cumuprodover, ... | |
1435 | ||
1436 | =item other stuff | |
1437 | ||
1438 | zcover, intover, minmaximum | |
1439 | ||
1440 | =back | |
1441 | ||
1442 | =cut | |
1443 | ||
1444 | ||
1445 | ||
1446 | ||
1447 | ##--------------------------------------------------------------------- | |
1448 | =pod | |
1449 | ||
1450 | =head1 ACKNOWLEDGEMENTS | |
1451 | ||
1452 | Perl by Larry Wall. | |
1453 | ||
1454 | PDL by Karl Glazebrook, Tuomas J. Lukka, Christian Soeller, and others. | |
1455 | ||
1456 | =cut | |
1457 | ||
1458 | ##---------------------------------------------------------------------- | |
1459 | =pod | |
1460 | ||
1461 | =head1 KNOWN BUGS | |
1462 | ||
1463 | Probably many. | |
1464 | ||
1465 | =cut | |
1466 | ||
1467 | ||
1468 | ##--------------------------------------------------------------------- | |
1469 | =pod | |
1470 | ||
1471 | =head1 AUTHOR | |
1472 | ||
1473 | Bryan Jurish E<lt>moocow@cpan.orgE<gt> | |
1474 | ||
1475 | =head2 Copyright Policy | |
1476 | ||
1477 | Copyright (C) 2007-2013, Bryan Jurish. All rights reserved. | |
1478 | ||
1479 | This package is free software, and entirely without warranty. | |
1480 | You may redistribute it and/or modify it under the same terms | |
1481 | as Perl itself. | |
1482 | ||
1483 | =head1 SEE ALSO | |
1484 | ||
1485 | perl(1), PDL(3perl) | |
1486 | ||
1487 | =cut | |
1488 | ||
1489 | ||
1490 | ||
1491 | ; | |
1492 | ||
1493 | ||
1494 | ||
1495 | # Exit with OK status | |
1496 | ||
1497 | 1; | |
1498 | ||
1499 | ⏎ |
4 | 4 | ##====================================================================== |
5 | 5 | |
6 | 6 | use PDL::VectorValued::Dev; |
7 | my $VERSION = '1.23.7'; ##-- update with perl-reversion from Perl::Version module | |
7 | my $VERSION = '1.23.8'; ##-- update with perl-reversion from Perl::Version module | |
8 | 8 | pp_setversion($VERSION); |
9 | 9 | |
10 | 10 | ##------------------------------------------------------ |
0 | ||
1 | # | |
2 | # GENERATED WITH PDL::PP! Don't modify! | |
3 | # | |
4 | package PDL::CCS::Utils; | |
5 | ||
6 | @EXPORT_OK = qw( PDL::PP nnz PDL::PP nnza PDL::PP ccs_encode_pointers PDL::PP ccs_decode_pointer PDL::PP ccs_pointerlen PDL::PP ccs_xindex1d PDL::PP ccs_xindex2d PDL::PP ccs_dump_which ); | |
7 | %EXPORT_TAGS = (Func=>[@EXPORT_OK]); | |
8 | ||
9 | use PDL::Core; | |
10 | use PDL::Exporter; | |
11 | use DynaLoader; | |
12 | ||
13 | ||
14 | ||
15 | $PDL::CCS::Utils::VERSION = 1.23.7; | |
16 | @ISA = ( 'PDL::Exporter','DynaLoader' ); | |
17 | push @PDL::Core::PP, __PACKAGE__; | |
18 | bootstrap PDL::CCS::Utils $VERSION; | |
19 | ||
20 | ||
21 | ||
22 | ||
23 | ||
24 | #use PDL::CCS::Config; | |
25 | use strict; | |
26 | ||
27 | =pod | |
28 | ||
29 | =head1 NAME | |
30 | ||
31 | PDL::CCS::Utils - Low-level utilities for compressed storage sparse PDLs | |
32 | ||
33 | =head1 SYNOPSIS | |
34 | ||
35 | use PDL; | |
36 | use PDL::CCS::Utils; | |
37 | ||
38 | ##--------------------------------------------------------------------- | |
39 | ## ... stuff happens | |
40 | ||
41 | =cut | |
42 | ||
43 | ||
44 | ||
45 | ||
46 | ||
47 | ||
48 | ||
49 | =head1 FUNCTIONS | |
50 | ||
51 | ||
52 | ||
53 | =cut | |
54 | ||
55 | ||
56 | ||
57 | ||
58 | *ccs_indx = \&PDL::indx; ##-- typecasting for CCS indices | |
59 | ||
60 | ||
61 | ||
62 | =pod | |
63 | ||
64 | =head1 Non-missing Value Counts | |
65 | ||
66 | =cut | |
67 | ||
68 | ||
69 | ||
70 | ||
71 | ||
72 | =head2 nnz | |
73 | ||
74 | =for sig | |
75 | ||
76 | Signature: (a(N); int+ [o]nnz()) | |
77 | ||
78 | Get number of non-zero values in a PDL $a(); | |
79 | For 1d PDLs, should be equivalent to: | |
80 | ||
81 | $nnz = nelem(which($a!=0)); | |
82 | ||
83 | For k>1 dimensional PDLs, projects via number of nonzero elements | |
84 | to N-1 dimensions by computing the number of nonzero elements | |
85 | along the the 1st dimension. | |
86 | ||
87 | ||
88 | =for bad | |
89 | ||
90 | nnz does not process bad values. | |
91 | It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. | |
92 | ||
93 | ||
94 | =cut | |
95 | ||
96 | ||
97 | ||
98 | ||
99 | ||
100 | ||
101 | *nnz = \&PDL::nnz; | |
102 | ||
103 | ||
104 | ||
105 | ||
106 | ||
107 | =head2 nnza | |
108 | ||
109 | =for sig | |
110 | ||
111 | Signature: (a(N); eps(); int+ [o]nnz()) | |
112 | ||
113 | Like nnz() using tolerance constant $eps(). | |
114 | For 1d PDLs, should be equivalent to: | |
115 | ||
116 | $nnz = nelem(which(!$a->approx(0,$eps))); | |
117 | ||
118 | ||
119 | =for bad | |
120 | ||
121 | nnza does not process bad values. | |
122 | It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. | |
123 | ||
124 | ||
125 | =cut | |
126 | ||
127 | ||
128 | ||
129 | ||
130 | ||
131 | ||
132 | *nnza = \&PDL::nnza; | |
133 | ||
134 | ||
135 | ||
136 | ||
137 | =pod | |
138 | ||
139 | =head1 Encoding Utilities | |
140 | ||
141 | =cut | |
142 | ||
143 | ||
144 | ||
145 | ||
146 | ||
147 | =head2 ccs_encode_pointers | |
148 | ||
149 | =for sig | |
150 | ||
151 | Signature: (indx ix(Nnz); indx N(); indx [o]ptr(Nplus1); indx [o]ixix(Nnz)) | |
152 | ||
153 | General CCS encoding utility. | |
154 | ||
155 | Get a compressed storage "pointer" vector $ptr | |
156 | for a dimension of size $N with non-missing values at indices $ix. Also returns a vector | |
157 | $ixix() which may be used as an index for $ix() to align its elements with $ptr() | |
158 | along the compressed dimension. | |
159 | ||
160 | The induced vector $ix-E<gt>index($ixix) is | |
161 | guaranteed to be stably sorted along dimension $N(): | |
162 | ||
163 | \forall $i,$j with 1 <= $i < $j <= $Nnz : | |
164 | ||
165 | $ix->index($ixix)->at($i) < $ix->index($ixix)->at($j) ##-- primary sort on $ix() | |
166 | or | |
167 | $ixix->at($i) < $ixix->at($j) ##-- ... stable | |
168 | ||
169 | ||
170 | ||
171 | =for bad | |
172 | ||
173 | ccs_encode_pointers does not process bad values. | |
174 | It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. | |
175 | ||
176 | ||
177 | =cut | |
178 | ||
179 | ||
180 | ||
181 | ||
182 | ||
183 | sub PDL::ccs_encode_pointers { | |
184 | my ($ix,$N,$ptr,$ixix) = @_; | |
185 | barf("Usage: ccs_encode_pointers(ix(Nnz), N(), [o]ptr(N+1), [o]ixix(Nnz)") if (!defined($ix)); | |
186 | $N = $ix->max()+1 if (!defined($N)); | |
187 | $ptr = PDL->zeroes(ccs_indx(), $N+1) if (!defined($ptr)); | |
188 | $ixix = PDL->zeroes(ccs_indx(), $ix->dim(0)) if (!defined($ixix)); | |
189 | &PDL::_ccs_encode_pointers_int($ix,$N,$ptr,$ixix); | |
190 | return ($ptr,$ixix); | |
191 | } | |
192 | ||
193 | ||
194 | *ccs_encode_pointers = \&PDL::ccs_encode_pointers; | |
195 | ||
196 | ||
197 | ||
198 | ||
199 | =pod | |
200 | ||
201 | =head1 Decoding Utilities | |
202 | ||
203 | =cut | |
204 | ||
205 | ||
206 | ||
207 | ||
208 | ||
209 | =head2 ccs_decode_pointer | |
210 | ||
211 | =for sig | |
212 | ||
213 | Signature: (indx ptr(Nplus1); indx proj(Nproj); indx [o]projix(NnzProj); indx [o]nzix(NnzProj)) | |
214 | ||
215 | General CCS decoding utility. | |
216 | ||
217 | Project indices $proj() from a compressed storage "pointer" vector $proj(). | |
218 | If unspecified, $proj() defaults to: | |
219 | ||
220 | sequence($ptr->dim(0)) | |
221 | ||
222 | ||
223 | ||
224 | =for bad | |
225 | ||
226 | ccs_decode_pointer does not process bad values. | |
227 | It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. | |
228 | ||
229 | ||
230 | =cut | |
231 | ||
232 | ||
233 | ||
234 | ||
235 | ||
236 | sub PDL::ccs_decode_pointer { | |
237 | my ($ptr,$proj,$projix,$nzix) = @_; | |
238 | barf("Usage: ccs_decode_pointer(ptr(N+1), proj(Nproj), [o]projix(NnzProj), [o]nzix(NnzProj)") | |
239 | if (!defined($ptr)); | |
240 | my ($nnzproj); | |
241 | if (!defined($proj)) { | |
242 | $proj = PDL->sequence(ccs_indx(), $ptr->dim(0)-1); | |
243 | $nnzproj = $ptr->at(-1); | |
244 | } | |
245 | if (!defined($projix) || !defined($nzix)) { | |
246 | $nnzproj = ($ptr->index($proj+1)-$ptr->index($proj))->sum if (!defined($nnzproj)); | |
247 | return (null,null) if (!$nnzproj); | |
248 | $projix = PDL->zeroes(ccs_indx(), $nnzproj) if (!defined($projix)); | |
249 | $nzix = PDL->zeroes(ccs_indx(), $nnzproj) if (!defined($nzix)); | |
250 | } | |
251 | &PDL::_ccs_decode_pointer_int($ptr,$proj,$projix,$nzix); | |
252 | return ($projix,$nzix); | |
253 | } | |
254 | ||
255 | ||
256 | *ccs_decode_pointer = \&PDL::ccs_decode_pointer; | |
257 | ||
258 | ||
259 | ||
260 | ||
261 | ||
262 | =head2 ccs_pointerlen | |
263 | ||
264 | =for sig | |
265 | ||
266 | Signature: (ptr(Nplus1); [o]ptrlen(N)) | |
267 | ||
268 | ||
269 | Get number of non-missing values for each axis value from a CCS-encoded | |
270 | offset pointer vector $ptr(). | |
271 | ||
272 | ||
273 | ||
274 | =for bad | |
275 | ||
276 | ccs_pointerlen does not process bad values. | |
277 | It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. | |
278 | ||
279 | ||
280 | =cut | |
281 | ||
282 | ||
283 | ||
284 | ||
285 | ||
286 | sub PDL::ccs_pointerlen { | |
287 | my ($ptr,$len) = @_; | |
288 | $len = zeroes($ptr->type, $ptr->nelem-1) if (!defined($len)); | |
289 | &PDL::_ccs_pointerlen_int($ptr,$len); | |
290 | return $len; | |
291 | } | |
292 | ||
293 | ||
294 | *ccs_pointerlen = \&PDL::ccs_pointerlen; | |
295 | ||
296 | ||
297 | ||
298 | ||
299 | =pod | |
300 | ||
301 | =head1 Indexing Utilities | |
302 | ||
303 | =cut | |
304 | ||
305 | ||
306 | ||
307 | ||
308 | ||
309 | =head2 ccs_xindex1d | |
310 | ||
311 | =for sig | |
312 | ||
313 | Signature: (which(Ndims,Nnz); a(Na); [o]nzia(NnzA); [o]nnza()) | |
314 | ||
315 | ||
316 | Compute indices $nzai() along dimension C<NNz> of $which() whose initial values $which(0,$nzai) | |
317 | match some element of $a(). Appropriate for indexing a sparse encoded PDL | |
318 | with non-missing entries at $which() | |
319 | along the 0th dimension, a la L<dice_axis(0,$a)|PDL::Slices/dice_axis>. | |
320 | $which((0),) and $a() must be both sorted in ascending order. | |
321 | ||
322 | In list context, returns a list ($nzai,$nnza), where $nnza() is the number of indices found, | |
323 | and $nzai are those C<Nnz> indices. In scalar context, trims the output vector $nzai() to $nnza() | |
324 | elements. | |
325 | ||
326 | ||
327 | ||
328 | =for bad | |
329 | ||
330 | ccs_xindex1d does not process bad values. | |
331 | It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. | |
332 | ||
333 | ||
334 | =cut | |
335 | ||
336 | ||
337 | ||
338 | ||
339 | ||
340 | sub PDL::ccs_xindex1d { | |
341 | my ($which,$a,$nzia,$nnza) = @_; | |
342 | barf("Usage: ccs_xindex2d(which(Ndims,Nnz), a(Na), [o]nzia(NnzA), [o]nnza()") | |
343 | if ((grep {!defined($_)} @_[0..1]) || $which->ndims < 2 || $which->dim(0) < 1); | |
344 | $nnza = $nzia->dim(0) if (defined($nzia) && !defined($nnza)); | |
345 | $nnza = $which->dim(1) if (!defined($nnza)); | |
346 | $nnza = pdl($which->type, $nnza) if (!ref($nnza)); | |
347 | $nzia = PDL->zeroes($which->type, $nnza->sclr) if (!defined($nzia)); | |
348 | &PDL::_ccs_xindex1d_int($which,$a,$nzia,$nnza); | |
349 | return ($nzia,$nnza) if (wantarray); | |
350 | return $nzia->reshape($nnza->sclr); | |
351 | } | |
352 | ||
353 | ||
354 | *ccs_xindex1d = \&PDL::ccs_xindex1d; | |
355 | ||
356 | ||
357 | ||
358 | ||
359 | ||
360 | =head2 ccs_xindex2d | |
361 | ||
362 | =for sig | |
363 | ||
364 | Signature: (which(Ndims,Nnz); a(Na); b(Nb); [o]ab(Nab); [o]nab()) | |
365 | ||
366 | ||
367 | Compute indices along dimension C<NNz> of $which() corresponding to any combination | |
368 | of values in the Cartesian product of $a() and $b(). Appropriate for indexing a | |
369 | 2d sparse encoded PDL with non-missing entries at $which() via the ND-index piddle | |
370 | $a-E<gt>slice("*1,")-E<gt>cat($b)-E<gt>clump(2)-E<gt>xchg(0,1), i.e. all pairs $ai,$bi with $ai in $a() | |
371 | and $bi in $b(). $a() and $b() values must be be sorted in ascending order | |
372 | ||
373 | In list context, returns a list ($ab,$nab), where $nab() is the number of indices found, | |
374 | and $ab are those C<Nnz> indices. In scalar context, trims the output vector $ab() to $nab() | |
375 | elements. | |
376 | ||
377 | ||
378 | ||
379 | =for bad | |
380 | ||
381 | ccs_xindex2d does not process bad values. | |
382 | It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. | |
383 | ||
384 | ||
385 | =cut | |
386 | ||
387 | ||
388 | ||
389 | ||
390 | ||
391 | sub PDL::ccs_xindex2d { | |
392 | my ($which,$a,$b,$ab,$nab) = @_; | |
393 | barf("Usage: ccs_xindex2d(which(2,Nnz), a(Na), b(Nb), [o]nab(), [o]ab(Nab)") | |
394 | if ((grep {!defined($_)} @_[0..2]) || $which->ndims != 2 || $which->dim(0) < 2); | |
395 | $nab = $ab->dim(0) if (defined($ab) && !defined($nab)); | |
396 | if (!defined($nab)) { | |
397 | $nab = $a->nelem*$b->nelem; | |
398 | $nab = $which->dim(1) if ($which->dim(1)) < $nab; | |
399 | } | |
400 | $nab = pdl($which->type, $nab) if (!ref($nab)); | |
401 | $ab = PDL->zeroes($which->type, $nab->sclr) if (!defined($ab)); | |
402 | &PDL::_ccs_xindex2d_int($which,$a,$b,$ab,$nab); | |
403 | return ($ab,$nab) if (wantarray); | |
404 | return $ab->reshape($nab->sclr); | |
405 | } | |
406 | ||
407 | ||
408 | *ccs_xindex2d = \&PDL::ccs_xindex2d; | |
409 | ||
410 | ||
411 | ||
412 | ||
413 | =pod | |
414 | ||
415 | =head1 Debugging Utilities | |
416 | ||
417 | =cut | |
418 | ||
419 | ||
420 | ||
421 | ||
422 | ||
423 | =head2 ccs_dump_which | |
424 | ||
425 | =for sig | |
426 | ||
427 | Signature: (indx which(Ndims,Nnz); SV *HANDLE; char *fmt; char *fsep; char *rsep) | |
428 | ||
429 | ||
430 | Print a text dump of an index PDL to the filehandle C<HANDLE>, which default to C<STDUT>. | |
431 | C<$fmt> is a printf() format to use for output, which defaults to "%d". | |
432 | C<$fsep> and C<$rsep> are field-and record separators, which default to | |
433 | a single space and C<$/>, respectively. | |
434 | ||
435 | ||
436 | ||
437 | =for bad | |
438 | ||
439 | ccs_dump_which does not process bad values. | |
440 | It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles. | |
441 | ||
442 | ||
443 | =cut | |
444 | ||
445 | ||
446 | ||
447 | ||
448 | ||
449 | sub PDL::ccs_dump_which { | |
450 | my ($which,$fh,$fmt,$fsep,$rsep) = @_; | |
451 | $fmt = '%d' if (!defined($fmt) || $fmt eq ''); | |
452 | $fsep = " " if (!defined($fsep) || $fsep eq ''); | |
453 | $rsep = "$/" if (!defined($rsep) || $rsep eq ''); | |
454 | $fh = \*STDOUT if (!defined($fh)); | |
455 | &PDL::_ccs_dump_which_int($which,$fh,$fmt,$fsep,$rsep); | |
456 | } | |
457 | ||
458 | ||
459 | *ccs_dump_which = \&PDL::ccs_dump_which; | |
460 | ||
461 | ||
462 | ||
463 | ||
464 | ##--------------------------------------------------------------------- | |
465 | =pod | |
466 | ||
467 | =head1 ACKNOWLEDGEMENTS | |
468 | ||
469 | Perl by Larry Wall. | |
470 | ||
471 | PDL by Karl Glazebrook, Tuomas J. Lukka, Christian Soeller, and others. | |
472 | ||
473 | =cut | |
474 | ||
475 | ##---------------------------------------------------------------------- | |
476 | =pod | |
477 | ||
478 | =head1 KNOWN BUGS | |
479 | ||
480 | Probably many. | |
481 | ||
482 | =cut | |
483 | ||
484 | ||
485 | ##--------------------------------------------------------------------- | |
486 | =pod | |
487 | ||
488 | =head1 AUTHOR | |
489 | ||
490 | Bryan Jurish E<lt>moocow@cpan.orgE<gt> | |
491 | ||
492 | =head2 Copyright Policy | |
493 | ||
494 | Copyright (C) 2007-2013, Bryan Jurish. All rights reserved. | |
495 | ||
496 | This package is free software, and entirely without warranty. | |
497 | You may redistribute it and/or modify it under the same terms | |
498 | as Perl itself. | |
499 | ||
500 | =head1 SEE ALSO | |
501 | ||
502 | perl(1), PDL(3perl) | |
503 | ||
504 | =cut | |
505 | ||
506 | ||
507 | ||
508 | ; | |
509 | ||
510 | ||
511 | ||
512 | # Exit with OK status | |
513 | ||
514 | 1; | |
515 | ||
516 | ⏎ |
4 | 4 | ##====================================================================== |
5 | 5 | |
6 | 6 | use PDL::VectorValued::Dev; |
7 | my $VERSION = '1.23.7'; ##-- update with perl-reversion from Perl::Version module | |
7 | my $VERSION = '1.23.8'; ##-- update with perl-reversion from Perl::Version module | |
8 | 8 | pp_setversion($VERSION); |
9 | 9 | |
10 | 10 | ##------------------------------------------------------ |
2 | 2 | ## Description: set version for PDL::CCS |
3 | 3 | |
4 | 4 | package PDL::CCS::Version; |
5 | our $VERSION = '1.23.7'; ##-- update with perl-reversion from Perl::Version module | |
5 | our $VERSION = '1.23.8'; ##-- update with perl-reversion from Perl::Version module | |
6 | 6 | |
7 | 7 | 1; ##-- make perl happy |
14 | 14 | use PDL::CCS::IO::FastRaw; |
15 | 15 | use strict; |
16 | 16 | |
17 | our $VERSION = '1.23.7'; ##-- update with perl-reversion from Perl::Version module | |
17 | our $VERSION = '1.23.8'; ##-- update with perl-reversion from Perl::Version module | |
18 | 18 | our @ISA = ('PDL::Exporter'); |
19 | 19 | our @EXPORT_OK = |
20 | 20 | ( |
0 | v1.23.8 Fri, 15 Jun 2018 13:45:06 +0200 moocow | |
1 | + various fixes for debian packaging (RT bug #125587), | |
2 | patches provided by L. Baillet and G. Herrmann | |
3 | ||
0 | 4 | v1.23.7 Wed, 06 Jun 2018 09:18:55 +0200 moocow |
1 | 5 | + CCS/IO 'clean' target: remove test temporaries t/ccs3.* t/dense3.* |
2 | 6 |
70 | 70 | |
71 | 71 | ##-- config hash |
72 | 72 | use Data::Dumper; |
73 | $Data::Dumper::Sortkeys=1; # reproducible order of hash keys | |
73 | 74 | print CONFIGPM Data::Dumper->Dump([\%cconfig],['*ccsConfig']), "\n"; |
74 | 75 | |
75 | 76 | ##-- type conversion sub |
3 | 3 | "Bryan Jurish" |
4 | 4 | ], |
5 | 5 | "dynamic_config" : 1, |
6 | "generated_by" : "ExtUtils::MakeMaker version 7.1002, CPAN::Meta::Converter version 2.150010", | |
6 | "generated_by" : "ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.141520", | |
7 | 7 | "license" : [ |
8 | 8 | "perl_5" |
9 | 9 | ], |
44 | 44 | } |
45 | 45 | }, |
46 | 46 | "release_status" : "stable", |
47 | "version" : "v1.23.7", | |
48 | "x_serialization_backend" : "JSON::PP version 2.27400" | |
47 | "version" : "v1.23.8" | |
49 | 48 | } |
11 | 11 | PDL::VectorValued: v1.0.4 |
12 | 12 | Test::More: '0' |
13 | 13 | dynamic_config: 1 |
14 | generated_by: 'ExtUtils::MakeMaker version 7.1002, CPAN::Meta::Converter version 2.150010' | |
14 | generated_by: 'ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.141520' | |
15 | 15 | license: perl |
16 | 16 | meta-spec: |
17 | 17 | url: http://module-build.sourceforge.net/META-spec-v1.4.html |
26 | 26 | PDL: '0' |
27 | 27 | PDL::VectorValued: v1.0.4 |
28 | 28 | Test::More: '0' |
29 | version: v1.23.7 | |
30 | x_serialization_backend: 'CPAN::Meta::YAML version 0.018' | |
29 | version: v1.23.8 |