program main c*********************************************************************72 c cc matrix_exponential_prb() tests matrix_exponential(). c c Licensing: c c This code is distributed under the MIT license. c c Modified: c c 03 March 2013 c c Author: c c John Burkardt c implicit none call timestamp ( ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'matrix_exponential_test():' write ( *, '(a)' ) ' FORTRAN77 version' write ( *, '(a)' ) ' Test matrix_exponential().' write ( *, '(a)' ) ' The R8LIB and C8LIB libraries are needed.' write ( *, '(a)' ) & ' This test needs the TEST_MATRIX_EXPONENTIAL library.' call matrix_exponential_test01 ( ) call matrix_exponential_test02 ( ) c c Terminate. c write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'matrix_exponential_test():' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)' ) ' ' call timestamp ( ) return end subroutine matrix_exponential_test01 ( ) c*********************************************************************72 c cc MATRIX_EXPONENTIAL_TEST01 compares matrix exponential algorithms. c c Licensing: c c This code is distributed under the MIT license. c c Modified: c c 03 March 2013 c c Author: c c John Burkardt c implicit none integer n_max parameter ( n_max = 10 ) double precision a(n_max,n_max) double precision a_exp(n_max,n_max) integer n integer test integer test_num write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'MATRIX_EXPONENTIAL_TEST01:' write ( *, '(a)' ) & ' R8MAT_EXPM1 is an M-file equivalent to MATLAB''s EXPM' write ( *, '(a)' ) ' R8MAT_EXPM2 uses a Taylor series approach' write ( *, '(a)' ) & ' R8MAT_EXPM3 relies on an eigenvalue calculation.' call r8mat_exp_test_num ( test_num ) do test = 1, test_num write ( *, '(a)' ) ' ' write ( *, '(a,i4)' ) ' Test #', test call r8mat_exp_story ( test ) call r8mat_exp_n ( test, n ) write ( *, '(a,i4)' ) ' Matrix order N = ', n call r8mat_exp_a ( test, n, a ) call r8mat_print ( n, n, a, ' Matrix:' ) call r8mat_expm1 ( n, a, a_exp ) call r8mat_print ( n, n, a_exp, ' EXPM1(A):' ) call r8mat_expm2 ( n, a, a_exp ) call r8mat_print ( n, n, a_exp, ' EXPM2(A):' ) c call r8mat_expm3 ( n, a, a_exp ) c call r8mat_print ( n, n, a_exp, ' EXPM3(A):' ) call r8mat_exp_expa ( test, n, a_exp ) call r8mat_print ( n, n, a_exp, ' Exact Exponential:' ) end do return end subroutine matrix_exponential_test02 ( ) c*********************************************************************72 c cc MATRIX_EXPONENTIAL_TEST02 compares matrix exponential algorithms. c c Licensing: c c This code is distributed under the MIT license. c c Modified: c c 03 March 2013 c c Author: c c John Burkardt c implicit none integer n_max parameter ( n_max = 10 ) double complex a(n_max,n_max) double complex a_exp(n_max,n_max) integer n integer test integer test_num write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'MATRIX_EXPONENTIAL_TEST02:' write ( *, '(a)' ) & ' C8MAT_EXPM1 is an M-file equivalent to MATLAB''s EXPM' write ( *, '(a)' ) ' C8MAT_EXPM2 uses a Taylor series approach' write ( *, '(a)' ) & ' C8MAT_EXPM3 relies on an eigenvalue calculation.' call c8mat_exp_test_num ( test_num ) do test = 1, test_num write ( *, '(a)' ) ' ' write ( *, '(a,i4)' ) ' Test #', test call c8mat_exp_story ( test ) call c8mat_exp_n ( test, n ) write ( *, '(a,i4)' ) ' Matrix order N = ', n call c8mat_exp_a ( test, n, a ) call c8mat_print ( n, n, a, ' Matrix:' ) call c8mat_expm1 ( n, a, a_exp ) call c8mat_print ( n, n, a_exp, ' EXPM1(A):' ) c call c8mat_expm2 ( n, a, a_exp ) c call c8mat_print ( n, n, a_exp, ' EXPM2(A):' ) c call c8mat_expm3 ( n, a, a_exp ) c call c8mat_print ( n, n, a_exp, ' EXPM3(A):' ) call c8mat_exp_expa ( test, n, a_exp ) call c8mat_print ( n, n, a_exp, ' Exact Exponential:' ) end do return end subroutine timestamp ( ) c*********************************************************************72 c cc timestamp() prints the YMDHMS date as a timestamp. c c Licensing: c c This code is distributed under the MIT license. c c Modified: c c 12 June 2014 c c Author: c c John Burkardt 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, trim ( month(m) ), y, h, ':', n, ':', s, '.', mm, & trim ( ampm ) return end