I have no better solution than B %*% solve(A), but I would like to note that overall it solve(A,B)works faster and is numerically more stable than that solve(A) %*% B.
> A = matrix(rnorm(10000),100,100)
> B = matrix(rnorm(10000),100,100)
> microbenchmark(solve(A,B), solve(A) %*% B, t(solve(t(B),t(A))), B %*% solve(A))
Unit: microseconds
expr min lq mean median uq max neval
solve(A, B) 481.695 604.2435 722.2512 677.2455 761.735 1280.888 100
solve(A) %*% B 628.243 830.2095 1056.3947 927.0130 1204.682 5275.030 100
t(solve(t(B), t(A))) 603.855 792.1360 1164.7210 924.0895 1122.184 10351.307 100
B %*% solve(A) 645.119 784.1990 1070.4751 927.9400 1097.601 7866.591 100
source
share