From e6483dc2b213073143b091eb424362a15ce5d994 Mon Sep 17 00:00:00 2001 From: odow Date: Wed, 5 Jun 2024 11:55:44 +1200 Subject: [PATCH] Update to cdots --- docs/src/manual/constraints.md | 6 +++--- src/print.jl | 8 +++++--- src/sd.jl | 2 +- test/test_print.jl | 10 +++++----- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/docs/src/manual/constraints.md b/docs/src/manual/constraints.md index 73f9e75b9d2..4eb08ee188e 100644 --- a/docs/src/manual/constraints.md +++ b/docs/src/manual/constraints.md @@ -202,7 +202,7 @@ julia> @variable(model, X[1:2, 1:2], Symmetric) julia> @constraint(model, X == LinearAlgebra.I) [X[1,1] - 1 X[1,2] - ⋅ X[2,2] - 1] ∈ Zeros() + ⋯ X[2,2] - 1] ∈ Zeros() ``` This will add only three rows to the constraint matrix because the symmetric @@ -1462,7 +1462,7 @@ julia> Z = [X[1, 1] X[1, 2]; X[1, 2] X[2, 2]] julia> @constraint(model, LinearAlgebra.Symmetric(Z) >= 0, PSDCone()) [X[1,1] X[1,2] - ⋅ X[2,2]] ∈ PSDCone() + ⋯ X[2,2]] ∈ PSDCone() ``` Note that the lower triangular entries are ignored even if they are @@ -1470,7 +1470,7 @@ different so use it with caution: ```jldoctest con_psd julia> @constraint(model, LinearAlgebra.Symmetric(X) >= 0, PSDCone()) [X[1,1] X[1,2] - ⋅ X[2,2]] ∈ PSDCone() + ⋯ X[2,2]] ∈ PSDCone() ``` (Note that no error is thrown, even though `X` is not symmetric.) diff --git a/src/print.jl b/src/print.jl index 7044e4fdb99..7c51d977001 100644 --- a/src/print.jl +++ b/src/print.jl @@ -908,9 +908,9 @@ function function_string( line *= " & " end if A isa LinearAlgebra.Symmetric && i > j - line *= "\\cdot" + line *= "\\cdots" elseif A isa LinearAlgebra.UpperTriangular && i > j - line *= "\\cdot" + line *= "\\cdots" else line *= function_string(mode, A[i, j]) end @@ -935,7 +935,9 @@ function function_string( constraint::VectorConstraint{F,S,SymmetricMatrixShape}, ) where {F,S} f = reshape_vector(jump_function(constraint), shape(constraint)) - return function_string(mode, LinearAlgebra.UpperTriangular(f)) + str = function_string(mode, LinearAlgebra.UpperTriangular(f)) + return replace(str, "⋅" => "⋯") + end function function_string(mode::MIME, p::NonlinearExpression) diff --git a/src/sd.jl b/src/sd.jl index e63ba11f14e..5457884faf3 100644 --- a/src/sd.jl +++ b/src/sd.jl @@ -126,7 +126,7 @@ julia> b = [1 2; 2 4]; julia> cref = @constraint(model, Symmetric(a - b) in PSDCone()) [x - 1 2 x - 2 - ⋅ x - 4] ∈ PSDCone() + ⋯ x - 4] ∈ PSDCone() julia> jump_function(constraint_object(cref)) 3-element Vector{AffExpr}: diff --git a/test/test_print.jl b/test/test_print.jl index b1786894594..66d0ff34fe0 100644 --- a/test/test_print.jl +++ b/test/test_print.jl @@ -605,7 +605,7 @@ Subject to con : a + b - 10 c + c1 - 2 x $le 1 a*b $le 2 [a b - ⋅ x] $inset $(PSDCone()) + ⋯ x] $inset $(PSDCone()) [a, b, c] $inset $(MOI.PositiveSemidefiniteConeTriangle(2)) [a b c x] $inset $(PSDCone()) @@ -666,7 +666,7 @@ Names registered in the model: a, a1, b, b1, c, c1, con, fi, soc, u, x, y, z"""; " & a\\times b \\leq 2\\\\\n" * " & \\begin{bmatrix}\n" * "a & b\\\\\n" * - "\\cdot & x\\\\\n" * + "\\cdots & x\\\\\n" * "\\end{bmatrix} \\in \\text{$(PSDCone())}\\\\\n" * " & [a, b, c] \\in \\text{MathOptInterface.PositiveSemidefiniteConeTriangle(2)}\\\\\n" * " & \\begin{bmatrix}\n" * @@ -1100,13 +1100,13 @@ function test_symmetric_constraint() @test function_string(MIME("text/plain"), x) == "[x[1,1] x[1,2]\n x[1,2] x[2,2]]" @test function_string(MIME("text/latex"), x) == - "\\begin{bmatrix}\nx_{1,1} & x_{1,2}\\\\\n\\cdot & x_{2,2}\\\\\n\\end{bmatrix}" + "\\begin{bmatrix}\nx_{1,1} & x_{1,2}\\\\\n\\cdots & x_{2,2}\\\\\n\\end{bmatrix}" c = @constraint(model, x in PSDCone()) o = constraint_object(c) @test function_string(MIME("text/plain"), o) == - "[x[1,1] x[1,2]\n ⋅ x[2,2]]" + "[x[1,1] x[1,2]\n ⋯ x[2,2]]" @test function_string(MIME("text/latex"), o) == - "\\begin{bmatrix}\nx_{1,1} & x_{1,2}\\\\\n\\cdot & x_{2,2}\\\\\n\\end{bmatrix}" + "\\begin{bmatrix}\nx_{1,1} & x_{1,2}\\\\\n\\cdots & x_{2,2}\\\\\n\\end{bmatrix}" return end