Learn R Programming

pbdDMAT (version 0.2-3)

Reductions: Arithmetic Reductions: Sums, Means, and Prods

Description

Arithmetic reductions for distributed matrices.

Usage

## S3 method for class 'ddmatrix':
sum(x, ..., na.rm = FALSE)
## S3 method for class 'ddmatrix':
mean(x, na.rm = FALSE)
## S3 method for class 'ddmatrix':
median(x, na.rm = FALSE)
## S3 method for class 'ddmatrix':
prod(x, na.rm = FALSE)
## S3 method for class 'ddmatrix':
rowSums(x, na.rm = FALSE)
## S3 method for class 'ddmatrix':
colSums(x, na.rm = FALSE)
## S3 method for class 'ddmatrix':
rowMeans(x, na.rm = FALSE)
## S3 method for class 'ddmatrix':
colMeans(x, na.rm = FALSE)
## S3 method for class 'ddmatrix':
min(x, na.rm = FALSE)
## S3 method for class 'ddmatrix':
max(x, na.rm = FALSE)
## S3 method for class 'ddmatrix':
rowMin(x, na.rm = FALSE)
## S3 method for class 'ddmatrix':
colMin(x, na.rm = FALSE)
## S3 method for class 'ddmatrix':
rowMax(x, na.rm = FALSE)
## S3 method for class 'ddmatrix':
colMax(x, na.rm = FALSE)

Arguments

x
numeric distributed matrix
na.rm
logical. Should missing (including NaN) be removed?
...
additional arguments

Value

  • Returns a global numeric vector.

Details

Performs the reduction operation on a distributed matrix. There are four legitimately new operations, namely rowMin(), rowMax(), colMin(), and colMax(). These implementations are not really necessary in R because one can easily (and reasonably efficiently) do something like apply(X=x, MARGIN=1L, FUN=min, na.rm=TRUE) But apply() on a ddmatrix is very costly, and should be used sparingly.

See Also

Arithmetic

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 <- sum(colMeans(x))
comm.print(y)

finalize()

Run the code above in your browser using DataLab