Skip to content

Commit 942a771

Browse files
committed
Deprecate operatornorm in favor of opnorm
opnorm will create OperatorNormAtom objects directly for p=2.
1 parent 205884c commit 942a771

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/atoms/sdp_cone/operatornorm.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Please read expressions.jl first.
77
#############################################################################
88
import LinearAlgebra: opnorm
9-
export operatornorm, sigmamax
9+
export sigmamax
1010

1111
### Operator norm
1212

@@ -18,7 +18,7 @@ struct OperatorNormAtom <: AbstractExpr
1818

1919
function OperatorNormAtom(x::AbstractExpr)
2020
children = (x,)
21-
return new(:operatornorm, hash(children), children, (1,1))
21+
return new(:opnorm, hash(children), children, (1,1))
2222
end
2323
end
2424

@@ -40,7 +40,6 @@ function evaluate(x::OperatorNormAtom)
4040
opnorm(evaluate(x.children[1]), 2)
4141
end
4242

43-
operatornorm(x::AbstractExpr) = OperatorNormAtom(x)
4443
sigmamax(x::AbstractExpr) = OperatorNormAtom(x)
4544

4645
function opnorm(x::AbstractExpr, p::Real=2)
@@ -50,14 +49,16 @@ function opnorm(x::AbstractExpr, p::Real=2)
5049
if p == 1
5150
return maximum(sum(abs(x), dims=1))
5251
elseif p == 2
53-
return operatornorm(x)
52+
return OperatorNormAtom(x)
5453
elseif p == Inf
5554
return maximum(sum(abs(x), dims=2))
5655
else
5756
throw(ArgumentError("matrix p-norms only defined for p = 1, 2, and Inf"))
5857
end
5958
end
6059

60+
Base.@deprecate operatornorm(x::AbstractExpr) opnorm(x)
61+
6162
# Create the equivalent conic problem:
6263
# minimize t
6364
# subject to

test/test_sdp.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ eye(n) = Matrix(1.0I, n, n)
7272

7373
@testset "operator norm atom" begin
7474
y = Variable((3,3))
75-
p = minimize(operatornorm(y), y[2,1]<=4, y[2,2]>=3, sum(y)>=12)
75+
p = minimize(opnorm(y), y[2,1]<=4, y[2,2]>=3, sum(y)>=12)
7676
@test vexity(p) == ConvexVexity()
7777
solve!(p)
7878
@test p.optval 4 atol=TOL
79-
@test evaluate(operatornorm(y)) 4 atol=TOL
79+
@test evaluate(opnorm(y)) 4 atol=TOL
8080
end
8181

8282
@testset "sigma max atom" begin

0 commit comments

Comments
 (0)