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"))
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))
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))