Skip to content

Commit

Permalink
modified: covmat.dat
Browse files Browse the repository at this point in the history
	modified:   covmat.f90
	modified:   covmat.x
	modified:   eigenvalues.dat
	modified:   eigenvectors.dat
	modified:   testing_vectors.dat
  • Loading branch information
cammneto committed Aug 21, 2021
1 parent a8c4473 commit 110bb20
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion covmat.dat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
matriz covariância
covariance matrix
2.3587777777777776 1.9436666666666662
1.9436666666666662 1.7867777777777776
38 changes: 19 additions & 19 deletions covmat.f90
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ program covariance
end do

rewind 10
write (40,FMT='(A6,F5.2)'), 'xbar =', xbar
write (40,FMT='(A6,F5.2)'), 'ybar =', ybar
write (40,*), 'x-xbar y-ybar'
write (40,FMT='(A6,F5.2)') 'xbar =', xbar
write (40,FMT='(A6,F5.2)') 'ybar =', ybar
write (40,*) 'x-xbar y-ybar'
do i=1,N
read(10,FMT='(F4.1,2x,F4.1)') x, y
covxx = covxx + ((x-xbar)**2)/(N-1)
covyy = covyy + ((y-ybar)**2)/(N-1)
write (40,FMT='(F5.2,2x,F5.2)'), x-xbar, y-ybar
write (40,FMT='(F5.2,2x,F5.2)') x-xbar, y-ybar
end do

rewind 10
Expand All @@ -43,19 +43,19 @@ program covariance
covxy = covxy + ((x-xbar)*(y-ybar))/(N-1)
end do

write (30,*),'covariance matrix'
write (30,*), covxx, covxy
write (30,*), covxy, covyy
write (30,*)'covariance matrix'
write (30,*) covxx, covxy
write (30,*) covxy, covyy

D = sqrt((-covxx-covyy)**2 -4*(covxx*covyy-(covxy**2)))

L1 = (covxx + covyy + D)/2

L2 = (covxx + covyy - D)/2

write (50,*),'covariance matrix eigenvalues'
write (50,*), L1
write (50,*), L2
write (50,*)'covariance matrix eigenvalues'
write (50,*) L1
write (50,*) L2

!eigenvectors for L1 eigenvalue
x1 = covxy/sqrt((covxy**2)+(L1-covxx)**2)
Expand All @@ -67,26 +67,26 @@ program covariance

x4 = (L2-covxx)*x3/covxy

write (60,*),'eigenvector associater with L1 =' , L1
write (60,*), x1, x2
write (60,*),'eigenvector associater with L2 =' , L2
write (60,*), x3, x4
write (60,*) 'eigenvector associater with L1 =' , L1
write (60,*) x1, x2
write (60,*) 'eigenvector associater with L2 =' , L2
write (60,*) x3, x4

!cheking eigenvectors calculations for L1 eigenvalue
C1 = covxx*x1 + covxy*x2
C2 = covxy*x1 + covyy*x2
C3 = x1*L1
C4 = x2*L1
write (70,*), 'If the results are equal thus, the eigenvectors are correct.'
write (70,*), C1, '=', C3
write (70,*), C2, '=', C4
write (70,*) 'If the results are equal thus, the eigenvectors are correct.'
write (70,*) C1, '=', C3
write (70,*) C2, '=', C4

!cheking eigenvectors calculations for L2 eigenvalue
C5 = covxx*x3 + covxy*x4
C6 = covxy*x3 + covyy*x4
C7 = x3*L2
C8 = x4*L2
write (70,*), C5, '=', C7
write (70,*), C6, '=', C8
write (70,*) C5, '=', C7
write (70,*) C6, '=', C8

end program
Binary file modified covmat.x
Binary file not shown.
2 changes: 1 addition & 1 deletion eigenvalues.dat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Autovalores da matriz covariância
covariance matrix eigenvalues
4.03737354
0.108182102
4 changes: 2 additions & 2 deletions eigenvectors.dat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Autovetores para o autovalor = 4.03737354
eigenvector associater with L1 = 4.03737354
0.75682790929801680 0.65361419484860706
Autovetores para o autovalor = 0.108182102
eigenvector associater with L2 = 0.108182102
0.65361416925583182 -0.75682793140053228
2 changes: 1 addition & 1 deletion testing_vectors.dat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Se as igualdades estão corretas encontramos autovalores e autovetores corretamente.
If the results are equal thus, the eigenvectors are correct.
3.05559707 = 3.05559707
2.63888454 = 2.63888454
7.07093552E-02 = 7.07093552E-02
Expand Down

0 comments on commit 110bb20

Please sign in to comment.