DelayedAperm-class {DelayedArray} | R Documentation

## DelayedAperm objects

### Description

NOTE: This man page is about DelayedArray internals and is provided for developers and advanced users only.

The DelayedAperm class provides a formal representation of a delayed "extended `aperm()`" operation, that is, of a delayed `aperm()` that can drop and/or add ineffective dimensions. Note that since only ineffective dimensions (i.e. dimensions with an extent of 1) can be dropped or added, the length of the output array is guaranteed to be the same as the length of the input array.

DelayedAperm is a concrete subclass of the DelayedUnaryOp virtual class, which itself is a subclass of the DelayedOp virtual class:

                              DelayedOp
                                  ^
                                  |
                            DelayedUnaryOp
                                  ^
                                  |
                             DelayedAperm

DelayedAperm objects are used inside a DelayedArray object to represent the delayed "extended `aperm()`" operations carried by the object. They're never exposed to the end user and are not intended to be manipulated directly.

### Usage

    ## S4 method for signature 'DelayedAperm'
    is_noop(x)

    ## S4 method for signature 'DelayedAperm'
    summary(object, ...)

    ## ~ ~ ~ Seed contract ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

    ## S4 method for signature 'DelayedAperm'
    dim(x)

    ## S4 method for signature 'DelayedAperm'
    dimnames(x)

    ## S4 method for signature 'DelayedAperm'
    extract_array(x, index)

    ## ~ ~ ~ Propagation of sparsity ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

    ## S4 method for signature 'DelayedAperm'
    is_sparse(x)

    ## S4 method for signature 'DelayedAperm'
    extract_sparse_array(x, index)

### Arguments

`x, object` | A DelayedAperm object.
`index` | See `?extract_array` for a description of the `index` argument.
`...` | Not used.

### See Also

- DelayedOp objects.

- `showtree` to visualize the nodes and access the leaves in the tree of delayed operations carried by a DelayedArray object.

- `extract_array` and `extract_sparse_array`.

### Examples

    ## DelayedAperm extends DelayedUnaryOp which extends DelayedOp:
    extends("DelayedAperm")

    ## ---------------------------------------------------------------------
    ## BASIC EXAMPLES
    ## ---------------------------------------------------------------------
    a0 <- array(1:20, dim=c(1, 10, 2))
    A0 <- DelayedArray(a0)
    showtree(A0)

    A <- aperm(A0, perm=c(2, 3, 1))
    showtree(A)
    class(A@seed)       # a DelayedAperm object

    M1 <- drop(A0)
    showtree(M1)
    class(M1@seed)      # a DelayedAperm object

    M2 <- t(M1)
    showtree(M2)
    class(M2@seed)      # a DelayedAperm object

    ## ---------------------------------------------------------------------
    ## PROPAGATION OF SPARSITY
    ## ---------------------------------------------------------------------
    ## DelayedAperm objects always propagate sparsity.

    sa0 <- as(a0, "SparseArraySeed")
    SA0 <- DelayedArray(sa0)
    showtree(SA0)
    is_sparse(SA0)      # TRUE

    SA <- aperm(SA0, perm=c(2, 3, 1))
    showtree(SA)
    class(SA@seed)      # a DelayedAperm object
    is_sparse(SA@seed)  # TRUE

    ## ---------------------------------------------------------------------
    ## SANITY CHECKS
    ## ---------------------------------------------------------------------
    stopifnot(class(A@seed) == "DelayedAperm")
    stopifnot(class(M1@seed) == "DelayedAperm")
    stopifnot(class(M2@seed) == "DelayedAperm")
    stopifnot(class(SA@seed) == "DelayedAperm")
    stopifnot(is_sparse(SA@seed))

[Package DelayedArray version 0.20.0 Index]