## Some tests... [🇷 for BE/BA]

Hi ElMaestro,

» now it gets really interesting.

I made some tests. And results is surprising.

First code:
 using BlockDiagonals using LinearAlgebra using BenchmarkTools Am = rand(150, 150) Bm = rand(150, 150) @rput Am @rput Bm blocks  = [rand(3,3) for i in 1:50] BDm     = BlockDiagonal(blocks) V       = Matrix(BDm) @rput V b1 = @benchmark R"solve(V)" b2 = @benchmark R"solve(Bm)" b3 = @benchmark inv(Bm)

b1 1.109ms VS b2 3.751ms , so R solve block-diagonal matrix more than twice faster.
In Julia b3 2.707 ms: random matrix solving in Julia faster than in R, but more slower then b1 when matrix is block-diagonal.

Second code:

using RCall using BlockDiagonals using LinearAlgebra using BenchmarkTools blocks  = [rand(3,3) for i in 1:50] BDm     = BlockDiagonal(blocks) V       = Matrix(BDm) @rput V @rput blocks b1 = @benchmark inv(V) b2 = @benchmark inv.(blocks) b3 = @benchmark inv(BDm) b4 = @benchmark R"solve(V)" b5 = @benchmark R"for (i in 1:50) {solve(blocks[[i]])}" 

Solving by blocks in R (b5 3.275 ms) really slower (a little more faster than solving random matrix).

But solving block-diagonal matrix in Julia when structure is described takes 56.484 μs (b3 in second code), this is 20 times faster than in R.

I'm trying to discuss this in Julia forum here.

I'am not so expirienced in R, but I think that Solve.block can increase performance for block-diagonal matrices, docs here.  Ing. Helmut Schütz 