program main c*********************************************************************72 c cc test_eigen_test() tests test_eigen(). c c Licensing: c c This code is distributed under the MIT license. c c Modified: c c 09 March 2018 c c Author: c c John Burkardt c implicit none call timestamp ( ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'test_eigen_test():' write ( *, '(a)' ) ' Fortran77 version' write ( *, '(a)' ) ' Test test_eigen().' call r8symm_gen_test ( ) call r8nsymm_gen_test ( ) c c Terminate. c write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'test_eigen_test():' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)') ' ' call timestamp ( ) stop 0 end subroutine r8symm_gen_test ( ) c*********************************************************************72 c cc r8symm_gen_test() tests r8symm_gen(). c c Licensing: c c This code is distributed under the MIT license. c c Modified: c c 09 March 2018 c c Author: c c John Burkardt c implicit none integer n parameter ( n = 5 ) double precision a(n,n) double precision aq(n,n) integer i integer j integer k double precision lambda(n) double precision lambda2(n) double precision lambda_dev parameter ( lambda_dev = 5.0D+00 ) double precision lambda_mean parameter ( lambda_mean = 10.0D+00 ) double precision q(n,n) integer seed seed = 123456789 write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'r8symm_gen_test():' write ( *, '(a)' ) ' r8symm_gen() makes an arbitrary size ' write ( *, '(a)' ) ' symmetric matrix with known eigenvalues ' write ( *, '(a)' ) ' and eigenvectors.' write ( *, '(a)' ) ' ' write ( *, '(a)' ) & ' Real data is declared as "DOUBLE PRECISION".' call r8symm_gen ( n, lambda_mean, lambda_dev, seed, a, q, & lambda ) call r8mat_print ( n, n, a, ' The matrix A:' ) call r8mat_print ( n, n, q, ' The eigenvector matrix Q:' ) call r8vec_print ( n, lambda, ' The eigenvalue vector LAMBDA:' ) do i = 1, n do j = 1, n aq(i,j) = 0.0D+00 do k = 1, n aq(i,j) = aq(i,j) + a(i,k) * q(k,j) end do end do end do do j = 1, n lambda2(j) = 0.0D+00 do i = 1, n lambda2(j) = lambda2(j) + aq(i,j) ** 2 end do lambda2(j) = sqrt ( lambda2(j) ) end do call r8vec2_print ( n, lambda, lambda2, & ' LAMBDA versus the column norms of A*Q:' ) return end subroutine r8nsymm_gen_test ( ) c*********************************************************************72 c cc r8nsymm_gen_test() tests r8nsymm_gen(). c c Licensing: c c This code is distributed under the MIT license. c c Modified: c c 05 June 2024 c c Author: c c John Burkardt c implicit none integer n parameter ( n = 5 ) double precision A(n,n) integer i double precision lambda(n) double precision lambda_dev parameter ( lambda_dev = 5.0D+00 ) double precision lambda_mean parameter ( lambda_mean = 10.0D+00 ) double precision Q(n,n) integer seed double precision T(n,n) seed = 123456789 write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'r8nsymm_gen_test()' write ( *, '(a)' ) ' r8nsymm_gen() makes an arbitrary size ' write ( *, '(a)' ) ' nonsymmetric matrix with known eigenvalues ' write ( *, '(a)' ) ' and eigenvectors.' write ( *, '(a)' ) ' ' write ( *, '(a)' ) & ' Real data is declared as "DOUBLE PRECISION".' call r8nsymm_gen ( n, lambda_mean, lambda_dev, seed, A, Q, T ) do i = 1, n lambda(i) = T(i,i) end do call r8vec_sort_bubble_a ( n, lambda ) call r8mat_print ( n, n, A, ' The nonsymmetric matrix A:' ) call r8mat_print ( n, n, Q, ' The orthogonal factor Q:' ) call r8mat_print ( n, n, T, ' The upper triangular matrix T:' ) call r8vec_print ( n, lambda, ' The sorted eigenvalues LAMBDA:' ) return end subroutine timestamp ( ) c*********************************************************************72 c cc timestamp() prints out the current YMDHMS date as a timestamp. c c Discussion: c c This Fortran77 version is made available for cases where the c Fortran90 version cannot be used. c c Licensing: c c This code is distributed under the MIT license. c c Modified: c c 12 January 2007 c c Author: c c John Burkardt c c Parameters: c c None c implicit none character * ( 8 ) ampm integer d character * ( 8 ) date integer h integer m integer mm character * ( 9 ) month(12) integer n integer s character * ( 10 ) time integer y save month data month / & 'January ', 'February ', 'March ', 'April ', & 'May ', 'June ', 'July ', 'August ', & 'September', 'October ', 'November ', 'December ' / call date_and_time ( date, time ) read ( date, '(i4,i2,i2)' ) y, m, d read ( time, '(i2,i2,i2,1x,i3)' ) h, n, s, mm if ( h .lt. 12 ) then ampm = 'AM' else if ( h .eq. 12 ) then if ( n .eq. 0 .and. s .eq. 0 ) then ampm = 'Noon' else ampm = 'PM' end if else h = h - 12 if ( h .lt. 12 ) then ampm = 'PM' else if ( h .eq. 12 ) then if ( n .eq. 0 .and. s .eq. 0 ) then ampm = 'Midnight' else ampm = 'AM' end if end if end if write ( *, & '(i2,1x,a,1x,i4,2x,i2,a1,i2.2,a1,i2.2,a1,i3.3,1x,a)' ) & d, month(m), y, h, ':', n, ':', s, '.', mm, ampm return end