Skip to content

Commit 4a722ef

Browse files
committed
enfore positive and finite p-norms
1 parent b44878f commit 4a722ef

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

ext/TensorKitCUDAExt/truncation.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ end
2121
function MatrixAlgebraKit.findtruncated(
2222
values::CuSectorVector, strategy::MatrixAlgebraKit.TruncationByError
2323
)
24+
(isfinite(strategy.p) && strategy.p > 0) ||
25+
throw(ArgumentError(lazy"p-norm with p = $(strategy.p) is currently not supported."))
2426
ϵᵖmax = max(strategy.atol^strategy.p, strategy.rtol^strategy.p * norm(values, strategy.p))
2527
ϵᵖ = similar(values, typeof(ϵᵖmax))
2628

src/factorizations/truncation.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ end
221221
# where k is determined by the cumulative truncation error of these values.
222222
# The strategy is therefore to sort all values, and then use a logical array to indicate
223223
# which ones to keep.
224-
function MAK.findtruncated(values::SectorVector, strategy::MAK.TruncationByError)
224+
function MAK.findtruncated(values::SectorVector, strategy::TruncationByError)
225+
(isfinite(strategy.p) && strategy.p > 0) ||
226+
throw(ArgumentError(lazy"p-norm with p = $(strategy.p) is currently not supported."))
225227
ϵᵖmax = max(strategy.atol^strategy.p, strategy.rtol^strategy.p * norm(values, strategy.p))
226228
ϵᵖ = similar(values, typeof(ϵᵖmax))
227229

0 commit comments

Comments
 (0)