Skip to content

Commit

Permalink
Add test for == and fix method
Browse files Browse the repository at this point in the history
  • Loading branch information
simsurace committed Feb 10, 2024
1 parent 73ad032 commit 092bf04
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parameters_matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct PositiveDefinite{TL<:AbstractVector{<:Real},Tε<:Real} <: AbstractParamet
ε::Tε
end

Base.:(==)(X::PositiveDefinite, Y::PositiveDefinite) = X.L == Y.L
Base.:(==)(X::PositiveDefinite, Y::PositiveDefinite) = X.L == Y.L && X.ε == Y.ε

value(X::PositiveDefinite) = A_At(vec_to_tril(X.L)) + X.ε * I

Expand Down
2 changes: 2 additions & 0 deletions test/parameters_matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ using ParameterHandling: vec_to_tril, tril_to_vec
@test isposdef(value(X))
X.L .= 0 # zero the unconstrained value
@test isposdef(value(X))
@test X != positive_definite(X_mat)
@test positive_definite(X_mat, 1e-3) != positive_definite(X_mat, 1e-2)
@test_throws ArgumentError positive_definite(zeros(3, 3))
@test_throws ArgumentError positive_definite(X_mat, 0.0)
test_parameter_interface(X)
Expand Down

0 comments on commit 092bf04

Please sign in to comment.