Learn R Programming

pbdBASE (version 0.1-1)

Insert: Directly Insert Into Distributed Matrix Submatrix Slot

Description

Allows you to directly replace the submatrix of a distributed matrix.

Usage

x[i, j] <- value
  submatrix(x) <- value

Arguments

x
numeric distributed matrix.
i, j
global integer indices.
value
replacement value. Must be numeric or NA.

Value

  • Returns a distributed matrix.

Details

[<- allows the user to insert values into a distributed matrix in exactly the same way one would with an ordinary matrix. The indices here are global, meaning that x[i, j] refers to the (i, j)'th element of the "full", global matrix, and not necessarily the (i, j)'th element of the local submatrix.

On the other hand, submatrix<- is not the same functionality with a different name. Instead, it is basically syntactic sugar for: x@Data <- newMatrix It does not alter the distributed matrix x's dim or bldim. It does adjust the ldim automatically. It is merely provided to give consistent behavior with the submatrix() function.

See Also

BLACS, InitGrid

Examples

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

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

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

x[1, ] <- 0
comm.print(submatrix(x), all.rank=T)

finalize()

Run the code above in your browser using DataLab