Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ When releasing a new version, move the "Unreleased" changes to a new version sec

### Changed

- The default behavior of SVD-based nullspaces now includes some small tolerance ([#172](https://github.com/QuantumKitHub/MatrixAlgebraKit.jl/pull/170)).

### Deprecated

### Removed
Expand Down
9 changes: 6 additions & 3 deletions src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,17 @@ function select_truncation(trunc)
end

@doc """
MatrixAlgebraKit.select_null_truncation(trunc)
MatrixAlgebraKit.select_null_truncation(A, trunc)

Construct a [`TruncationStrategy`](@ref) from the given `NamedTuple` of keywords or input strategy, to implement a nullspace selection.
Construct a [`TruncationStrategy`](@ref) for `A` from the given `NamedTuple` of keywords or input strategy, to implement a nullspace selection.
""" select_null_truncation

select_null_truncation(A, trunc) = select_null_truncation(typeof(A), trunc)
select_null_truncation(A::Type, trunc) =
isnothing(trunc) ? select_null_truncation((; atol = defaulttol(eltype(A)))) : select_null_truncation(trunc)
function select_null_truncation(trunc)
if isnothing(trunc)
return NoTruncation()
return null_truncation_strategy()
elseif trunc isa NamedTuple
return null_truncation_strategy(; trunc...)
elseif trunc isa TruncationStrategy
Expand Down
4 changes: 2 additions & 2 deletions src/interface/orthnull.jl
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ function select_algorithm(::typeof(left_null!), A, ::Val{:qr}; trunc = nothing,
end
function select_algorithm(::typeof(left_null!), A, ::Val{:svd}; trunc = nothing, kwargs...)
alg_svd = select_algorithm(svd_full!, A, get(kwargs, :svd, nothing))
alg = TruncatedAlgorithm(alg_svd, select_null_truncation(trunc))
alg = TruncatedAlgorithm(alg_svd, select_null_truncation(A, trunc))
return LeftNullViaSVD(alg)
end

Expand All @@ -390,7 +390,7 @@ function select_algorithm(::typeof(right_null!), A, ::Val{:lq}; trunc = nothing,
end
function select_algorithm(::typeof(right_null!), A, ::Val{:svd}; trunc = nothing, kwargs...)
alg_svd = select_algorithm(svd_full!, A; kwargs...)
alg = TruncatedAlgorithm(alg_svd, select_null_truncation(trunc))
alg = TruncatedAlgorithm(alg_svd, select_null_truncation(A, trunc))
return RightNullViaSVD(alg)
end

Expand Down