Learn R Programming

pbdDMAT (version 0.2-3)

DistributedMatrixCreation: Distributed Matrix Creation

Description

Methods for simple construction of distributed matrices.

Usage

## S3 method for class 'character':
ddmatrix(data, nrow = 1, ncol = 1, byrow = FALSE,
                               ..., min = 0, max = 1, mean = 0, sd = 1,
                               rate = 1, shape, scale = 1, 
                                bldim = .BLDIM, ICTXT = .ICTXT)
## S3 method for class 'matrix':
ddmatrix(data, nrow = 1, ncol = 1, byrow = FALSE,
                               ..., bldim = .BLDIM, ICTXT = .ICTXT)
## S3 method for class 'missing':
ddmatrix(data, nrow = 1, ncol = 1, byrow = FALSE,
                               ..., bldim = .BLDIM, ICTXT = .ICTXT)
## S3 method for class 'vector':
ddmatrix(data, nrow = 1, ncol = 1, byrow = FALSE,
                               ..., bldim = .BLDIM, ICTXT = .ICTXT)
## S3 method for class 'character':
ddmatrix.local(data, nrow = 1, ncol = 1, byrow = FALSE,
                               ..., min = 0, max = 1, mean = 0, sd = 1,
                               rate = 1, shape, scale = 1, 
                                bldim = .BLDIM, ICTXT = .ICTXT)
## S3 method for class 'matrix':
ddmatrix.local(data, nrow = 1, ncol = 1, byrow = FALSE,
                               ..., bldim = .BLDIM, ICTXT = .ICTXT)
## S3 method for class 'missing':
ddmatrix.local(data, nrow = 1, ncol = 1, byrow = FALSE,
                               ..., bldim = .BLDIM, ICTXT = .ICTXT)
## S3 method for class 'vector':
ddmatrix.local(data, nrow = 1, ncol = 1, byrow = FALSE,
                               ..., bldim = .BLDIM, ICTXT = .ICTXT)

Arguments

data
optional data vector.
nrow
number of rows. Global rows for ddmatrix(). Local rows for ddmatrix.local(). See details below.
ncol
number of columns. Global columns for ddmatrix(). Local columns for ddmatrix.local(). See details below.
byrow
logical. If FALSE then the distributed matrix will be filled by column major storage, otherwise row-major.
...
Extra arguments
min, max
Min and max values for random uniform generation.
mean,sd
Mean and standard deviation for random normal generation.
rate
Rate for random exponential generation.
shape,scale
Shape and scale parameters for random weibull generation.
bldim
blocking dimension.
ICTXT
BLACS context number.

Value

  • Returns a distributed matrix.

Details

These methods are simplified methods of creating distributed matrices, including random ones. These methods involve only local computations, i.e., no communication is performed in the construction of a ddmatrix using these methods (in contrast to using as.ddmatrix() et al). For non-character inputs, the methods attempt to mimic R as closely as possible. So ddmatrix(1:3, 5, 7) produces the distributed analogue of matrix(1:3, 5, 7). For character inputs, you may also specify additional parametric family information. The functions predicated with .local generate data with a fixed local dimension, i.e., each processor gets an identical amount of data. Likewise, the remaining functions generate a fixed global amount of data, and each processor may or may not have an identical amount of local data. To ensure good random number generation, you should only consider using the character methods with the comm.set.seed() function from pbdMPI which uses the method of L'Ecuyer via the rlecuyer package.

See Also

as.ddmatrix

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()

dx <- ddmatrix(data="rnorm", nrow=5, ncol=6, mean=10, sd=100)
dy <- ddmatrix(data=1:4, nrow=7, ncol=5)

print(dx)
print(dy)

finalize()

Run the code above in your browser using DataLab