Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -539,3 +539,7 @@ macro check_size(x, sz, size = :size)
end
)
end

# Check equality of two `TruncationStrategy`s
isequal(t1::T, t2::T) where {T <: TruncationStrategy} = all(getfield(t1, f) == getfield(t2, f) for f in fieldnames(typeof(t1)))
Comment thread
sanderdemeyer marked this conversation as resolved.
Outdated
isequal(t1::T1, t2::T2) where {T1, T2 <: TruncationStrategy} = false
Comment thread
lkdvos marked this conversation as resolved.
Outdated
20 changes: 20 additions & 0 deletions test/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,23 @@ end
@test @constinferred(select_algorithm(svd_compact!, A, $alg)) === QRIteration()
end
end

@testset "Truncation equivalencies" begin
truncs = [
notrunc(),
truncrank(4),
truncrank(5),
truncfilter(x -> x > 0),
truncfilter(x -> x > 1.0e-4),
trunctol(; atol = 0),
trunctol(; atol = 1.0e-4),
truncerror(; atol = 0),
truncerror(; atol = 1.0e-4),
truncrank(4) & truncfilter(x -> x > 0),
truncrank(4) & truncrank(5),
]

for (i1, t1) in enumerate(truncs), (i2, t2) in enumerate(truncs)
@test (i1 == i2) ? t1 == t2 : t1 != t2
end
end
Loading