Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions src/compressor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ function _aca_partial(K, irange, jrange, atol, rmax, rtol, istart, buffer_ = not
r = 0 # current rank
while er > max(atol, rtol * est_norm) && r < rmax
# remove index i from allowed row
if i < 1
all(j -> iszero(K[first(irange), j]), jrange) &&
all(i -> iszero(K[i, first(jrange)]), irange) ||
@warn "aca possibly failed on $irange × $jrange"
break
end
I[i] = false
# pre-allocate row and column
a = newcol!(A)
Expand Down
18 changes: 14 additions & 4 deletions test/compressor_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ Random.seed!(1)
aca = PartialACA(; atol = atol)
R = aca(M, irange, jrange)
@test norm(Matrix(R) - M) < atol
# test zero matrix
R = aca(zero(M), irange, jrange)
@test norm(Matrix(R)) ≈ 0.0
# low-rank because singular values decay to zero immediately. Error
# estimator fails, and warning is thrown
tmp = 0 * M
tmp[end-20:end, :] .= rand(T, 21, n)
R = aca(tmp, irange, jrange)
@test Matrix(R) ≈ tmp
tmp = 0 * M
tmp[1:20, :] .= rand(T, 20, n)
R = aca(tmp, irange, jrange)
@test Matrix(R) ≈ tmp

rtol = 1e-5
aca = PartialACA(; rtol = rtol)
R = aca(M, irange, jrange)
Expand All @@ -31,10 +45,6 @@ Random.seed!(1)
R = aca(M, irange, jrange)
@test rank(R) == r

# test zero matrix
R = aca(zero(M), irange, jrange)
@test norm(Matrix(R)) ≈ 0.0

# test fast update of frobenius norm
m, n = 10000, 1000
r = 10
Expand Down