# PetIGA / src / petigainv.f90.in

 ```Lisandro Dalcin 5e19e94 2012-08-21 Lisandro Dalcin 6fd57f4 2013-03-03 Lisandro Dalcin ca3d144 2012-08-22 Lisandro Dalcin 5e19e94 2012-08-21 Lisandro Dalcin 791c6f2 2013-04-26 Lisandro Dalcin 5e19e94 2012-08-21 Lisandro Dalcin 6fd57f4 2013-03-03 Lisandro Dalcin ca3d144 2012-08-22 Lisandro Dalcin 5e19e94 2012-08-21 Lisandro Dalcin 791c6f2 2013-04-26 Lisandro Dalcin 5e19e94 2012-08-21 Lisandro Dalcin 791c6f2 2013-04-26 Lisandro Dalcin 5e19e94 2012-08-21 ``` ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53``` ```! -*- f90 -*- pure function Determinant(dim,A) result (detA) use PetIGA implicit none integer(kind=IGA_INTEGER_KIND), intent(in) :: dim real (kind=IGA_REAL_KIND ), intent(in) :: A(dim,dim) real (kind=IGA_REAL_KIND ) :: detA select case (dim) case (1) detA = A(1,1) case (2) detA = + A(1,1)*A(2,2) - A(2,1)*A(1,2) case (3) detA = + A(1,1) * ( A(2,2)*A(3,3) - A(3,2)*A(2,3) ) & - A(2,1) * ( A(1,2)*A(3,3) - A(3,2)*A(1,3) ) & + A(3,1) * ( A(1,2)*A(2,3) - A(2,2)*A(1,3) ) case default detA = 0 end select end function Determinant pure function Inverse(dim,detA,A) result (invA) use PetIGA implicit none integer(kind=IGA_INTEGER_KIND), intent(in) :: dim real (kind=IGA_REAL_KIND ), intent(in) :: detA real (kind=IGA_REAL_KIND ), intent(in) :: A(dim,dim) real (kind=IGA_REAL_KIND ) :: invA(dim,dim) select case (dim) case (1) invA = 1/detA case (2) invA(1,1) = + A(2,2) invA(2,1) = - A(2,1) invA(1,2) = - A(1,2) invA(2,2) = + A(1,1) invA = invA/detA case (3) invA(1,1) = + A(2,2)*A(3,3) - A(2,3)*A(3,2) invA(2,1) = - A(2,1)*A(3,3) + A(2,3)*A(3,1) invA(3,1) = + A(2,1)*A(3,2) - A(2,2)*A(3,1) invA(1,2) = - A(1,2)*A(3,3) + A(1,3)*A(3,2) invA(2,2) = + A(1,1)*A(3,3) - A(1,3)*A(3,1) invA(3,2) = - A(1,1)*A(3,2) + A(1,2)*A(3,1) invA(1,3) = + A(1,2)*A(2,3) - A(1,3)*A(2,2) invA(2,3) = - A(1,1)*A(2,3) + A(1,3)*A(2,1) invA(3,3) = + A(1,1)*A(2,2) - A(1,2)*A(2,1) invA = invA/detA case default invA = 0 end select end function Inverse ```