diff --git a/src/atoms/sdp_cone/operatornorm.jl b/src/atoms/sdp_cone/operatornorm.jl index 3b334f177..7004ac3bb 100644 --- a/src/atoms/sdp_cone/operatornorm.jl +++ b/src/atoms/sdp_cone/operatornorm.jl @@ -6,7 +6,7 @@ # Please read expressions.jl first. ############################################################################# import LinearAlgebra: opnorm -export operatornorm, sigmamax +export sigmamax ### Operator norm @@ -18,7 +18,7 @@ struct OperatorNormAtom <: AbstractExpr function OperatorNormAtom(x::AbstractExpr) children = (x,) - return new(:operatornorm, hash(children), children, (1,1)) + return new(:opnorm, hash(children), children, (1,1)) end end @@ -40,7 +40,6 @@ function evaluate(x::OperatorNormAtom) opnorm(evaluate(x.children[1]), 2) end -operatornorm(x::AbstractExpr) = OperatorNormAtom(x) sigmamax(x::AbstractExpr) = OperatorNormAtom(x) function opnorm(x::AbstractExpr, p::Real=2) @@ -50,7 +49,7 @@ function opnorm(x::AbstractExpr, p::Real=2) if p == 1 return maximum(sum(abs(x), dims=1)) elseif p == 2 - return operatornorm(x) + return OperatorNormAtom(x) elseif p == Inf return maximum(sum(abs(x), dims=2)) else @@ -58,6 +57,8 @@ function opnorm(x::AbstractExpr, p::Real=2) end end +Base.@deprecate operatornorm(x::AbstractExpr) opnorm(x) + # Create the equivalent conic problem: # minimize t # subject to diff --git a/test/test_sdp.jl b/test/test_sdp.jl index 678809522..855d6999e 100644 --- a/test/test_sdp.jl +++ b/test/test_sdp.jl @@ -72,11 +72,11 @@ eye(n) = Matrix(1.0I, n, n) @testset "operator norm atom" begin y = Variable((3,3)) - p = minimize(operatornorm(y), y[2,1]<=4, y[2,2]>=3, sum(y)>=12) + p = minimize(opnorm(y), y[2,1]<=4, y[2,2]>=3, sum(y)>=12) @test vexity(p) == ConvexVexity() solve!(p) @test p.optval ≈ 4 atol=TOL - @test evaluate(operatornorm(y)) ≈ 4 atol=TOL + @test evaluate(opnorm(y)) ≈ 4 atol=TOL end @testset "sigma max atom" begin