See also 'Matrix Computations 4e', P188 4.4.2 The method of Aason.
u can download that book via Z-Library for free.
% Aasen's algorithm : PAP.'=LTL.', where A is a n-by-n (dense) symmetric
% matrix, L is a unit lower triangular matrix, P is a permutation matrix,
% and T is a symmetric tridiagonal matrix.
function [P,L,T]=Aasen(A)
[m,n]=size(A);
if m ~= n || isequal(A,A')==false
error('A must be symmetric!')
end
P=eye(n);
L=zeros(n);
for i=1:n-2
r=maxIndex(A(:,i),i+1,n);
if abs(A(r,i))>eps
if r~=i+1
A([i+1,r],:)=A([r,i+1],:); % row (i+1) <-> row r
A(:,[i+1,r])=A(:,[r,i+1]); % column (i+1) <-> column r
I=eye(n);I(r,r)=0;I(i+1,r)=1;I(r,i+1)=1;I(i&