!c Description:
!c   連立方程式の解の確からしさの検証
!c
!c Current Code Owner: 
!c   sugiyama@gfd-dennou.org
!c
!c Histry: 
!c   Version    Date          Comment
!c   -------    ----------    --------
!c   1.0        2003-03-17    作成
!c
!c Copyright (C) SUGIYAMA Ko-ichiro, 2003, All rights reserved

module interface_residual
  interface

     subroutine residual(A, B, X, RR)
       implicit none
       real(8), intent(in)  :: A(:,:)           !係数行列
       real(8), intent(in)  :: B(:)             !定数行列
       real(8), intent(in)  :: X(:)             !解行列
       real(8), intent(out) :: RR(:)            !残差
     end subroutine residual

  end interface
end module interface_residual




subroutine residual(A, B, X, RR)
  implicit none
  real(8), intent(in)  :: A(:,:)           !係数行列
  real(8), intent(in)  :: B(:)             !定数行列
  real(8), intent(in)  :: X(:)             !解行列
  real(8), intent(out) :: RR(:)            !残差
  integer :: N, J
  
  
!!!
!!!連立一次方程式の残差の計算
!!!
  N = size(A,1)
  do J = 1, N
     RR(J) = B(J) - dot_product(A(J,:N), X(:N))
  end do
  
  
end subroutine residual

