Good afternoon everyone, I'm in need of a factoring algorithm cholesky and algorithms to solve upper and lower triangular systems, but I'm not finding any work in that octave. Recalling that need the algorithm and can not just use the already available functions in the programs. I even tried to adapt this algorithm but it is in trouble in the windows octave
function [G] = cholesky(A,dim)
epsilon = 1.0e-10;
sum = 0.0;
for k = 1:(i-1)
sum = sum + G(k,i)*G(k,i);
end
delta = A(i,i) - sum;
if( delta < 0.0 ), errorspd(delta,i); end
G(i,i) = sqrt(delta);
if( abs(G(i,i)) < epsilon ); end
for j = (i+1):ndim
sum = 0.0;
for k = 1:(i-1)
sum = sum + G(k,i)*G(k,j);
end
G(i,j) = ( A(i,j) - sum ) / G(i,i);
end
end
Thanks in advance
Here is my Matlab code for Cholesky, I hope it works also on Octave. It is taken step by step by the wikipedia Cholesky–Banachiewicz algorithm:
The $L$ obtained is such that $A=LL^T$. For solving upper triangular systems of the form $Ux=b$, I use the next code based on the backward substitution
Meanwhile for lower ones of the form $Lx=b$, I use an algorithm base on the forward substitution
As an example, if you want to solve a system $Ax=b$ where $A$ is symmetric positive definite matrix, then use
to obtain the solution $x$.