Skip to content

Commit b9d6d2c

Browse files
authored
Fix TruncationIntersection implementation and test (#300)
* some more small truncation fixes * add tests
1 parent 4ab4707 commit b9d6d2c

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/factorizations/truncation.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,19 +225,19 @@ function MAK.findtruncated_svd(values::SectorDict, strategy::TruncationSpace)
225225
end
226226

227227
function MAK.findtruncated(values::SectorDict, strategy::TruncationIntersection)
228-
inds = map(Base.Fix1(MAK.findtruncated, values), strategy)
228+
inds = map(Base.Fix1(MAK.findtruncated, values), strategy.components)
229229
return SectorDict(
230230
c => mapreduce(
231-
Base.Fix2(getindex, c), _ind_intersect, inds;
231+
Base.Fix2(getindex, c), MatrixAlgebraKit._ind_intersect, inds;
232232
init = trues(length(values[c]))
233233
) for c in intersect(map(keys, inds)...)
234234
)
235235
end
236-
function MAK.findtruncated_svd(Sd::SectorDict, strategy::TruncationIntersection)
237-
inds = map(Base.Fix1(MAK.findtruncated_svd, Sd), strategy)
236+
function MAK.findtruncated_svd(values::SectorDict, strategy::TruncationIntersection)
237+
inds = map(Base.Fix1(MAK.findtruncated_svd, values), strategy.components)
238238
return SectorDict(
239239
c => mapreduce(
240-
Base.Fix2(getindex, c), _ind_intersect, inds;
240+
Base.Fix2(getindex, c), MatrixAlgebraKit._ind_intersect, inds;
241241
init = trues(length(values[c]))
242242
) for c in intersect(map(keys, inds)...)
243243
)

test/factorizations.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,14 @@ for V in spacelist
260260
@test isisometry(U4)
261261
@test isisometry(Vᴴ4; side = :right)
262262
@test norm(t - U4 * S4 * Vᴴ4) <= 0.5
263+
264+
trunc = truncrank(dim(domain(S)) ÷ 2) & trunctol(; atol = λ - 10eps(λ))
265+
U5, S5, Vᴴ5 = @constinferred svd_trunc(t; trunc)
266+
@test t * Vᴴ5' U5 * S5
267+
@test isisometry(U5)
268+
@test isisometry(Vᴴ5; side = :right)
269+
@test minimum(minimum, values(LinearAlgebra.diag(S5))) >= λ
270+
@test dim(domain(S5)) dim(domain(S)) ÷ 2
263271
end
264272
end
265273

0 commit comments

Comments
 (0)