File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -1207,13 +1207,19 @@ Base.eltype(::Type{T}) where {T<:AbstractJuMPScalar} = T
12071207
12081208# These are required to create symmetric containers of AbstractJuMPScalars.
12091209LinearAlgebra. symmetric_type (:: Type{T} ) where {T<: AbstractJuMPScalar } = T
1210- LinearAlgebra . hermitian_type ( :: Type{T} ) where {T <: AbstractJuMPScalar } = T
1210+
12111211LinearAlgebra. symmetric (scalar:: AbstractJuMPScalar , :: Symbol ) = scalar
12121212
1213+ LinearAlgebra. issymmetric (:: AbstractJuMPScalar ) = true
1214+
1215+ LinearAlgebra. hermitian_type (:: Type{T} ) where {T<: AbstractJuMPScalar } = T
1216+
12131217function LinearAlgebra. hermitian (x:: F , :: Symbol ) where {F<: AbstractJuMPScalar }
12141218 return convert (F, real (x))
12151219end
12161220
1221+ LinearAlgebra. ishermitian (x:: AbstractJuMPScalar ) = isreal (x)
1222+
12171223LinearAlgebra. adjoint (scalar:: AbstractJuMPScalar ) = conj (scalar)
12181224
12191225Base. iterate (x:: AbstractJuMPScalar ) = (x, true )
Original file line number Diff line number Diff line change @@ -739,7 +739,23 @@ function test_is_symmetric()
739739 @test ! LinearAlgebra. issymmetric ([x[1 ] x[2 ]; x[3 ] x[3 ]])
740740 @test ! LinearAlgebra. issymmetric ([x[1 ] x[2 ]])
741741 @test LinearAlgebra. issymmetric ([x[1 ] x[2 ]; x[2 ] x[3 ]])
742+ @test LinearAlgebra. issymmetric (x[1 ])
743+ @test LinearAlgebra. issymmetric (1.0 * x[1 ] + 2.0 )
744+ @test LinearAlgebra. issymmetric (x[1 ] * x[1 ])
745+ @test LinearAlgebra. issymmetric (log (x[1 ]))
742746 return
743747end
744748
749+ function test_is_hermitian ()
750+ model = Model ()
751+ @variable (model, x)
752+ @test LinearAlgebra. ishermitian (x)
753+ @test LinearAlgebra. ishermitian (1.0 * x + 2.0 )
754+ @test LinearAlgebra. ishermitian (x^ 2 )
755+ @test LinearAlgebra. ishermitian (log (x))
756+ @test ! LinearAlgebra. ishermitian (2.0 * im * x)
757+ @test ! LinearAlgebra. ishermitian (2.0 * im * x * x)
758+ return
745759end
760+
761+ end # module
You can’t perform that action at this time.
0 commit comments