import torch


def polak_ribiere(g_k1, g_k):
    """
    This function computes the Polak-Ribier conjugate gradient search direction constant

    INPUTS:
        g_k1 < tensor > : gradient at current time step
        g_k < tensor > : gradient at previous time step

    OUTPUTS:
        b_k1 < tensor > : conj. gradient update constant at current time step
    """
    return torch.matmul(g_k1.t(), (g_k1 - g_k)) / torch.matmul(g_k.t(), g_k)