(x, y)
return result, grad
r"""Chebyshev or l-infinity distance with gradient.

    ..math::
        D(x, y) = \max_i |x_i - y_i|
r"""Chebyshev or l-infinity distance with gradient.
r Chebyshev or l - infinity distance with gradient .
def chebyshev_grad(x, y):
    r"""Chebyshev or l-infinity distance with gradient.

    ..math::
        D(x, y) = \max_i |x_i - y_i|
    """
    result = 0.0
    max_i = 0
    for i in range(x.shape[0]):
        v = np.abs(x[i] - y[i])
        if v > result:
            result = v
            max_i = i
    grad = np.zeros(x.shape)
    grad[max_i] = np.sign(x[max_i] - y[max_i])

    return result, grad
def chebyshev_grad ( x , y ) : result = 0.0 max_i = 0 for i in range ( x . shape [ 0 ] ) : v = np . abs ( x [ i ] - y [ i ] ) if v > result : result = v max_i = i grad = np . zeros ( x . shape ) grad [ max_i ] = np . sign ( x [ max_i ] - y [ max_i ] ) return result , grad