The Elk Code
 
Loading...
Searching...
No Matches
trzhmm.f90
Go to the documentation of this file.
1
2! Copyright (C) 2021 J. K. Dewhurst, S. Sharma and E. K. U. Gross.
3! This file is distributed under the terms of the GNU General Public License.
4! See the file COPYING for license details.
5
6!BOP
7! !ROUTINE: trzhmm
8! !INTERFACE:
9pure real(8) function trzhmm(n,a,b)
10! !INPUT/OUTPUT PARAMETERS:
11! n : order of matrix (in,integer)
12! a : Hermitian matrix A (in,complex(n,n))
13! b : Hermitian matrix B (in,complex(n,n))
14! !DESCRIPTION:
15! Calculates the trace of the product of two Hermitian matrices, $\tr(AB)$.
16! Only the upper triangular parts of $A$ and $B$ are referenced.
17!
18! !REVISION HISTORY:
19! Created December 2021 (JKD)
20!EOP
21!BOC
22implicit none
23! arguments
24integer, intent(in) :: n
25complex(8), intent(in) :: a(n,n),b(n,n)
26! local variables
27integer i,j
28real(8) sm
29sm=0.d0
30! off-diagonal contribution (use upper triangular part)
31do j=1,n
32 do i=1,j-1
33 sm=sm+dble(a(i,j)*conjg(b(i,j)))
34 end do
35end do
36sm=sm*2.d0
37! diagonal contribution
38do i=1,n
39 sm=sm+dble(a(i,i))*dble(b(i,i))
40end do
41trzhmm=sm
42end function
43!EOC
44
pure real(8) function trzhmm(n, a, b)
Definition trzhmm.f90:10