Skip to content

Commit df60400

Browse files
authored
fix: hcat would fail with one block; added unary +(Sign) and +(Comple… (#405)
* fix: hcat would fail with one block; added unary +(Sign) and +(ComplexSign) * added tests for hcat fix
1 parent 991dbd1 commit df60400

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/dcp.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ struct ComplexSign <: Sign end
8484
+(v::ConvexVexity, w::ConcaveVexity) = NotDcp()
8585

8686
#+(::Convex.Positive, ::Convex.NoSign)
87+
+(s::Sign) = s
8788
+(s::Positive, t::Positive) = s
8889
+(s::Negative, t::Negative) = s
8990
+(s::Positive, t::Negative) = NoSign()
@@ -95,6 +96,7 @@ struct ComplexSign <: Sign end
9596
+(t::Negative, s::NoSign) = s+t
9697

9798
# Any sign + ComplexSign = ComplexSign
99+
+(s::ComplexSign) = s
98100
+(s::ComplexSign, t::ComplexSign) = s
99101
+(s::Sign, t::ComplexSign) = t
100102
+(t::ComplexSign, s::Sign) = s+t

src/problem_depot/problems/affine.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,26 @@ end
480480
end
481481
end
482482

483+
@add_problem affine function affine_single_hcat_atom(handle_problem!, ::Val{test}, atol, rtol, ::Type{T}) where {T, test}
484+
x = Variable(4, 4)
485+
p = maximize(tr(hcat(x)), hcat(x) <= 2; numeric_type = T)
486+
487+
handle_problem!(p)
488+
if test
489+
@test p.optval 8 atol=atol rtol=rtol
490+
end
491+
end
492+
493+
@add_problem affine function affine_single_vcat_atom(handle_problem!, ::Val{test}, atol, rtol, ::Type{T}) where {T, test}
494+
x = Variable(4, 4)
495+
p = maximize(tr(vcat(x)), vcat(x) <= 2; numeric_type = T)
496+
497+
handle_problem!(p)
498+
if test
499+
@test p.optval 8 atol=atol rtol=rtol
500+
end
501+
end
502+
483503
@add_problem affine function affine_Diagonal_atom(handle_problem!, ::Val{test}, atol, rtol, ::Type{T}) where {T, test}
484504
x = Variable(2, 2)
485505
if test

0 commit comments

Comments
 (0)