program main !*****************************************************************************80 ! !! simplex_coordinates_test() tests simplex_coordinates(). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 19 September 2010 ! ! Author: ! ! John Burkardt ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer n call timestamp ( ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'simplex_coordinates_test():' write ( *, '(a)' ) ' FORTRAN90 version' write ( *, '(a)' ) ' Test simplex_coordinates().' n = 3 call simplex_coordinates1_test ( n ) call simplex_coordinates2_test ( n ) n = 4 call simplex_coordinates1_test ( n ) call simplex_coordinates2_test ( n ) ! ! Terminate. ! write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'simplex_coordinates_test():' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)' ) ' ' call timestamp ( ) stop 0 end subroutine simplex_coordinates1_test ( n ) !*****************************************************************************80 ! !! simplex_coordinates1_test() tests simplex_coordinates1(). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 19 September 2010 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, integer N, the spatial dimension. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer n real ( kind = rk ) r8_factorial real ( kind = rk ) side real ( kind = rk ) volume real ( kind = rk ) volume2 real ( kind = rk ) x(n,n+1) real ( kind = rk ) xtx(n+1,n+1) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'simplex_coordinates1_test()' write ( *, '(a)' ) ' Test simplex_coordinates1()' call simplex_coordinates1 ( n, x ) call r8mat_transpose_print ( n, n + 1, x, ' Simplex vertex coordinates:' ) side = sqrt ( sum ( ( x(1:n,1) - x(1:n,2) )**2 ) ) call simplex_volume ( n, x, volume ) volume2 = sqrt ( real ( n + 1, kind = rk ) ) / r8_factorial ( n ) & / sqrt ( 2.0D+00**n ) * side**n write ( *, '(a)' ) ' ' write ( *, '(a,g14.6)' ) ' Side length = ', side write ( *, '(a,g14.6)' ) ' Volume = ', volume write ( *, '(a,g14.6)' ) ' Expected volume = ', volume2 xtx = matmul ( transpose ( x ), x ) call r8mat_transpose_print ( n + 1, n + 1, xtx, ' Dot product matrix:' ) return end subroutine simplex_coordinates2_test ( n ) !*****************************************************************************80 ! !! simplex_coordinates2_test() tests simplex_coordinates2(). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 19 September 2010 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, integer N, the spatial dimension. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer n real ( kind = rk ) r8_factorial real ( kind = rk ) side real ( kind = rk ) volume real ( kind = rk ) volume2 real ( kind = rk ) x(n,n+1) real ( kind = rk ) xtx(n+1,n+1) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'simplex_coordinates2_test():' write ( *, '(a)' ) ' Test simplex_coordinates2()' call simplex_coordinates2 ( n, x ) call r8mat_transpose_print ( n, n + 1, x, ' Simplex vertex coordinates:' ) side = sqrt ( sum ( ( x(1:n,1) - x(1:n,2) )**2 ) ) call simplex_volume ( n, x, volume ) volume2 = sqrt ( real ( n + 1, kind = rk ) ) / r8_factorial ( n ) & / sqrt ( 2.0D+00**n ) * side**n write ( *, '(a)' ) ' ' write ( *, '(a,g14.6)' ) ' Side length = ', side write ( *, '(a,g14.6)' ) ' Volume = ', volume write ( *, '(a,g14.6)' ) ' Expected volume = ', volume2 xtx = matmul ( transpose ( x ), x ) call r8mat_transpose_print ( n + 1, n + 1, xtx, ' Dot product matrix:' ) return end subroutine timestamp ( ) !*****************************************************************************80 ! !! timestamp() prints the current YMDHMS date as a time stamp. ! ! Example: ! ! 31 May 2001 9:45:54.872 AM ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 18 May 2013 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! None ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) character ( len = 8 ) ampm integer d integer h integer m integer mm character ( len = 9 ), parameter, dimension(12) :: month = (/ & 'January ', 'February ', 'March ', 'April ', & 'May ', 'June ', 'July ', 'August ', & 'September', 'October ', 'November ', 'December ' /) integer n integer s integer values(8) integer y call date_and_time ( values = values ) y = values(1) m = values(2) d = values(3) h = values(5) n = values(6) s = values(7) mm = values(8) if ( h < 12 ) then ampm = 'AM' else if ( h == 12 ) then if ( n == 0 .and. s == 0 ) then ampm = 'Noon' else ampm = 'PM' end if else h = h - 12 if ( h < 12 ) then ampm = 'PM' else if ( h == 12 ) then if ( n == 0 .and. s == 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