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!(
2424 )
2525end
2626
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+
2738function MatrixAlgebraKit. truncate! (
2839 :: typeof (svd_trunc!),
2940 (U, S, Vᴴ):: TBlockUSV ᴴ,
3041 strategy:: BlockPermutedDiagonalTruncationStrategy ,
3142)
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)
3744
3845 # first determine the block structure of the output to avoid having assumptions on the
3946 # data structures
You can’t perform that action at this time.
0 commit comments