4
1
mirror of https://github.com/pfloos/quack synced 2024-09-26 19:41:00 +02:00
quack/src/AOtoMO/AOtoMO.f90
2024-09-01 13:50:29 +02:00

32 lines
805 B
Fortran

subroutine AOtoMO(nBas, nOrb, C, M_AOs, M_MOs)
! Perform AO to MO transformation of a matrix M_AOs for given coefficients c
! M_MOs = C.T M_AOs C
implicit none
integer, intent(in) :: nBas, nOrb
double precision, intent(in) :: C(nBas,nOrb)
double precision, intent(in) :: M_AOs(nBas,nBas)
double precision, intent(out) :: M_MOs(nOrb,nOrb)
double precision, allocatable :: AC(:,:)
allocate(AC(nBas,nOrb))
!AC = matmul(M_AOs, C)
!M_MOs = matmul(transpose(C), AC)
call dgemm("N", "N", nBas, nOrb, nBas, 1.d0, &
M_AOs(1,1), nBas, C(1,1), nBas, &
0.d0, AC(1,1), nBas)
call dgemm("T", "N", nOrb, nOrb, nBas, 1.d0, &
C(1,1), nBas, AC(1,1), nBas, &
0.d0, M_MOs(1,1), nOrb)
deallocate(AC)
end subroutine