Aggiunto gauss naif e implementato alcuni script come funzioni.

This commit is contained in:
2014-10-08 15:11:46 +02:00
parent 85ff9aa1d0
commit ed6268c665
14 changed files with 133 additions and 125 deletions

5
samples/calculate_eps.m Normal file
View File

@@ -0,0 +1,5 @@
errore = 1;
while 1+errore ~= 1
errore = errore /2;
end
errore = errore *2

View File

@@ -0,0 +1,8 @@
%minimo numero non normalizzato permesso in float
u = 1;
while u~= 0
rmin = u;
u=u/2;
end
rmin

View File

@@ -0,0 +1,11 @@
% completa risoluzione di un sistema lineare usando la riduzione
% in matrice triangolare superiore con gauss pivoting parziale
% e algoritmo di bottom up con sostituzione
U=[4,8,12,16;2,9,6,8;0,1,1,4;6,2,2,4]; % matrice di input
b=[1;-1;2;1]; %termini noti
[x,y] = convert_matrix_to_triangular_matrix_gauss_pivoting(U,b);
[x1] = linear_system_resolver_triangular_matrix(x,y);
x1

View File

@@ -0,0 +1,8 @@
% 1 + sommatoria da 1 a 1e7 di 1e-17
sum = 0;
for i=1:1e7
sum = sum + 1e-17;
end
sum = sum + 1;
sum

View File

@@ -0,0 +1,5 @@
a = 0;
while a~= 5
a= a + 0.625
end

61
samples/test.m Normal file
View File

@@ -0,0 +1,61 @@
&% completa risoluzione di un sistema lineare usando la riduzione
% in matrice triangolare superiore con gauss pivoting parziale
% e algoritmo di bottom up con sostituzione
U=[0,20,30;0,5,3;0,56,34]; % matrice di input
b=[1;2;17]; %termini noti
n= length(b);
U= [U,b];
U
for i=1:1:n-1
x_max = max ( abs(U(i:n,i)) );
if x_max == 0
disp('errore matrice di input, det 0')
break
else
[x,y]= ind2sub(size(U), find (abs(U(i:n,i)) == x_max) );
x= x + i -1;
y = i;
if x~= i
U([i x],:) = U([x i],:);
end
for j=i+1:1:n
U(j,:) = U(j,:) + ( U(i,:) * (- U(j,i) / U(i,i) ) ) ;
end
end
end
if x_max ~= 0
b=U(:,n+1);
U=U(1:n,1:n);
x=[];
n= length(b);
x(n) = b(n)/U(n,n);
for i=n-1:-1:1
somma = 0;
for k=i+1:n
somma=somma+U(i,k) * x(k);
end
x(i) = (b(i) - somma)/ U(i,i);
end
disp ('La soluzione <EFBFBD> ')
x
end

View File

@@ -0,0 +1,4 @@
U=[4,8,12,16;2,9,6,8;0,1,1,4;6,2,2,4];
triu(U)%superiore
tril(U)%inferiore