Learn R Programming

pbdDMAT (version 0.2-3)

as.matrix: Distributed-to-non-distributed Matrix Converters

Description

Converts objects of class ddmatrix to the requested non-distributed type.

Usage

## S3 method for class 'ddmatrix':
as.vector(x, mode = 'any', proc.dest = 'all')
## S3 method for class 'ddmatrix':
as.matrix(x, proc.dest = 'all', attributes = TRUE)

Arguments

x
numeric distributed matrix
mode
A character string giving an atomic mode or "list", or (except for 'vector') "any".
proc.dest
destination process for storing the matrix
attributes
logical, specifies whether or not the current attributes should be preserved.

Value

  • Returns an ordinary R matrix.

Details

Converts a distributed matrix into a non-distributed vector or matrix. The proc.dest= argument accepts either the BLACS grid position or the MPI rank if the user desires a single process to own the matrix. Alternatively, passing the default value of 'all' will result in all processes owning the matrix. If only a single process owns the undistributed matrix, then all other processes store NULL for that object.

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:16, ncol=4)
dx <- as.ddmatrix(x) 

y <- as.matrix(dx, proc.dest=0)

finalize()

Run the code above in your browser using DataLab