# code review – Individual block diagonalisations take more time than single diagonalization of block matrix

Sample Problem of a large block matrix:

I want to find the lowest eigenvalue of a blockdiagonal matrix `h[x]` for a range of values of `x`

• To save the time, I do so by finding the lowest eigenvalue of each block individually and then lowest out of them but

Individual block diagonalizations take more time than single diagonalization of block matrix `h[x]` for a range of values of `x`.

``````b0 = RandomReal[{-1, 1}, {16, 16}]; c0 = RandomReal[{-1, 1}, {64, 64}]; d0 = RandomReal[{-1, 1}, {128, 128}]; e0 = RandomReal[{-1, 1}, {32, 32}];
b = b0 + Transpose[b0];
c = c0 + Transpose[c0];
d = d0 + Transpose[d0];
e = e0 + Transpose[e0];
h[x_] := x*SparseArray[Band[{1, 1}] -> {b, c, d, e}];
AbsoluteTiming[ParallelTable[-Eigenvalues[-h[x], 1, Method -> {"Arnoldi", "Criteria" -> "RealPart"}][], {x, 0.1,5., 0.1}];][]
eigbloc0[x_, bl_] := -Eigenvalues[-h[x][[#, #]], 1, Method -> {"Arnoldi", "Criteria" -> "RealPart"}][] & /@ {blocks[x][[bl]]}
eigbloc1[x_] := Table[eigbloc0[x, bl], {bl, 1, 4, 1}]
AbsoluteTiming[ParallelTable[Min[Flatten[{eigbloc1[x]}]], {x, 0.1, 5., 0.1}];][]
``````

Output:

`7.98266`

`11.7006`

I was expecting lower time for individual block diagonalization, Could anyone suggest me the resolution ?

Posted on Categories Articles