get_rayleigh_quotient Function

public function get_rayleigh_quotient(this, i_state) result(exp_val)

Arguments

Type IntentOptional Attributes Name
type(LanczosCalcType), intent(inout) :: this
integer, intent(in) :: i_state

Return Value real(kind=dp)


Contents

Source Code


Source Code

    function get_rayleigh_quotient(this, i_state) result(exp_val)
        type(LanczosCalcType), intent(inout) :: this
        integer, intent(in) :: i_state
        integer :: ierr
        HElement_t(dp), allocatable :: H_ket(:)
        real(dp) :: exp_val

        safe_malloc(H_ket, (this%super%space_size))

        call MPIBCast(this%eigenvectors)
        if (iprocindex == root) then
            call multiply_hamil_and_vector(this%super, this%eigenvectors(1:this%super%space_size, i_state), H_ket)
        else
            call multiply_hamil_and_vector(this%super, this%eigenvectors(1:this%super%space_size, i_state), this%super%temp_out)
        end if
        if (iprocindex == root) then
            exp_val = real(inner_product(this%eigenvectors(1:this%super%space_size, i_state), H_ket), dp)
            exp_val = exp_val / euclidean_norm_square(this%eigenvectors(1:this%super%space_size, i_state))
        else
            exp_val = 0.0_dp
        end if
        safe_free(H_ket)
    end function get_rayleigh_quotient