@@ -46,7 +46,7 @@ projection(::PositiveOrthant, x) = max.(0, x)
46
46
47
47
@generated function projection (:: SecondOrderCone , x:: V ) where V <: AbstractVector
48
48
# assumes x is stacked [v; s] such that ||v||₂ ≤ s
49
- v = V isa StaticVector ? :(v = pop (x)) : :(v = view (x, 1 : n- 1 ))
49
+ v = V <: StaticVector ? :(v = pop (x)) : :(v = view (x, 1 : n- 1 ))
50
50
quote
51
51
n = length (x)
52
52
s = x[end ]
@@ -64,6 +64,8 @@ projection(::PositiveOrthant, x) = max.(0, x)
64
64
end
65
65
end
66
66
67
+ projection! (:: Equality , px, x) = px .= 0
68
+
67
69
function projection! (:: NegativeOrthant , px, x)
68
70
@assert length (px) == length (x)
69
71
for i in eachindex (x)
@@ -101,7 +103,7 @@ function ∇projection!(::NegativeOrthant, J, x)
101
103
end
102
104
103
105
@generated function ∇projection! (:: SecondOrderCone , J, x:: V ) where V <: AbstractVector
104
- v = V isa StaticVector ? :(v = pop (x)) : :(v = view (x, 1 : n- 1 ))
106
+ v = V <: StaticVector ? :(v = pop (x)) : :(v = view (x, 1 : n- 1 ))
105
107
return quote
106
108
n = length (x)
107
109
s = x[end ]
159
161
@generated function ∇²projection! (
160
162
:: SecondOrderCone , hess, x:: V1 , b:: V2
161
163
) where {V1<: AbstractVecOrMat ,V2<: AbstractVector }
162
- v = V1 isa StaticVector ? :(v = pop (x)) : :(v = view (x, 1 : n))
163
- bv = V2 isa StaticVector ? :(bv = pop (b)) : :(bv = view (b, 1 : n))
164
+ v = V1 <: StaticVector ? :(v = pop (x)) : :(v = view (x, 1 : n))
165
+ bv = V2 <: StaticVector ? :(bv = pop (b)) : :(bv = view (b, 1 : n))
164
166
quote
165
167
n = length (x)- 1
166
168
@assert size (hess) == (n+ 1 ,n+ 1 )
0 commit comments