Skip to content

Commit b5d60ed

Browse files
committed
rename findtruncated_sorted to findtruncated_svd
1 parent 852774a commit b5d60ed

7 files changed

Lines changed: 15 additions & 15 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: 5 additions & 5 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

@@ -79,7 +79,7 @@ function findtruncated(values::AbstractVector, strategy::TruncationByError)
7979
I′ = _truncerr_impl(values, I; strategy.atol, strategy.rtol, strategy.p)
8080
return I[I′]
8181
end
82-
function findtruncated_sorted(values::AbstractVector, strategy::TruncationByError)
82+
function findtruncated_svd(values::AbstractVector, strategy::TruncationByError)
8383
I = eachindex(values)
8484
I′ = _truncerr_impl(values, I; strategy.atol, strategy.rtol, strategy.p)
8585
return I[I′]
@@ -107,8 +107,8 @@ function findtruncated(values::AbstractVector, strategy::TruncationIntersection)
107107
return mapreduce(Base.Fix1(findtruncated, values), _ind_intersect, strategy.components;
108108
init=trues(length(values)))
109109
end
110-
function findtruncated_sorted(values::AbstractVector, strategy::TruncationIntersection)
111-
return mapreduce(Base.Fix1(findtruncated_sorted, values), _ind_intersect,
110+
function findtruncated_svd(values::AbstractVector, strategy::TruncationIntersection)
111+
return mapreduce(Base.Fix1(findtruncated_svd, values), _ind_intersect,
112112
strategy.components; init=trues(length(values)))
113113
end
114114

test/truncate.jl

Lines changed: 3 additions & 3 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,7 +35,7 @@ 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)
@@ -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)