Skip to contents

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

The DelayedNaryIsoOp class provides a formal representation of a delayed N-ary isometric operation. It is a concrete subclass of the DelayedNaryOp virtual class, which itself is a subclass of the DelayedOp virtual class:


                          DelayedOp
                              ^
                              |
                        DelayedNaryOp
                              ^
                              |
                       DelayedNaryIsoOp
  

DelayedNaryIsoOp objects are used inside a DelayedArray object to represent the delayed N-ary isometric operation carried by the object. They're never exposed to the end user and are not intended to be manipulated directly.

Usage

# S4 method for class 'DelayedNaryIsoOp'
summary(object, ...)

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

# S4 method for class 'DelayedNaryIsoOp'
dim(x)

# S4 method for class 'DelayedNaryIsoOp'
dimnames(x)

# S4 method for class 'DelayedNaryIsoOp'
extract_array(x, index)

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

# S4 method for class 'DelayedNaryIsoOp'
is_sparse(x)

# S4 method for class 'DelayedNaryIsoOp'
extract_sparse_array(x, index)

Arguments

x, object

A DelayedNaryIsoOp object.

index

See ?extract_array in the S4Arrays package for a description of the index argument.

...

Not used.

See also

Examples

## DelayedNaryIsoOp extends DelayedNaryOp which extends DelayedOp:
extends("DelayedNaryIsoOp")
#> [1] "DelayedNaryIsoOp" "DelayedNaryOp"    "DelayedOp"        "Array"           

## ---------------------------------------------------------------------
## BASIC EXAMPLE
## ---------------------------------------------------------------------
m1 <- matrix(101:130, ncol=5)
m2 <- matrix(runif(30), ncol=5)
M1 <- DelayedArray(m1)
M2 <- DelayedArray(m2)
showtree(M1)
#> 6x5 integer: DelayedMatrix object
#> └─ 6x5 integer: [seed] matrix object
showtree(M2)
#> 6x5 double: DelayedMatrix object
#> └─ 6x5 double: [seed] matrix object

M <- M1 / M2
showtree(M)
#> 6x5 double: DelayedMatrix object
#> └─ 6x5 double: N-ary iso op
#>    ├─ 6x5 integer: [seed] matrix object
#>    └─ 6x5 double: [seed] matrix object
class(M@seed)        # a DelayedNaryIsoOp object
#> [1] "DelayedNaryIsoOp"
#> attr(,"package")
#> [1] "DelayedArray"

## ---------------------------------------------------------------------
## PROPAGATION OF SPARSITY
## ---------------------------------------------------------------------
sm1 <- sparseMatrix(i=c(1, 6), j=c(1, 4), x=c(11, 64), dims=6:5)
SM1 <- DelayedArray(sm1)
sm2 <- sparseMatrix(i=c(2, 6), j=c(1, 5), x=c(21, 65), dims=6:5)
SM2 <- DelayedArray(sm2)
showtree(SM1)
#> 6x5 double, sparse: DelayedMatrix object
#> └─ 6x5 double, sparse: [seed] dgCMatrix object
showtree(SM2)
#> 6x5 double, sparse: DelayedMatrix object
#> └─ 6x5 double, sparse: [seed] dgCMatrix object
is_sparse(SM1)       # TRUE
#> [1] TRUE
is_sparse(SM2)       # TRUE
#> [1] TRUE

SM3 <- SM1 - SM2
showtree(SM3)
#> 6x5 double, sparse: DelayedMatrix object
#> └─ 6x5 double, sparse: N-ary iso op
#>    ├─ 6x5 double, sparse: [seed] dgCMatrix object
#>    └─ 6x5 double, sparse: [seed] dgCMatrix object
class(SM3@seed)      # a DelayedNaryIsoOp object
#> [1] "DelayedNaryIsoOp"
#> attr(,"package")
#> [1] "DelayedArray"
is_sparse(SM3@seed)  # TRUE
#> [1] TRUE

M4 <- SM1 / SM2
showtree(M4)
#> 6x5 double: DelayedMatrix object
#> └─ 6x5 double: N-ary iso op
#>    ├─ 6x5 double, sparse: [seed] dgCMatrix object
#>    └─ 6x5 double, sparse: [seed] dgCMatrix object
class(M4@seed)       # a DelayedNaryIsoOp object
#> [1] "DelayedNaryIsoOp"
#> attr(,"package")
#> [1] "DelayedArray"
is_sparse(M4@seed)   # FALSE
#> [1] FALSE

## ---------------------------------------------------------------------
## SANITY CHECKS
## ---------------------------------------------------------------------
stopifnot(class(M@seed) == "DelayedNaryIsoOp")
stopifnot(class(SM3@seed) == "DelayedNaryIsoOp")
stopifnot(is_sparse(SM3@seed))
stopifnot(class(M4@seed) == "DelayedNaryIsoOp")
stopifnot(!is_sparse(M4@seed))