! Copyright (C) HPC WORLD (Prometech Software, Inc. and GDEP Solutions, Inc.) All rights reserved. ! ! Permission is hereby granted, free of charge, to any person obtaining a ! copy of this software and associated documentation files (the "Software"), ! to deal in the Software without restriction, including without limitation ! the rights to use, copy, modify, merge, publish, distribute, sublicense, ! and/or sell copies of the Software, and to permit persons to whom the ! Software is furnished to do so, subject to the following conditions: ! ! The above copyright notice and this permission notice shall be included in ! all copies or substantial portions of the Software. ! ! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ! IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ! THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ! FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ! DEALINGS IN THE SOFTWARE. program main implicit none integer, parameter :: m = 5 ! row number of matrix A integer, parameter :: n = m ! column number of matrix A integer, parameter :: nrhs = 2 ! number of vector b integer, parameter :: lda = m integer, parameter :: ldb = n real(8), parameter :: pi = datan(1.0d0)*4.0d0 integer :: i, j, k, min_mn real(8) :: a(lda, n) ! m x m matrix A real(8) :: b(ldb, nrhs) ! n x nrhs RHS (set of vectors b) real(8) :: a1(lda, n) ! initial A real(8) :: b1(ldb, nrhs) ! initial b real(8) :: b2(ldb, nrhs) ! check real(8) :: theta(m) ! variable theta real(8) :: init_L(m, m) ! initial matrix L real(8) :: init_U(m, m) ! initial matrix U real(8) :: temp real(8) :: x1, x2 real(8) :: sum0, relative_error real(8) :: phase, detA ! LAPACK integer, allocatable :: ipiv(:) integer :: info_f, info_s ! Elapsed time function initialized integer ic, icr, icm real*8 cpu0, cpu1, elapsed, t_ac real*8 second external second write (*, *) "Dgetrs (LAPACK)" ! 時間の計測の精度 call system_clock(ic, icr, icm) t_ac = 1.0d0/real(icr, 8) print '(1x,a,e10.5)', 'Time measurement accuracy : ', t_ac write (*, *) 'lda,ldb', lda, ldb ! elements of matrix A ! ここでは、LとUを作り、それらをかけて行列Aを作る。 ! calculation of theta temp = pi/(dble(m)*2.0d0) do i = 1, m theta(i) = dble(i)*temp ! 適当な数 end do ! initial matrix L ! (ここでは、init_Lを転置で定義しているので注意。後のloopでの演算で利点がある。) ! initial matrix U ! case: i = j ! write (*, *) "case: i=j" do i = 1, m init_U(i, i) = 1.0d0 ! det(A) = det(U) = 1 init_L(i, i) = 1.0d0 end do ! case: i > j (lower) ! write (*, *) "i>j" do j = 1, m - 1 do i = j + 1, m init_U(i, j) = 0.0d0 init_L(i, j) = 0.0d0 end do end do ! case: i < j (upper) ! write (*, *) "i