Converts a complex hermitian band matrix into its compact form.
AHLband = linalg_hbandL(Afull,nsubdiag)
a n-by-n matrix of complex doubles
a 1-by-1 matrix of doubles, integer value, positive, the number of non-null subdiagonals of Afull
a nsubdiag+1-by-n matrix of doubles, the Hermitian Band Lower storage format of Afull.
Transforms a complex Hermitian Band matrix into its compact form suitable for the zhbev algorithm. We store in AB only the lower triangular part of the full matrix A.
Afull = [ 3 1+7*%i 0 1-7*%i 4 -2-8*%i 0 -2+8*%i -12 ]; nsubdiag = 1; AHLband=linalg_hbandL(Afull,nsubdiag) expected = [ 3, 4,-12;1-%i*7,-2+%i*8,0] // Combine hbandL and zhbev // Create a n-by-n Hermitian matrix. n = 50; nsubdiag = 5; Ar = zeros(n,n); for i = 1 : n j = (i:i+nsubdiag-1); j = max(min(j,n),1); Ar(i,j) = j; end Ai = zeros(n,n); for i = 1 : n j = (i:i+nsubdiag-1); j = max(min(j,n),1); Ai(i,j) = j; end Afull = (Ar+%i*Ai) + (Ar'-%i*Ai'); // Convert it into band-form AHLband=linalg_hbandL(Afull,nsubdiag); // Use zhbev D = linalg_zhbev ( AHLband ); D = gsort(D,"g","i"); // Compare with spec Dfull = spec(Afull); Dfull = gsort(Dfull,"g","i"); // Display relative error : rtol should be from 10 to 1000 rtol = max(abs(D-Dfull)./abs(D)/%eps) | ![]() | ![]() |