Displaying 1 result from an estimated 1 matches for "bdom".
Did you mean:
bdm
2001 Jul 10
0
speeding up aperm/ adding repmat
...eral, we can implement this by making B the same size as A by
replicating its entries, then permuting the dimensions so they match
A's, and then doing element-wise multiplication.
Here is the R code:
B2 <- array(B, Asz) # duplicate elements of B to make it same size as A
diffdom <- Adom[-Bdom] # Adom \ Bdom
B2dom <- c(Bdom, diffdom)
perm <- match(Adom, B2dom)
B3 <- aperm(B2, perm) # make B2 have the same order as A (VERY SLOW)
C <- A * B3
In Matlab, there is a quicker way, using 'reshape' and 'repmat': one
can reshape B to have the same number of dimensions...