Skip to content

Commit 84a30f2

Browse files
authored
Rename GeomMean to GeometricMean (#638)
* Rename Geom to Geometric * GeomMean -> GeometricMean * Fix format
1 parent a1400c6 commit 84a30f2

File tree

9 files changed

+77
-57
lines changed

9 files changed

+77
-57
lines changed

LICENSE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ which is licensed under the MIT "Expat" license:
3131
* src/atoms/sdp_cone/QuantumRelativeEntropyAtom.jl
3232
* src/atoms/sdp_cone/TraceLogmAtom.jl
3333
* src/atoms/sdp_cone/TraceMpowerAtom.jl
34-
* src/constraints/GeomMeanEpiCone.jl
35-
* src/constraints/GeomMeanHypoCone.jl
34+
* src/constraints/GeometricMeanEpiCone.jl
35+
* src/constraints/GeometricMeanHypoCone.jl
3636
* src/constraints/RelativeEntropyEpiCone.jl
3737
* src/reformulations/lieb_ando.jl,
3838

docs/src/manual/operations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ solver (including SCS and Mosek).
116116
| `rootdet(X)` | n-th root-determinant of the $n$-by-$n$ matrix X, that is $det(X)^{1/n}$ | concave | not monotonic | |
117117
| `matrixfrac(x, P)` | $x^TP^{-1}x$ | convex | not monotonic | IC: P is positive semidefinite |
118118
| `sumlargesteigs(x, k)` | sum of top $k$ eigenvalues of $x$ | convex | not monotonic | IC: P symmetric |
119-
| `T in GeomMeanHypoCone(A, B, t)` | $T \preceq A \#_t B = A^{1/2} (A^{-1/2} B A^{-1/2})^t A^{1/2}$ | concave | increasing | IC: $A \succeq 0$, $B \succeq 0$, $t \in [0,1]$ |
119+
| `T in GeometricMeanHypoCone(A, B, t)` | $T \preceq A \#_t B = A^{1/2} (A^{-1/2} B A^{-1/2})^t A^{1/2}$ | concave | increasing | IC: $A \succeq 0$, $B \succeq 0$, $t \in [0,1]$ |
120120
| `Convex.GenericConstraint((T, A, B), GeometricMeanEpiConeSquare(t, size(T, 1)))` | $T \succeq A \#_t B = A^{1/2} (A^{-1/2} B A^{-1/2})^t A^{1/2}$ | convex | not monotonic | IC: $A \succeq 0$, $B \succeq 0$, $t \in [-1, 0] \cup [1, 2]$ |
121121
| `quantum_entropy(X)` | $-\textrm{Tr}(X \log X)$ | concave | not monotonic | IC: $X \succeq 0$; uses natural log |
122122
| `quantum_relative_entropy(A, B)` | $\textrm{Tr}(A \log A - A \log B)$ | convex | not monotonic | IC: $A \succeq 0$, $B \succeq 0$; uses natural log |

src/Convex.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export conv,
4444
sumlargesteigs,
4545
sumsmallest,
4646
sumsquares,
47-
GeomMeanHypoCone,
47+
GeometricMeanHypoCone,
4848
GeometricMeanEpiConeSquare,
4949
RelativeEntropyEpiCone,
5050
quantum_relative_entropy,

src/atoms/TraceMpowerAtom.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ function new_conic_form!(context::Context{T}, atom::TraceMpowerAtom) where {T}
9393
end
9494
I = Matrix(one(T) * LinearAlgebra.I(n))
9595
if 0 <= atom.t <= 1
96-
add_constraint!(context, tmp in GeomMeanHypoCone(I, A, atom.t, false))
96+
add_constraint!(
97+
context,
98+
tmp in GeometricMeanHypoCone(I, A, atom.t, false),
99+
)
97100
else
98101
add_constraint!(
99102
context,

src/constraints/GeometricMeanEpiCone.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ function _add_constraint!(
9191
end
9292
if t <= 0
9393
add_constraint!(context, [T A; A Z] 0)
94-
add_constraint!(context, Z in GeomMeanHypoCone(A, B, -t, false))
94+
add_constraint!(context, Z in GeometricMeanHypoCone(A, B, -t, false))
9595
else
9696
# range of t checked in GeometricMeanEpiConeSquare constructor.
9797
@assert t >= 1
9898
add_constraint!(context, [T B; B Z] 0)
99-
add_constraint!(context, Z in GeomMeanHypoCone(A, B, 2 - t, false))
99+
add_constraint!(context, Z in GeometricMeanHypoCone(A, B, 2 - t, false))
100100
end
101101
return
102102
end

src/constraints/GeomMeanHypoCone.jl renamed to src/constraints/GeometricMeanHypoCone.jl

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ REFERENCE
3030
theorem, matrix geometric means and semidefinite optimization" by Hamza
3131
Fawzi and James Saunderson (arXiv:1512.03401)
3232
"""
33-
mutable struct GeomMeanHypoCone
33+
mutable struct GeometricMeanHypoCone
3434
A::AbstractExpr
3535
B::AbstractExpr
3636
t::Rational
3737
size::Tuple{Int,Int}
3838
fullhyp::Bool
3939

40-
function GeomMeanHypoCone(
40+
function GeometricMeanHypoCone(
4141
A::AbstractExpr,
4242
B::AbstractExpr,
4343
t::Rational,
@@ -56,64 +56,74 @@ mutable struct GeomMeanHypoCone
5656
return new(A, B, t, (n, n), fullhyp)
5757
end
5858

59-
function GeomMeanHypoCone(
59+
function GeometricMeanHypoCone(
6060
A::Value,
6161
B::AbstractExpr,
6262
t::Rational,
6363
fullhyp::Bool = true,
6464
)
65-
return GeomMeanHypoCone(constant(A), B, t, fullhyp)
65+
return GeometricMeanHypoCone(constant(A), B, t, fullhyp)
6666
end
6767

68-
function GeomMeanHypoCone(
68+
function GeometricMeanHypoCone(
6969
A::AbstractExpr,
7070
B::Value,
7171
t::Rational,
7272
fullhyp::Bool = true,
7373
)
74-
return GeomMeanHypoCone(A, constant(B), t, fullhyp)
74+
return GeometricMeanHypoCone(A, constant(B), t, fullhyp)
7575
end
7676

77-
function GeomMeanHypoCone(
77+
function GeometricMeanHypoCone(
7878
A::Value,
7979
B::Value,
8080
t::Rational,
8181
fullhyp::Bool = true,
8282
)
83-
return GeomMeanHypoCone(constant(A), constant(B), t, fullhyp)
83+
return GeometricMeanHypoCone(constant(A), constant(B), t, fullhyp)
8484
end
8585

86-
function GeomMeanHypoCone(
86+
function GeometricMeanHypoCone(
8787
A::Union{AbstractExpr,Value},
8888
B::Union{AbstractExpr,Value},
8989
t::Integer,
9090
fullhyp::Bool = true,
9191
)
92-
return GeomMeanHypoCone(A, B, t // 1, fullhyp)
92+
return GeometricMeanHypoCone(A, B, t // 1, fullhyp)
9393
end
9494
end
9595

96-
mutable struct GeomMeanHypoConeConstraint <: Constraint
96+
mutable struct GeometricMeanHypoConeConstraint <: Constraint
9797
T::AbstractExpr
98-
cone::GeomMeanHypoCone
98+
cone::GeometricMeanHypoCone
9999

100-
function GeomMeanHypoConeConstraint(T::AbstractExpr, cone::GeomMeanHypoCone)
100+
function GeometricMeanHypoConeConstraint(
101+
T::AbstractExpr,
102+
cone::GeometricMeanHypoCone,
103+
)
101104
if size(T) != cone.size
102105
throw(DimensionMismatch("T must be size $(cone.size)"))
103106
end
104107
return new(T, cone)
105108
end
106109

107-
function GeomMeanHypoConeConstraint(T::Value, cone::GeomMeanHypoCone)
108-
return GeomMeanHypoConeConstraint(constant(T), cone)
110+
function GeometricMeanHypoConeConstraint(
111+
T::Value,
112+
cone::GeometricMeanHypoCone,
113+
)
114+
return GeometricMeanHypoConeConstraint(constant(T), cone)
109115
end
110116
end
111117

112-
head(io::IO, ::GeomMeanHypoConeConstraint) = print(io, "∈(GeomMeanHypoCone)")
118+
function head(io::IO, ::GeometricMeanHypoConeConstraint)
119+
return print(io, "∈(GeometricMeanHypoCone)")
120+
end
113121

114-
Base.in(T, cone::GeomMeanHypoCone) = GeomMeanHypoConeConstraint(T, cone)
122+
function Base.in(T, cone::GeometricMeanHypoCone)
123+
return GeometricMeanHypoConeConstraint(T, cone)
124+
end
115125

116-
function AbstractTrees.children(constraint::GeomMeanHypoConeConstraint)
126+
function AbstractTrees.children(constraint::GeometricMeanHypoConeConstraint)
117127
return (
118128
constraint.T,
119129
constraint.cone.A,
@@ -124,7 +134,7 @@ end
124134

125135
# For t ∈ [0,1] the t-weighted matrix geometric mean is matrix concave (arxiv:1512.03401).
126136
# So if A and B are convex sets, then T ⪯ A #_t B will be a convex set.
127-
function vexity(constraint::GeomMeanHypoConeConstraint)
137+
function vexity(constraint::GeometricMeanHypoConeConstraint)
128138
A = vexity(constraint.cone.A)
129139
B = vexity(constraint.cone.B)
130140
T = vexity(constraint.T)
@@ -145,7 +155,7 @@ end
145155

146156
function _add_constraint!(
147157
context::Context,
148-
constraint::GeomMeanHypoConeConstraint,
158+
constraint::GeometricMeanHypoConeConstraint,
149159
)
150160
A = constraint.cone.A
151161
B = constraint.cone.B
@@ -165,7 +175,7 @@ function _add_constraint!(
165175

166176
if fullhyp && t != 0 && t != 1
167177
W = make_temporary()
168-
add_constraint!(context, W in GeomMeanHypoCone(A, B, t, false))
178+
add_constraint!(context, W in GeometricMeanHypoCone(A, B, t, false))
169179
add_constraint!(context, W T)
170180
else
171181
p = t.num
@@ -190,13 +200,13 @@ function _add_constraint!(
190200
if t < 1 / 2
191201
add_constraint!(
192202
context,
193-
Z in GeomMeanHypoCone(A, B, 2 * t, false),
203+
Z in GeometricMeanHypoCone(A, B, 2 * t, false),
194204
)
195205
add_constraint!(context, [A T; T' Z] 0)
196206
else
197207
add_constraint!(
198208
context,
199-
Z in GeomMeanHypoCone(A, B, 2 * t - 1, false),
209+
Z in GeometricMeanHypoCone(A, B, 2 * t - 1, false),
200210
)
201211
add_constraint!(context, [B T; T' Z] 0)
202212
end
@@ -205,7 +215,7 @@ function _add_constraint!(
205215
Z = make_temporary()
206216
add_constraint!(
207217
context,
208-
Z in GeomMeanHypoCone(A, T, (2 * p - q) // p, false),
218+
Z in GeometricMeanHypoCone(A, T, (2 * p - q) // p, false),
209219
)
210220
add_constraint!(context, [Z T; T B] 0)
211221
elseif t < 1 / 2
@@ -215,15 +225,18 @@ function _add_constraint!(
215225
l = floor(Int, log2(q))
216226
add_constraint!(
217227
context,
218-
X in GeomMeanHypoCone(A, B, p // (2^l), false),
228+
X in GeometricMeanHypoCone(A, B, p // (2^l), false),
219229
)
220230
add_constraint!(
221231
context,
222-
T in GeomMeanHypoCone(A, X, (2^l) // q, false),
232+
T in GeometricMeanHypoCone(A, X, (2^l) // q, false),
223233
)
224234
else
225235
#println("geom_mean_hypocone p=$p q=$q else")
226-
add_constraint!(context, T in GeomMeanHypoCone(B, A, 1 - t, false))
236+
add_constraint!(
237+
context,
238+
T in GeometricMeanHypoCone(B, A, 1 - t, false),
239+
)
227240
end
228241
end
229242
end

src/constraints/RelativeEntropyEpiCone.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ function _add_constraint!(
177177
Z = Variable(n, n)
178178
T = [Variable(r, r) for i in 1:m]
179179
end
180-
add_constraint!(context, Z in GeomMeanHypoCone(X, Y, 1 // (2^k), false))
180+
add_constraint!(
181+
context,
182+
Z in GeometricMeanHypoCone(X, Y, 1 // (2^k), false),
183+
)
181184
for ii in 1:m
182185
# Note that we are dividing by w here because it is easier
183186
# to do this than to do sum w_i T(:,...,:,ii) later (cf. line that

0 commit comments

Comments
 (0)