Learn R Programming

pbdDMAT (version 0.2-3)

Extract: Extract or Replace Parts of a Distributed Matrix

Description

Operators to extract or replace parts of a distributed matrix.

Usage

x[i, j, ..., ICTXT]

## S3 method for class 'ddmatrix': head(x, n = 6L, ...) ## S3 method for class 'ddmatrix': tail(x, n = 6L, ...)

Arguments

x
numeric distributed matrix.
i, j
indices specifying elements to extract or replace. Indices can be numeric, character, empty, or NULL.
n
a single integer. If positive, size for the resulting object: number of elements for a vector (including lists), rows for a matrix or data frame or lines for a function. If negative, all but the n last/first number of elements of
...
additional arguments.
ICTXT
optional BLACS context number for output

Value

  • Returns a distributed matrix.

Details

[ can be used to extract/replace for a distributed matrix exactly as you would with an ordinary matrix. The functions rely on reblocking across different BLACS contexts. If i is not empty, then the input distributed matrix will be redistributed along context 1, where extracting/deleting rows does not destroy block-cyclicality. Likewise, if j is not empty, then the input distributed matrix will be redistributed along context 2. When extraction is complete, the matrix will be redistributed across its input context.

Examples

Run this code
# Save code in a file "demo.r" and run with 2 processors by
# > mpiexec -np 2 Rscript demo.r

library(pbdDMAT, quiet = TRUE)
init.grid()

# don't do this in production code
x <- matrix(1:9, 3)
x <- as.ddmatrix(x)

y <- x[, -1]
y <- head(y, 2)
print(y)

finalize()

Run the code above in your browser using DataLab