matinv Subroutine

public subroutine matinv(a, b)

Matrix inversion with LU-decomposition

Arguments

Type IntentOptional AttributesName
real(kind=double), intent(in), dimension(:,:):: a
real(kind=double), intent(out), dimension(:,:):: b

Calls

proc~~matinv~~CallsGraph proc~matinv matinv proc~ludcmp ludcmp proc~matinv->proc~ludcmp proc~outerprod outerprod proc~ludcmp->proc~outerprod

Called by

proc~~matinv~~CalledByGraph proc~matinv matinv proc~colrad colrad proc~colrad->proc~matinv proc~fida_weights_los fida_weights_los proc~fida_weights_los->proc~colrad proc~attenuate attenuate proc~attenuate->proc~colrad proc~npa_weights npa_weights proc~npa_weights->proc~attenuate proc~npa_f npa_f proc~npa_f->proc~attenuate program~fidasim fidasim program~fidasim->proc~fida_weights_los program~fidasim->proc~npa_weights program~fidasim->proc~npa_f proc~npa_mc npa_mc program~fidasim->proc~npa_mc proc~npa_mc->proc~attenuate

Contents

Source Code


Source Code

  subroutine matinv(a, b)
    !+ Matrix inversion with LU-decomposition
    !====================================================
    real(double), dimension(:,:), intent(IN)             :: a
    real(double), dimension(:,:), intent(OUT)            :: b
    real(double), dimension(size(a,dim=1),size(a,dim=2)) :: ah, y
    integer                                              :: i, N
    integer, dimension(size(a,dim=1))                    :: indx
    real(double)                                         :: d
    N = size(a,dim=1)
    if (N /= size(a,dim=2)) stop 'SUB matinv: ludcmp matrix must be square!'
    ah = a
    y  = 0.
    do i = 1, N
       y(i,i) = 1.d0
    enddo
    call ludcmp(ah,indx,d)
    do i = 1, N
       call lubksb(ah,indx,y(:,i))
    enddo
    b = y
  end subroutine matinv