part3_solutions

# part3_solutions - solutions Mon:31:33 2011 1 1 2...

This preview shows pages 1–2. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: solutions.txt Mon Nov 28 08:31:33 2011 1 1: 2:******************************************* 3:./part3.f90 4: 5:PROGRAM part3 6: 7: USE part3_mod 8: 9: IMPLICIT NONE 10: 11: INTEGER, PARAMETER :: m=3,n=3 12: REAL, DIMENSION(m,n) :: mat1 13: REAL, DIMENSION(m) :: eigvec 14: REAL :: tol=0.000001,eigval 15: LOGICAL,DIMENSION(2) :: flag 16: INTEGER :: iters 17: 18: !mat1=getmat(m,n) !*** Input matrix1 from the keyboard 19: 20: !** Explicitly assign matrix to mat1 for testing 21: mat1(1,:)=(/1,5,3/) 22: mat1(2,:)=(/6,3,5/) 23: mat1(3,:)=(/2,8,5/) 24: eigvec=(/1,1,1/) 25: 26: !** Call the power method 27: iters=power1(mat1,eigvec,tol,eigval,flag) 28: 29: PRINT*, "Estimate of eigenvalue : " ,eigval 30: PRINT ’( "Estimate of eigenvector : " ,3f11.6)’,eigvec(1),eigvec(2),eigvec(3) 31: 32: IF (flag(1)) THEN 33: PRINT*, "The method converged to the solution within the given tolerence." 34: ELSE 35: PRINT*, "The method did not to the solution within the given tolerence." 36: ENDIF 37: 38: IF (flag(2)) THEN 39: PRINT*, "The maximum number of iterations was exceeded." 40: ELSE 41: PRINT*, "The maximum number of iterations was not exceeded." 42: PRINT*, "Number of iterations taken : " ,iters 43: ENDIF 44: 45:END PROGRAM part3 46: 47:!******* OUTPUT FROM THE CODE WHEN RUN IS ********* 48:! Estimate of eigenvalue : 13.06310 49:! Estimate of eigenvector : 0.603874 0.856918 1.000000 50:! The method converged to the solution within the given tolerence. 51:! The maximum number of iterations was not exceeded. 52:! Number of iterations taken : 12 53:******************************************* 54: 55: 56:******************************************* 57:./part3_mod.f90 58: 59:MODULE part3_mod 60: 61: IMPLICIT NONE 62: 63: CONTAINS 64: 65: ! *********************************************************************** 66: 67: FUNCTION infnorm(vec) solutions.txt Mon Nov 28 08:31:33 2011 2 68: !** Calculates the infinity norm of vector vec. 69: !*** Dummy declarations 70: REAL, DIMENSION(:), INTENT(IN) :: vec 71: !*** Local declarations 72: REAL :: infnorm 73: 74: infnorm=MAXVAL(ABS(vec))...
View Full Document

## This note was uploaded on 02/13/2012 for the course MATH 5806 taught by Professor Brooks during the Fall '10 term at Minnesota.

### Page1 / 3

part3_solutions - solutions Mon:31:33 2011 1 1 2...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online