calc_norm Function

public function calc_norm(dets, num_dets) result(cd_norm)

Arguments

Type IntentOptional Attributes Name
integer(kind=dp) :: dets(0:,1:)
integer, intent(in) :: num_dets

Return Value complex(kind=dp), (normsize)


Contents

Source Code


Source Code

    function calc_norm(dets, num_dets) result(cd_norm)
        ! the first dimension of dets has to be niftot
        ! function to calculate the norm of a state and
        ! the overlap between replicas(general function)
        complex(dp) :: cd_norm(normsize)
        integer(dp) :: dets(0:, 1:)
        integer, intent(in) :: num_dets
        character(*), parameter :: this_routine = "calc_perturbed_norm"

        integer :: idet, run, targetRun
        real(dp) :: tmp_sign(lenof_sign)

        cd_norm = 0.0_dp

        do idet = 1, num_dets

            call extract_sign(dets(:, idet), tmp_sign)
            do run = 1, inum_runs
                ! we calculate the overlap between any two replicas, including the norm
                ! of each individually
                do targetRun = 1, run
! this only works for complex builds, it would not even compile else
                    cd_norm(overlap_index(run, targetRun)) = cd_norm(overlap_index(run, targetRun)) &
                                                            + conjg(cmplx(tmp_sign(min_part_type(run)), tmp_sign(max_part_type(run)), dp)) &
                                                             * cmplx(tmp_sign(min_part_type(targetRun)), tmp_sign( &
                                                                     max_part_type(targetRun)), dp)
                end do
            end do
            do run = 1, inum_runs
                do targetRun = run + 1, inum_runs
                    cd_norm(overlap_index(run, targetRun)) = conjg(cd_norm(overlap_index(targetRun, run)))
                end do
            end do
        end do

    end function calc_norm