view general/numerical/inv_triu.m @ 6:0ce3c2070089

Removed duplicate code and fixed doc in timed_action.
author samer
date Mon, 14 Jan 2013 14:33:37 +0000
parents e44f49929e56
children
line wrap: on
line source
function t=inv_triu(t)
% inv_triu - Inverse of upper triangular matrix
% 
% inv_triu :: [[N,N]] -> [[N,N]].

n=size(t,1);
for k=1:n
	if t(k,k)~=0
		t(k,k) = 1/t(k,k);
		t(1:k-1,k) = -t(1:k-1,k) * t(k,k);

		j = k+1:n;
		temp = t(k,j);
		t(k,j) = 0;
		t(1:k,j) = t(1:k,j) + t(1:k,k)*temp;
	end
end