Skip to content

Commit cab923d

Browse files
author
RAYNAUD Paul (raynaudp)
committed
add tests + change to satisfy the tests
1 parent e10fb7a commit cab923d

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/compressed_lbfgs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ end
142142
# Algorithm 3.2 (p15)
143143
# step 4, Jₖ is computed only if needed
144144
function inverse_cholesky(op::CompressedLBFGS)
145-
view(op.chol_matrix, 1:op.k, 1:op.k) .= op.α .* (transpose(view(op.Sₖ, :, 1:op.k)) * view(op.Sₖ, :, 1:op.k)) .+ view(op.Lₖ, 1:op.k, 1:op.k) * inv(op.Dₖ[1:op.k, 1:op.k]) * transpose(view(op.Lₖ, 1:op.k, 1:op.k))
145+
view(op.chol_matrix, 1:op.k, 1:op.k) .= op.α .* (transpose(view(op.Sₖ, :, 1:op.k)) * view(op.Sₖ, :, 1:op.k)) .+ view(op.Lₖ, 1:op.k, 1:op.k) * inv(Diagonal(op.Dₖ[1:op.k, 1:op.k])) * transpose(view(op.Lₖ, 1:op.k, 1:op.k))
146146
cholesky!(Symmetric(view(op.chol_matrix, 1:op.k, 1:op.k)))
147147
Jₖ = transpose(UpperTriangular(view(op.chol_matrix, 1:op.k, 1:op.k)))
148148
return Jₖ

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ include("test_linop_allocs.jl")
77
include("test_adjtrans.jl")
88
include("test_cat.jl")
99
include("test_lbfgs.jl")
10+
include("test_clbfgs.jl")
1011
include("test_lsr1.jl")
1112
include("test_kron.jl")
1213
include("test_callable.jl")

test/test_clbfgs.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@testset "CompressedLBFGS operator" begin
2+
iter=50
3+
n=100
4+
n=5
5+
lbfgs = CompressedLBFGS(n) # m=5
6+
Bv = rand(n)
7+
for i in 1:iter
8+
s = rand(n)
9+
y = rand(n)
10+
push!(lbfgs, s, y)
11+
# warmp-up computing the mandatory intermediate structures
12+
mul!(Bv, lbfgs, s)
13+
allocs = @allocated mul!(Bv, lbfgs, s)
14+
@test allocs == 0
15+
@test Bv y
16+
end
17+
end

0 commit comments

Comments
 (0)