Exemplo n.º 1
0
def sum_squares(expr):
    """The sum of the squares of the entries.

    Parameters
    ----------
    expr: Expression
        The expression to take the sum of squares of.

    Returns
    -------
    Expression
        An expression representing the sum of squares.
    """
    return square(norm(expr, "fro"))
Exemplo n.º 2
0
def huber(x, M=1):
    """The Huber function

    Huber(x, M) = 2M|x|-M^2 for |x| >= |M|
                  |x|^2 for |x| <= |M|
    M defaults to 1.

    Parameters
    ----------
    x : Expression
        A CVXPY expression.
    M : int/float
    """
    # TODO require that M is positive?
    return square(M)*huber_pos(abs(x)/abs(M))
Exemplo n.º 3
0
def huber(x, M=1):
    """The Huber function

    Huber(x, M) = 2M|x|-M^2 for |x| >= |M|
                  |x|^2 for |x| <= |M|
    M defaults to 1.

    Parameters
    ----------
    x : Expression
        A CVXPY expression.
    M : int/float
    """
    # TODO require that M is positive?
    return square(M) * huber_pos(abs(x) / abs(M))