File: matmul.R

package info (click to toggle)
r-cran-foreach 1.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 648 kB
  • sloc: makefile: 2
file content (16 lines) | stat: -rw-r--r-- 342 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# simple (and inefficient) parallel matrix multiply

library(foreach)

# generate the input matrices
x <- matrix(rnorm(16), 4)
y <- matrix(rnorm(16), 4)

# multiply the matrices
z <- foreach(y=iter(y, by='col'), .combine=cbind) %dopar% (x %*% y)

# print the results
print(z)

# check the results
print(all.equal(z, x %*% y))