The Elk Code
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:
9 pure 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
22 implicit none
23 ! arguments
24 integer, intent(in) :: n
25 complex(8), intent(in) :: a(n,n),b(n,n)
26 ! local variables
27 integer i,j
28 real(8) sm
29 sm=0.d0
30 ! off-diagonal contribution (use upper triangular part)
31 do j=1,n
32  do i=1,j-1
33  sm=sm+dble(a(i,j)*conjg(b(i,j)))
34  end do
35 end do
36 sm=sm*2.d0
37 ! diagonal contribution
38 do i=1,n
39  sm=sm+dble(a(i,i))*dble(b(i,i))
40 end do
41 trzhmm=sm
42 end function
43 !EOC
44 
pure real(8) function trzhmm(n, a, b)
Definition: trzhmm.f90:10