Skip to content

Commit 570bd4c

Browse files
committed
rename findtruncated_sorted to findtruncated_svd
1 parent af00bd8 commit 570bd4c

7 files changed

Lines changed: 18 additions & 18 deletions

File tree

docs/src/dev_interface.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ MatrixAlgebraKit.jl provides a developer interface for specifying custom algorit
1111
MatrixAlgebraKit.default_algorithm
1212
MatrixAlgebraKit.select_algorithm
1313
MatrixAlgebraKit.findtruncated
14-
MatrixAlgebraKit.findtruncated_sorted
14+
MatrixAlgebraKit.findtruncated_svd
1515
```

ext/MatrixAlgebraKitAMDGPUExt/MatrixAlgebraKitAMDGPUExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ _gpu_heevd!(A::StridedROCMatrix, Dd::StridedROCVector, V::StridedROCMatrix; kwar
4141
_gpu_heev!(A::StridedROCMatrix, Dd::StridedROCVector, V::StridedROCMatrix; kwargs...) = YArocSOLVER.heev!(A, Dd, V; kwargs...)
4242
_gpu_heevx!(A::StridedROCMatrix, Dd::StridedROCVector, V::StridedROCMatrix; kwargs...) = YArocSOLVER.heevx!(A, Dd, V; kwargs...)
4343

44-
function MatrixAlgebraKit.findtruncated_sorted(values::StridedROCVector, strategy::TruncationByValue)
44+
function MatrixAlgebraKit.findtruncated_svd(values::StridedROCVector, strategy::TruncationByValue)
4545
return MatrixAlgebraKit.findtruncated(values, strategy)
4646
end
4747

ext/MatrixAlgebraKitCUDAExt/MatrixAlgebraKitCUDAExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ _gpu_gesvdj!(A::StridedCuMatrix, S::StridedCuVector, U::StridedCuMatrix, Vᴴ::S
4444
_gpu_heevj!(A::StridedCuMatrix, Dd::StridedCuVector, V::StridedCuMatrix; kwargs...) = YACUSOLVER.heevj!(A, Dd, V; kwargs...)
4545
_gpu_heevd!(A::StridedCuMatrix, Dd::StridedCuVector, V::StridedCuMatrix; kwargs...) = YACUSOLVER.heevd!(A, Dd, V; kwargs...)
4646

47-
function MatrixAlgebraKit.findtruncated_sorted(values::StridedCuVector, strategy::TruncationByValue)
47+
function MatrixAlgebraKit.findtruncated_svd(values::StridedCuVector, strategy::TruncationByValue)
4848
return MatrixAlgebraKit.findtruncated(values, strategy)
4949
end
5050

src/MatrixAlgebraKit.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export ROCSOLVER_HouseholderQR, ROCSOLVER_QRIteration, ROCSOLVER_Jacobi,
3838
export notrunc, truncrank, trunctol, truncerror, truncfilter
3939

4040
VERSION >= v"1.11.0-DEV.469" &&
41-
eval(Expr(:public, :default_algorithm, :findtruncated, :findtruncated_sorted,
41+
eval(Expr(:public, :default_algorithm, :findtruncated, :findtruncated_svd,
4242
:select_algorithm))
4343

4444
include("common/defaults.jl")

src/algorithms.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,16 @@ based on the `strategy`. The output should be a collection of indices specifying
168168
which values to keep. `MatrixAlgebraKit.findtruncated` is used inside of the default
169169
implementation of [`truncate!`](@ref) to perform the truncation. It does not assume that the
170170
values are sorted. For a version that assumes the values are reverse sorted (which is the
171-
standard case for SVD) see [`MatrixAlgebraKit.findtruncated_sorted`](@ref).
171+
standard case for SVD) see [`MatrixAlgebraKit.findtruncated_svd`](@ref).
172172
""" findtruncated
173173

174174
@doc """
175-
MatrixAlgebraKit.findtruncated_sorted(values::AbstractVector, strategy::TruncationStrategy)
175+
MatrixAlgebraKit.findtruncated_svd(values::AbstractVector, strategy::TruncationStrategy)
176176
177177
Like [`MatrixAlgebraKit.findtruncated`](@ref) but assumes that the values are real and
178178
sorted in descending order, as typically obtained by the SVD. This assumption is not
179179
checked, and this is used in the default implementation of [`svd_trunc!`](@ref).
180-
""" findtruncated_sorted
180+
""" findtruncated_svd
181181

182182
"""
183183
TruncatedAlgorithm(alg::AbstractAlgorithm, trunc::TruncationAlgorithm)

src/implementations/truncation.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# ---------
33
# Generic implementation: `findtruncated` followed by indexing
44
function truncate!(::typeof(svd_trunc!), (U, S, Vᴴ), strategy::TruncationStrategy)
5-
ind = findtruncated_sorted(diagview(S), strategy)
5+
ind = findtruncated_svd(diagview(S), strategy)
66
return U[:, ind], Diagonal(diagview(S)[ind]), Vᴴ[ind, :]
77
end
88
function truncate!(::typeof(eig_trunc!), (D, V), strategy::TruncationStrategy)
@@ -29,7 +29,7 @@ end
2929
# findtruncated
3030
# -------------
3131
# Generic fallback
32-
function findtruncated_sorted(values::AbstractVector, strategy::TruncationStrategy)
32+
function findtruncated_svd(values::AbstractVector, strategy::TruncationStrategy)
3333
return findtruncated(values, strategy)
3434
end
3535

@@ -40,7 +40,7 @@ function findtruncated(values::AbstractVector, strategy::TruncationByOrder)
4040
howmany = min(strategy.howmany, length(values))
4141
return partialsortperm(values, 1:howmany; strategy.by, strategy.rev)
4242
end
43-
function findtruncated_sorted(values::AbstractVector, strategy::TruncationByOrder)
43+
function findtruncated_svd(values::AbstractVector, strategy::TruncationByOrder)
4444
@assert strategy.by === abs
4545
if strategy.by === abs
4646
howmany = min(strategy.howmany, length(values))
@@ -80,7 +80,7 @@ function findtruncated(values::AbstractVector, strategy::TruncationByError)
8080
I′ = _truncerr_impl(values, I; strategy.atol, strategy.rtol, strategy.p)
8181
return I[I′]
8282
end
83-
function findtruncated_sorted(values::AbstractVector, strategy::TruncationByError)
83+
function findtruncated_svd(values::AbstractVector, strategy::TruncationByError)
8484
I = eachindex(values)
8585
I′ = _truncerr_impl(values, I; strategy.atol, strategy.rtol, strategy.p)
8686
return I[I′]
@@ -108,8 +108,8 @@ function findtruncated(values::AbstractVector, strategy::TruncationIntersection)
108108
return mapreduce(Base.Fix1(findtruncated, values), _ind_intersect, strategy.components;
109109
init=trues(length(values)))
110110
end
111-
function findtruncated_sorted(values::AbstractVector, strategy::TruncationIntersection)
112-
return mapreduce(Base.Fix1(findtruncated_sorted, values), _ind_intersect,
111+
function findtruncated_svd(values::AbstractVector, strategy::TruncationIntersection)
112+
return mapreduce(Base.Fix1(findtruncated_svd, values), _ind_intersect,
113113
strategy.components; init=trues(length(values)))
114114
end
115115

test/truncate.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using Test
33
using TestExtras
44
using MatrixAlgebraKit: NoTruncation, TruncationIntersection, TruncationByOrder,
55
TruncationByValue, TruncationStrategy, findtruncated,
6-
findtruncated_sorted
6+
findtruncated_svd
77

88
@testset "truncate" begin
99
trunc = @constinferred TruncationStrategy()
@@ -35,15 +35,15 @@ using MatrixAlgebraKit: NoTruncation, TruncationIntersection, TruncationByOrder,
3535
@test @constinferred(findtruncated(values, truncrank(2))) == 1:2
3636
@test @constinferred(findtruncated(values, truncrank(2; rev=false))) == [5, 4]
3737
@test @constinferred(findtruncated(values, truncrank(2; by=((-) abs)))) == [5, 4]
38-
@test @constinferred(findtruncated_sorted(values, truncrank(2))) === 1:2
38+
@test @constinferred(findtruncated_svd(values, truncrank(2))) === 1:2
3939

4040
values = [1, 0.9, 0.5, -0.3, 0.01]
4141
strategy = trunctol(; atol=0.4)
4242
@test @constinferred(findtruncated(values, strategy)) == 1:3
43-
@test @constinferred(findtruncated_sorted(values, strategy)) === 1:3
43+
@test @constinferred(findtruncated_svd(values, strategy)) === 1:3
4444
strategy = trunctol(; atol=0.4, rev=true)
4545
@test @constinferred(findtruncated(values, strategy)) == 4:5
46-
@test @constinferred(findtruncated_sorted(values, strategy)) === 4:5
46+
@test @constinferred(findtruncated_svd(values, strategy)) === 4:5
4747

4848
values = [0.01, 1, 0.9, -0.3, 0.5]
4949
for strategy in (trunctol(; atol=0.4), trunctol(; atol=0.2, by=identity))
@@ -65,5 +65,5 @@ using MatrixAlgebraKit: NoTruncation, TruncationIntersection, TruncationByOrder,
6565
strategy = truncerror(; atol=0.2, rtol=0)
6666
@test issetequal(@constinferred(findtruncated(values, strategy)), 2:5)
6767
vals_sorted = sort(values; by=abs, rev=true)
68-
@test @constinferred(findtruncated_sorted(vals_sorted, strategy)) == 1:4
68+
@test @constinferred(findtruncated_svd(vals_sorted, strategy)) == 1:4
6969
end

0 commit comments

Comments
 (0)