
A simplified interface to the distribute()
and redistribute()
functions.
as.ddmatrix(x, ...)distribute(x, bldim = .pbd_env$BLDIM, xCTXT = 0, ICTXT = .pbd_env$ICTXT)
# S4 method for matrix
as.ddmatrix(x, bldim = .pbd_env$BLDIM,
ICTXT = .pbd_env$ICTXT)
# S4 method for `NULL`
as.ddmatrix(x, bldim = .pbd_env$BLDIM,
ICTXT = .pbd_env$ICTXT)
# S4 method for vector
as.ddmatrix(x, bldim = .pbd_env$BLDIM,
ICTXT = .pbd_env$ICTXT)
a numeric matrix
Additional arguments.
the blocking dimension for block-cyclically distributing the matrix across the process grid.
the BLACS context number for initial distribution of the matrix
x
.
BLACS context number for return.
Returns a distributed matrix.
A simplified wrapper for the distribute()
function, especially in the
case that the matrix x
is global (which you really should not ever
let happen outside of testing, but I won't stop you).
The function will only work if x
is stored on all processes, or
x
is stored on a single process (does not matter which) and every
other process has NULL stored for x.
If several processes own pieces of the matrix x
, then you can not use
this function. You will have to create an appropriate ddmatrix
on all
processes and redistriubte the data with the redistribute()
function.
As usual, the ICTXT
number is the BLACS context corresponding to the
process grid onto which the output distributed matrix will be distributed.
# NOT RUN {
# 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()
if (comm.rank()==0){
x <- matrix(1:16, ncol=4)
} else {
x <- NULL
}
dx <- as.ddmatrix(x, bldim=2)
dx
### Can also be common to all ranks
y <- matrix(1:25, 5, bldim=2)
dy <- as.ddmatrix(y)
dy
finalize()
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab