Skip to content

Commit

Permalink
Merge pull request #130 from thompsonresearchgroup/master
Browse files Browse the repository at this point in the history
Small bug fix in slater_condon. Restructuring of how to deal with est integrals when there are missing blocks.
  • Loading branch information
leethomo86 authored Mar 29, 2024
2 parents e6b16af + dd50404 commit 09b57fe
Show file tree
Hide file tree
Showing 2 changed files with 689 additions and 253 deletions.
167 changes: 167 additions & 0 deletions src/mqc_algebra.F03
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ Module MQC_Algebra
Procedure, Public::inv => MQC_Matrix_Inverse
!> \brief <b> Returns the determinant of the MQC Matrix</b>
Procedure, Public::det => mqc_matrix_determinant
!> \brief <b> Returns the minor of the MQC Matrix</b>
Procedure, Public::minor => mqc_matrix_minor
!> \brief <b> Returns the cofactor of the MQC Matrix</b>
Procedure, Public::cofactor => mqc_matrix_cofactor
!> \brief <b> Returns the trace of the MQC Matrix</b>
Procedure, Public::trace => mqc_matrix_trace
!> \brief <b> Returns a vector of diagonal elements of the MQC Matrix</b>
Expand Down Expand Up @@ -25094,6 +25098,169 @@ function mqc_matrix_determinant(a) result(det)
end function mqc_matrix_determinant
!
!
! PROCEDURE mqc_matrix_minor
!
!> \brief <b> MQC_Matrix_Minor is a function that returns the minor of
!> an MQC matrix</b>
!
!> \par Purpose:
! =============
!>
!> \verbatim
!>
!> MQC_Matrix_Minor is a function that returns the minor of an MQC
!> matrix.
!>
!> \endverbatim
!
! Arguments:
! ==========
!> \param[in] A
!> \verbatim
!> A is Class(MQC_Matrix)
!> The MQC matrix which will be evaluated.
!> \endverbatim
!>
!> \param[in] I
!> \verbatim
!> I is Integer(kind=int64)
!> The row index of the minor. A negative
!> number evaluates from the last index of
!> the matrix.
!> \endverbatim
!>
!> \param[in] J
!> \verbatim
!> J is Integer(kind=int64)
!> The column index of the minor. A negative
!> number evaluates from the last index of
!> the matrix.
!> \endverbatim
!
! Authors:
! ========
!> \author L. M. Thompson
!> \date 2024
!
function mqc_matrix_minor(a,i,j) result(minor)
!
implicit none
class(mqc_matrix),intent(in)::a
integer(kind=int64),intent(in)::i,j
type(mqc_scalar)::minor
!
integer(kind=int64)::iUse,jUse
type(mqc_matrix)::tmp
!
if(abs(i).gt.mqc_matrix_rows(a)) &
call mqc_error_i('Badly defined index in mqc_matrix_minor',6,'i',i)
if(abs(j).gt.mqc_matrix_columns(a)) &
call mqc_error_i('Badly defined index in mqc_matrix_minor',6,'j',j)
if(i.lt.0) then
iUse = mqc_matrix_rows(a)+i+1
elseif(i.gt.0) then
iUse = i
else
call mqc_error_i('Badly defined index in mqc_matrix_minor',6,'i',i)
endIf
if(j.lt.0) then
jUse = mqc_matrix_columns(a)+j+1
elseif(i.gt.0) then
jUse = j
else
call mqc_error_i('Badly defined index in mqc_matrix_minor',6,'j',j)
endIf

call tmp%init(mqc_matrix_rows(a)-1,mqc_matrix_columns(a)-1)
if(iUse.gt.1.and.jUse.gt.1) call tmp%mput(a%mat([1,iUse-1],[1,jUse-1]),[1,iUse-1],[1,jUse-1])
if(iUse.gt.1.and.jUse.lt.mqc_matrix_columns(a)) &
call tmp%mput(a%mat([1,iUse-1],[jUse+1,-1]),[1,iUse-1],[jUse,-1])
if(iUse.lt.mqc_matrix_rows(a).and.jUse.gt.1) &
call tmp%mput(a%mat([iUse+1,-1],[1,jUse-1]),[iUse,-1],[1,jUse-1])
if(iUse.lt.mqc_matrix_rows(a).and.jUse.lt.mqc_matrix_columns(a)) &
call tmp%mput(a%mat([iUse+1,-1],[jUse+1,-1]),[iUse,-1],[jUse,-1])
minor = tmp%det()

end function mqc_matrix_minor
!
!
! PROCEDURE mqc_matrix_cofactor
!
!> \brief <b> MQC_Matrix_Cofactor is a function that returns the cofactor of
!> an MQC matrix</b>
!
!> \par Purpose:
! =============
!>
!> \verbatim
!>
!> MQC_Matrix_Cofactor is a function that returns the cofactor of an MQC
!> matrix.
!>
!> \endverbatim
!
! Arguments:
! ==========
!> \param[in] A
!> \verbatim
!> A is Class(MQC_Matrix)
!> The MQC matrix which will be evaluated.
!> \endverbatim
!>
!> \param[in] I
!> \verbatim
!> I is Integer(kind=int64)
!> The row index of the cofactor. A negative
!> number evaluates from the last index of
!> the matrix.
!> \endverbatim
!>
!> \param[in] J
!> \verbatim
!> J is Integer(kind=int64)
!> The column index of the cofactor. A negative
!> number evaluates from the last index of
!> the matrix.
!> \endverbatim
!
! Authors:
! ========
!> \author L. M. Thompson
!> \date 2024
!
function mqc_matrix_cofactor(a,i,j) result(cofactor)
!
implicit none
class(mqc_matrix),intent(in)::a
integer(kind=int64),intent(in)::i,j
type(mqc_scalar)::cofactor
!
integer(kind=int64)::iUse,jUse
!
if(abs(i).gt.mqc_matrix_rows(a)) &
call mqc_error_i('Badly defined index in mqc_matrix_minor',6,'i',i)
if(abs(j).gt.mqc_matrix_columns(a)) &
call mqc_error_i('Badly defined index in mqc_matrix_minor',6,'j',j)
if(i.lt.0) then
iUse = mqc_matrix_rows(a)+i+1
elseif(i.gt.0) then
iUse = i
else
call mqc_error_i('Badly defined index in mqc_matrix_minor',6,'i',i)
endIf
if(j.lt.0) then
jUse = mqc_matrix_columns(a)+j+1
elseif(i.gt.0) then
jUse = j
else
call mqc_error_i('Badly defined index in mqc_matrix_minor',6,'j',j)
endIf

cofactor = (-1)**(iUse+jUse)*a%minor(iUse,jUse)

end function mqc_matrix_cofactor
!
!
! PROCEDURE mqc_matrix_inverse
!
!> \brief <b> MQC_Matrix_Inverse is a function that returns the inverse of an MQC
Expand Down
Loading

0 comments on commit 09b57fe

Please sign in to comment.