File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -24,16 +24,23 @@ function MatrixAlgebraKit.truncate!(
24
24
)
25
25
end
26
26
27
+ # cannot use regular slicing here: I want to slice without altering blockstructure
28
+ # solution: use boolean indexing and slice the mask, effectively cheaply inverting the map
29
+ function MatrixAlgebraKit. findtruncated (
30
+ values:: AbstractVector , strategy:: BlockPermutedDiagonalTruncationStrategy
31
+ )
32
+ ind = MatrixAlgebraKit. findtruncated (values, strategy. strategy)
33
+ indexmask = falses (length (values))
34
+ indexmask[ind] .= true
35
+ return indexmask
36
+ end
37
+
27
38
function MatrixAlgebraKit. truncate! (
28
39
:: typeof (svd_trunc!),
29
40
(U, S, Vᴴ):: TBlockUSV ᴴ,
30
41
strategy:: BlockPermutedDiagonalTruncationStrategy ,
31
42
)
32
- ind = MatrixAlgebraKit. findtruncated (diagview (S), strategy. strategy)
33
- # cannot use regular slicing here: I want to slice without altering blockstructure
34
- # solution: use boolean indexing and slice the mask, effectively cheaply inverting the map
35
- indexmask = falses (size (S, 1 ))
36
- indexmask[ind] .= true
43
+ indexmask = MatrixAlgebraKit. findtruncated (diagview (S), strategy)
37
44
38
45
# first determine the block structure of the output to avoid having assumptions on the
39
46
# data structures
You can’t perform that action at this time.
0 commit comments