program main use matrix use Jacobi implicit none integer, parameter :: n = 200 real, parameter :: acc = 1e-8 real :: A(n,n), B(n,n) real :: t1, t2 integer :: rots, i, j !---------------------------------------------- ! Construct Simple matrix: !A = unit_matrix(n) !A(1,1) = 1.0 !A(1,3) = 7.0; A(3,1) = 7.0; !A(2,1) = 2.0; A(1,2) = 2.0; !A(2,2) = 5.0 !A(2,3) = 8.0; A(3,2) = 8.0; !A(3,3) = 9.0 !call MatOut('A = B =', A) print *, "Using square matrices of size ", n ! Construct Matrix of Random numbers: print *, '*********************************' print *, 'Matrix of random numbers.' call random_number(A) A = A*10.0 ! Make symmetric: do i = 1,n do j = 1,i-1 A(i,j) = A(j,i) enddo enddo B = A print *, 'Cyclic Method:' call cpu_time(t1) call Cyclic(A, acc, rots) call cpu_time(t2) !call MatOut('Cyclic =', A) print '(" Elapsed time: ",f12.6," msec.")', (t2-t1)*1000 print '(" Number of rotations: ",i6)', rots print *, 'Classical Method:' call cpu_time(t1) call Classical(B, acc, rots) call cpu_time(t2) !call MatOut('Classical =', B) print '(" Elapsed time: ",f12.6," msec.")', (t2-t1)*1000 print '(" Number of rotations: ",i6)', rots print *, '*********************************' print *, 'The Classical method used fever rotations,' print *, 'but takes longer time.' !---------------------------------------------- ! Construct Unit-matrix, except last column wich is random: A = unit_matrix(n) call random_number(A(:,n)) A(:,n) = 10*A(:,n) B = A print *, '' print *, '*********************************' print *, 'Unit-matrix, except last column:' print *, 'Cyclic Method:' call cpu_time(t1) call Cyclic(A, acc, rots) call cpu_time(t2) !call MatOut('Cyclic =', A) print '(" Elapsed time: ",f12.6," msec.")', (t2-t1)*1000 print '(" Number of rotations: ",i6)', rots print *, 'Classical Method:' call cpu_time(t1) call Classical(B, acc, rots) call cpu_time(t2) !call MatOut('Classical =', B) print '(" Elapsed time: ",f12.6," msec.")', (t2-t1)*1000 print '(" Number of rotations: ",i6)', rots print *, '*********************************' end program