-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlgoritmo1_scriptexperimentacion.m
55 lines (47 loc) · 1.25 KB
/
Algoritmo1_scriptexperimentacion.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
iteracionestotales = 0
iteracionprueba = 0
encontrototal = 0
noencontrototal = 0
tic
for iter=1:100
valido = 0
encontro = 0
noencontro = 0
Iteraciones = 0
epsilon = 10^(-10) %epsilon maquina
Dx = [3-0.9999,1+0.9999,-1,-1,-1,-1]
%for i=1:35
% Dx(i)=((rand-(1/3))*100)
%endfor
Dx = sort(Dx,'descend')
Y = rand(length(Dx)) %Matriz Random Y positiva
Y = Y+Y' %Hace simetrica Y
do
Iteraciones = Iteraciones+1;
[autovec,autoval]=eig(Y)
[autoval,perm] = sort(diag(autoval),'descend')
autovec=autovec(:,perm)
Vy = autovec
Vyt = transpose(Vy)
X = Vy*diag(Dx)*Vyt
X = ((1/2)*(X + transpose(X)))
Y = X
Y(Y<0)=0
until (norm((X-Y),"fro")<epsilon) || (Iteraciones > 1000)
if (Iteraciones <= 1000)
encontro = encontro + 1;
else
noencontro = noencontro + 1;
endif
encontrototal = encontrototal + encontro
noencontrototal = noencontrototal + noencontro
iteracionestotales = iteracionestotales + Iteraciones
iteracionprueba = iter
endfor
toc
printf("========================================================\n")
iteracionestotales
iteracionprueba
encontrototal
noencontrototal
printf("========================================================\n")