0
library(foreach)
library(doMPI)
m<-matrix(as.integer(0),5,5)
cl <- startMPIcluster(count=4)
registerDoMPI(cl)
foreach(b=1:5)%dopar%
{
m[b,]<-c(1:5)
}
在R上運行上面的代碼,我得到了較低的結果。使用foreach〜dopar的計算矩陣R
> m
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 0 0
[2,] 0 0 0 0 0
[3,] 0 0 0 0 0
[4,] 0 0 0 0 0
[5,] 0 0 0 0 0
我該如何獲得適用於行方式替換的矩陣?