# DSArray-utils: Common operations on DSArray objects In PeteHaitch/DSArray: Compressed In-Memory Representation of 3-Dimensional Arrays That Contain Many Duplicate Slices

## Description

Common operations on DSArray objects

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26``` ```## S4 method for signature 'DSArray' Math(x) ## S4 method for signature 'DSArray' cummax(x) ## S4 method for signature 'DSArray' cummin(x) ## S4 method for signature 'DSArray' cumprod(x) ## S4 method for signature 'DSArray' cumsum(x) ## S4 method for signature 'DSArray' Math2(x) ## S4 method for signature 'DSArray,vector' Ops(e1, e2) ## S4 method for signature 'vector,DSArray' Ops(e1, e2) ## S4 method for signature 'DSArray,DSArray' Ops(e1, e2) ```

## Arguments

 `x, e1, e2` DSArray objects.

## Group Generics

DSArray objects have partial and limited support for the S4 group generics. The following methods are optimally implemented:

`Arith`

`"+"`, `"-"`, `"*"`, `"^"`, `"%%"`, `"%/%"`, `"/"` provided that one argument is a vector of length 1.

`Compare`

`"=="`, `">"`, `"<"`, `"!="`, `"<="`, `">="` provided that one argument is a vector of length 1.

`Logic`

`"&"`, `"|"` provided that one argument is a vector of length 1.

`Ops`

`"Arith"`, `"Compare"`, `"Logic"` provided that one argument is a vector of length 1.

`Math`

`"abs"`, `"sign"`, `"sqrt"`, `"ceiling"`, `"floor"`, `"trunc"`, `"log"`, `"log10"`, `"log2"`, `"log1p"`, `"acos"`, `"acosh"`, `"asin"`, `"asinh"`, `"atan"`, `"atanh"`, `"exp"`, `"expm1"`, `"cos"`, `"cosh"`, `"sin"`, `"sinh"`, `"tan"`, `"tanh"`, `"gamma"`, `"lgamma"`, `"digamma"`, `"trigamma"`

`Math2`

`"round"`, `"signif"`

`Summary`

`"max"`, `"min"`, `"range"`, `"prod"`, `"sum"`, `"any"`, `"all"`

The following methods are sub-optimally implemented, i.e. these methods first densify the data and then call the relevant `base::array`-based method (a warning is given when the data are densified).

`Arith`

`"+"`, `"-"`, `"*"`, `"^"`, `"%%"`, `"%/%"`, `"/"` if one argument is a vector of length greater than 1 or both objects are DSArray instances.

`Compare`

`"=="`, `">"`, `"<"`, `"!="`, `"<="`, `">="` if one argument is a vector of length greater than 1 or both objects are DSArray instances.

`Logic`

`"&"`, `"|"` if one argument is a vector of length greater than 1 or both objects are DSArray instances.

`Ops`

`"Arith"`, `"Compare"`, `"Logic"` if one argument is a vector of length greater than 1 or both objects are DSArray instances.

`Math`

`"cummax"`,`"cummin"`, `"cumprod"`, `"cumsum"`.

Use of these sub-optimal methods rather obviously defeats the purpose of using DSArray objects; contributions adding optimised methods are most welcome (I will add those that are useful in my own work).

The `Complex` S4 group generic is not implemented in any form because the DSArray class does not currently support complex data.

## Author(s)

Peter Hickey

`S4groupGeneric`