for(i in 1:1111){
for(j in 1:2222){
for(k in 1:3333){
y[i, j, k] <- a[i] + b[j, k]
}
}
}
where a[ ], b[, ], y[ , , ] is arrays.
This code take a long time, so I want to vectorization or any treatment to be more faster code.
Someone have any idea to make the code faster.
One way to solve, I am not sure, but by adjusting the index by replicating the arrays, it goes well ?
see for replication:
Replicating 2 dimensional matrix to create a 3 dimensional array (in R)
I am not sure array format make code faster.
If dimensions of arrays a,b,y have same, then the code will simplify by
y <-a+b
and this seems faster code.