Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ 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)).
- The Mooncake rules for truncated decompositions with `TruncatedAlgorithm` now use the pullbacks that make use of the full decomposition. ([#171](https://github.com/QuantumKitHub/MatrixAlgebraKit.jl/pull/171))

### Deprecated
Expand Down
9 changes: 6 additions & 3 deletions src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,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)
Comment thread
lkdvos marked this conversation as resolved.
Outdated
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 @@ end
end
@inline 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 @@ end
end
@inline 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
Loading