---
name: "PDL::CCS::Ufunc"
section: "3pm"
platform: "linux"
package: "libpdl-ccs-perl"
version: "1.24.1-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/PDL::CCS::Ufunc"
---

# PDL::CCS::Ufunc(3pm)

Ufuncs for compressed storage sparse PDLs

## NAME

PDL::CCS::Ufunc - Ufuncs for compressed storage sparse PDLs

## SYNOPSIS

```
 use PDL;
 use PDL::CCS::Ufunc;
 ##---------------------------------------------------------------------
 ## ... stuff happens
```

## FUNCTIONS

### ccs\_accum\_prod

```
  Signature: (
    indx ixIn(Ndims,NnzIn);
         nzvalsIn(NnzIn);
         missing();
    indx N();
    indx [o]ixOut(Ndims,NnzOut);
       [o]nzvalsOut(NnzOut);
    indx [o]nOut();
    )
```

Accumulated product over values $**nzvalsIn()** associated with non-missing vector-valued keys $**ixIn()**. On return, $**ixOut()** holds the unique non-"missing" values of $**ixIn()**, $**nzvalsOut()** holds the associated values, and $**nOut()** stores the number of unique non-missing values computed.

If $N() is specified and greater than zero, then the quantity:

```
 $missing ** ($N - (rlevec($ixIn))[0])
```

is multiplied into `$nzvalsOut:` this is probably What You Want if you are computing the product over a virtual dimension in a sparse index-encoded PDL (see PDL::CCS::Nd for a wrapper class).

Returned PDLs are implicitly sliced such that NnzOut==$**nOut()**.

In scalar context, returns only $**nzvalsOut()**.

ccs\_accum\_prod processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

### ccs\_accum\_dprod

```
  Signature: (
    indx ixIn(Ndims,NnzIn);
         nzvalsIn(NnzIn);
         missing();
    indx N();
    indx [o]ixOut(Ndims,NnzOut);
    double [o]nzvalsOut(NnzOut);
    indx [o]nOut();
    )
```

Accumulated double-precision product over values $**nzvalsIn()** associated with non-missing vector-valued keys $**ixIn()**. On return, $**ixOut()** holds the unique non-"missing" values of $**ixIn()**, $**nzvalsOut()** holds the associated values, and $**nOut()** stores the number of unique non-missing values computed.

If $N() is specified and greater than zero, then the quantity:

```
 $missing ** ($N - (rlevec($ixIn))[0])
```

is multiplied into `$nzvalsOut:` this is probably What You Want if you are computing the product over a virtual dimension in a sparse index-encoded PDL (see PDL::CCS::Nd for a wrapper class).

Returned PDLs are implicitly sliced such that NnzOut==$**nOut()**.

In scalar context, returns only $**nzvalsOut()**.

ccs\_accum\_dprod processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

### ccs\_accum\_sum

```
  Signature: (
    indx ixIn(Ndims,NnzIn);
         nzvalsIn(NnzIn);
         missing();
    indx N();
    indx [o]ixOut(Ndims,NnzOut);
       [o]nzvalsOut(NnzOut);
    indx [o]nOut();
    )
```

Accumulated sum over values $**nzvalsIn()** associated with non-missing vector-valued keys $**ixIn()**. On return, $**ixOut()** holds the unique non-"missing" values of $**ixIn()**, $**nzvalsOut()** holds the associated values, and $**nOut()** stores the number of unique non-missing values computed.

If $N() is specified and greater than zero, then the quantity:

```
 $missing * ($N - (rlevec($ixIn))[0])
```

is added to `$nzvalsOut:` this is probably What You Want if you are summing over a virtual dimension in a sparse index-encoded PDL (see PDL::CCS::Nd for a wrapper class).

Returned PDLs are implicitly sliced such that NnzOut==$**nOut()**.

In scalar context, returns only $**nzvalsOut()**.

ccs\_accum\_sum processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

### ccs\_accum\_dsum

```
  Signature: (
    indx ixIn(Ndims,NnzIn);
         nzvalsIn(NnzIn);
         missing();
    indx N();
    indx [o]ixOut(Ndims,NnzOut);
    double [o]nzvalsOut(NnzOut);
    indx [o]nOut();
    )
```

Accumulated double-precision sum over values $**nzvalsIn()** associated with non-missing vector-valued keys $**ixIn()**. On return, $**ixOut()** holds the unique non-"missing" values of $**ixIn()**, $**nzvalsOut()** holds the associated values, and $**nOut()** stores the number of unique non-missing values computed.

If $N() is specified and greater than zero, then the quantity:

```
 $missing * ($N - (rlevec($ixIn))[0])
```

is added to `$nzvalsOut:` this is probably What You Want if you are summing over a virtual dimension in a sparse index-encoded PDL (see PDL::CCS::Nd for a wrapper class).

Returned PDLs are implicitly sliced such that NnzOut==$**nOut()**.

In scalar context, returns only $**nzvalsOut()**.

ccs\_accum\_dsum processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

### ccs\_accum\_or

```
  Signature: (
    indx ixIn(Ndims,NnzIn);
         nzvalsIn(NnzIn);
         missing();
    indx N();
    indx [o]ixOut(Ndims,NnzOut);
       [o]nzvalsOut(NnzOut);
    indx [o]nOut();
    )
```

Accumulated logical "or" over values $**nzvalsIn()** associated with non-missing vector-valued keys $**ixIn()**. On return, $**ixOut()** holds the unique non-"missing" values of $**ixIn()**, $**nzvalsOut()** holds the associated values, and $**nOut()** stores the number of unique non-missing values computed.

If $N() is specified and greater than zero, $**missing()** is logically (or)ed into each result value at each output index with a run length of less than $N() in $**ixIn()**. This is probably What You Want.

Returned PDLs are implicitly sliced such that NnzOut==$**nOut()**.

In scalar context, returns only $**nzvalsOut()**.

ccs\_accum\_or processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

### ccs\_accum\_and

```
  Signature: (
    indx ixIn(Ndims,NnzIn);
         nzvalsIn(NnzIn);
         missing();
    indx N();
    indx [o]ixOut(Ndims,NnzOut);
       [o]nzvalsOut(NnzOut);
    indx [o]nOut();
    )
```

Accumulated logical "and" over values $**nzvalsIn()** associated with non-missing vector-valued keys $**ixIn()**. On return, $**ixOut()** holds the unique non-"missing" values of $**ixIn()**, $**nzvalsOut()** holds the associated values, and $**nOut()** stores the number of unique non-missing values computed.

If $N() is specified and greater than zero, $**missing()** is logically (and)ed into each result value at each output index with a run length of less than $N() in $**ixIn()**. This is probably What You Want.

Returned PDLs are implicitly sliced such that NnzOut==$**nOut()**.

In scalar context, returns only $**nzvalsOut()**.

ccs\_accum\_and processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

### ccs\_accum\_bor

```
  Signature: (
    indx ixIn(Ndims,NnzIn);
         nzvalsIn(NnzIn);
         missing();
    indx N();
    indx [o]ixOut(Ndims,NnzOut);
       [o]nzvalsOut(NnzOut);
    indx [o]nOut();
    )
```

Accumulated bitwise "or" over values $**nzvalsIn()** associated with non-missing vector-valued keys $**ixIn()**. On return, $**ixOut()** holds the unique non-"missing" values of $**ixIn()**, $**nzvalsOut()** holds the associated values, and $**nOut()** stores the number of unique non-missing values computed.

If $N() is specified and greater than zero, $**missing()** is bitwise (or)ed into each result value at each output index with a run length of less than $N() in $**ixIn()**. This is probably What You Want.

Returned PDLs are implicitly sliced such that NnzOut==$**nOut()**.

In scalar context, returns only $**nzvalsOut()**.

ccs\_accum\_bor processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

### ccs\_accum\_band

```
  Signature: (
    indx ixIn(Ndims,NnzIn);
         nzvalsIn(NnzIn);
         missing();
    indx N();
    indx [o]ixOut(Ndims,NnzOut);
       [o]nzvalsOut(NnzOut);
    indx [o]nOut();
    )
```

Accumulated bitwise "and" over values $**nzvalsIn()** associated with non-missing vector-valued keys $**ixIn()**. On return, $**ixOut()** holds the unique non-"missing" values of $**ixIn()**, $**nzvalsOut()** holds the associated values, and $**nOut()** stores the number of unique non-missing values computed.

If $N() is specified and greater than zero, $**missing()** is bitwise (and)ed into each result value at each output index with a run length of less than $N() in $**ixIn()**. This is probably What You Want.

Returned PDLs are implicitly sliced such that NnzOut==$**nOut()**.

In scalar context, returns only $**nzvalsOut()**.

ccs\_accum\_band processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

### ccs\_accum\_maximum

```
  Signature: (
    indx ixIn(Ndims,NnzIn);
         nzvalsIn(NnzIn);
         missing();
    indx N();
    indx [o]ixOut(Ndims,NnzOut);
       [o]nzvalsOut(NnzOut);
    indx [o]nOut();
    )
```

Accumulated maximum over values $**nzvalsIn()** associated with non-missing vector-valued keys $**ixIn()**. On return, $**ixOut()** holds the unique non-"missing" values of $**ixIn()**, $**nzvalsOut()** holds the associated values, and $**nOut()** stores the number of unique non-missing values computed.

If $N() is specified and greater than zero, and if $**missing()** is greater than any listed value for a vector key with a run-length of less than $N(), then $**missing()** is used as the output value for that key. This is probably What You Want.

Returned PDLs are implicitly sliced such that NnzOut==$**nOut()**.

In scalar context, returns only $**nzvalsOut()**.

ccs\_accum\_maximum processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

### ccs\_accum\_minimum

```
  Signature: (
    indx ixIn(Ndims,NnzIn);
         nzvalsIn(NnzIn);
         missing();
    indx N();
    indx [o]ixOut(Ndims,NnzOut);
       [o]nzvalsOut(NnzOut);
    indx [o]nOut();
    )
```

Accumulated minimum over values $**nzvalsIn()** associated with non-missing vector-valued keys $**ixIn()**. On return, $**ixOut()** holds the unique non-"missing" values of $**ixIn()**, $**nzvalsOut()** holds the associated values, and $**nOut()** stores the number of unique non-missing values computed.

If $N() is specified and greater than zero, and if $**missing()** is less than any listed value for a vector key with a run-length of less than $N(), then $**missing()** is used as the output value for that key. This is probably What You Want.

Returned PDLs are implicitly sliced such that NnzOut==$**nOut()**.

In scalar context, returns only $**nzvalsOut()**.

ccs\_accum\_minimum processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

### ccs\_accum\_maximum\_nz\_ind

```
  Signature: (
    indx ixIn(Ndims,NnzIn);
         nzvalsIn(NnzIn);
         missing();
    indx N();
    indx [o]ixOut(Ndims,NnzOut);
    indx [o]nzvalsOut(NnzOut);
    indx [o]nOut();
    )
```

Accumulated maximum\_nz\_ind over values $**nzvalsIn()** associated with non-missing vector-valued keys $**ixIn()**. On return, $**ixOut()** holds the unique non-"missing" values of $**ixIn()**, $**nzvalsOut()** holds the associated values, and $**nOut()** stores the number of unique non-missing values computed.

Output indices index `$nzvalsIn`, -1 indicates that the missing value is maximal.

Returned PDLs are implicitly sliced such that NnzOut==$**nOut()**.

In scalar context, returns only $**nzvalsOut()**.

ccs\_accum\_maximum\_nz\_ind processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

### ccs\_accum\_minimum\_nz\_ind

```
  Signature: (
    indx ixIn(Ndims,NnzIn);
         nzvalsIn(NnzIn);
         missing();
    indx N();
    indx [o]ixOut(Ndims,NnzOut);
    indx [o]nzvalsOut(NnzOut);
    indx [o]nOut();
    )
```

Accumulated minimum\_nz\_ind over values $**nzvalsIn()** associated with non-missing vector-valued keys $**ixIn()**. On return, $**ixOut()** holds the unique non-"missing" values of $**ixIn()**, $**nzvalsOut()** holds the associated values, and $**nOut()** stores the number of unique non-missing values computed.

Output indices index `$nzvalsIn`, -1 indicates that the missing value is minimal.

Returned PDLs are implicitly sliced such that NnzOut==$**nOut()**.

In scalar context, returns only $**nzvalsOut()**.

ccs\_accum\_minimum\_nz\_ind processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

### ccs\_accum\_nbad

```
  Signature: (
    indx ixIn(Ndims,NnzIn);
         nzvalsIn(NnzIn);
         missing();
    indx N();
    indx [o]ixOut(Ndims,NnzOut);
    indx [o]nzvalsOut(NnzOut);
    indx [o]nOut();
    )
```

Accumulated number of bad values over values $**nzvalsIn()** associated with non-missing vector-valued keys $**ixIn()**. On return, $**ixOut()** holds the unique non-"missing" values of $**ixIn()**, $**nzvalsOut()** holds the associated values, and $**nOut()** stores the number of unique non-missing values computed.

Should handle missing values appropriately.

Returned PDLs are implicitly sliced such that NnzOut==$**nOut()**.

In scalar context, returns only $**nzvalsOut()**.

ccs\_accum\_nbad processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

### ccs\_accum\_ngood

```
  Signature: (
    indx ixIn(Ndims,NnzIn);
         nzvalsIn(NnzIn);
         missing();
    indx N();
    indx [o]ixOut(Ndims,NnzOut);
    indx [o]nzvalsOut(NnzOut);
    indx [o]nOut();
    )
```

Accumulated number of good values over values $**nzvalsIn()** associated with non-missing vector-valued keys $**ixIn()**. On return, $**ixOut()** holds the unique non-"missing" values of $**ixIn()**, $**nzvalsOut()** holds the associated values, and $**nOut()** stores the number of unique non-missing values computed.

Should handle missing values appropriately.

Returned PDLs are implicitly sliced such that NnzOut==$**nOut()**.

In scalar context, returns only $**nzvalsOut()**.

ccs\_accum\_ngood processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

### ccs\_accum\_nnz

```
  Signature: (
    indx ixIn(Ndims,NnzIn);
         nzvalsIn(NnzIn);
         missing();
    indx N();
    indx [o]ixOut(Ndims,NnzOut);
    indx [o]nzvalsOut(NnzOut);
    indx [o]nOut();
    )
```

Accumulated number of non-zero values over values $**nzvalsIn()** associated with non-missing vector-valued keys $**ixIn()**. On return, $**ixOut()** holds the unique non-"missing" values of $**ixIn()**, $**nzvalsOut()** holds the associated values, and $**nOut()** stores the number of unique non-missing values computed.

Should handle missing values appropriately.

Returned PDLs are implicitly sliced such that NnzOut==$**nOut()**.

In scalar context, returns only $**nzvalsOut()**.

ccs\_accum\_nnz processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

### ccs\_accum\_average

```
  Signature: (
    indx ixIn(Ndims,NnzIn);
         nzvalsIn(NnzIn);
         missing();
    indx N();
    indx [o]ixOut(Ndims,NnzOut);
    float+ [o]nzvalsOut(NnzOut);
    indx [o]nOut();
    )
```

Accumulated average over values $**nzvalsIn()** associated with non-missing vector-valued keys $**ixIn()**. On return, $**ixOut()** holds the unique non-"missing" values of $**ixIn()**, $**nzvalsOut()** holds the associated values, and $**nOut()** stores the number of unique non-missing values computed.

If $N() is specified and greater than zero, then the quantity:

```
 $missing * ($N - (rlevec($ixIn))[0]) / $N
```

is added to `$nzvalsOut:` this is probably What You Want if you are averaging over a virtual dimension in a sparse index-encoded PDL (see PDL::CCS::Nd for a wrapper class).

Returned PDLs are implicitly sliced such that NnzOut==$**nOut()**.

In scalar context, returns only $**nzvalsOut()**.

ccs\_accum\_average processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

## TODO / NOT YET IMPLEMENTED

- extrema indices

  maximum\_ind, minimum\_ind: not quite compatible...

- statistical aggregates

  daverage, medover, oddmedover, pctover, ...

- cumulative functions

  cumusumover, cumuprodover, ...

- other stuff

  zcover, intover, minmaximum

## ACKNOWLEDGEMENTS

Perl by Larry Wall.

PDL by Karl Glazebrook, Tuomas J. Lukka, Christian Soeller, and others.

## KNOWN BUGS

Probably many.

## AUTHOR

Bryan Jurish \<moocow@cpan.org\>

### Copyright Policy

Copyright (C) 2007-2024, Bryan Jurish. All rights reserved.

This package is free software, and entirely without warranty. You may redistribute it and/or modify it under the same terms as Perl itself.

## SEE ALSO

[**perl**(1)](/perl/1.md), **PDL**(3perl)
