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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
\name{DelayedAperm-class}
\alias{class:DelayedAperm}
\alias{DelayedAperm-class}
\alias{DelayedAperm}
\alias{is_noop,DelayedAperm-method}
\alias{summary.DelayedAperm}
\alias{summary,DelayedAperm-method}
\alias{dim,DelayedAperm-method}
\alias{dimnames,DelayedAperm-method}
\alias{extract_array,DelayedAperm-method}
\alias{is_sparse,DelayedAperm-method}
\alias{extract_sparse_array,DelayedAperm-method}
\alias{updateObject,SeedDimPicker-method}
\title{DelayedAperm objects}
\description{
NOTE: This man page is about \link{DelayedArray} internals and is provided
for developers and advanced users only.
The DelayedAperm class provides a formal representation of a
\emph{delayed "extended \code{aperm()}" operation}, that is, of a delayed
\code{\link[base]{aperm}()} that can drop and/or add \emph{ineffective}
dimensions. Note that since only \emph{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 \link{DelayedUnaryOp} virtual
class, which itself is a subclass of the \link{DelayedOp} virtual class:
\preformatted{
DelayedOp
^
|
DelayedUnaryOp
^
|
DelayedAperm
}
DelayedAperm objects are used inside a \link{DelayedArray} object to
represent the \emph{delayed "extended \code{aperm()}" operations} carried
by the object. They're never exposed to the end user and are not intended
to be manipulated directly.
}
\usage{
\S4method{is_noop}{DelayedAperm}(x)
\S4method{summary}{DelayedAperm}(object, ...)
## ~ ~ ~ Seed contract ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
\S4method{dim}{DelayedAperm}(x)
\S4method{dimnames}{DelayedAperm}(x)
\S4method{extract_array}{DelayedAperm}(x, index)
## ~ ~ ~ Propagation of sparsity ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
\S4method{is_sparse}{DelayedAperm}(x)
\S4method{extract_sparse_array}{DelayedAperm}(x, index)
}
\arguments{
\item{x, object}{
A DelayedAperm object.
}
\item{index}{
See \code{?\link{extract_array}} for a description of the \code{index}
argument.
}
\item{...}{
Not used.
}
}
\seealso{
\itemize{
\item \link{DelayedOp} objects.
\item \code{\link{showtree}} to visualize the nodes and access the
leaves in the tree of delayed operations carried by a
\link{DelayedArray} object.
\item \code{\link{extract_array}} and \code{\link{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))
}
\keyword{methods}
|