Skip to content

Commit

Permalink
Switch to explicit nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlevy committed Oct 18, 2023
1 parent 0cacd23 commit 742498c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/tensor_operations/matrix_decomposition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ Perform a factorization of `A` into ITensors `L` and `R` such that `A ≈ L * R`
For truncation arguments, see: [`svd`](@ref)
"""
function factorize(A::ITensor, Linds...; kwargs...)
function factorize(A::ITensor, Linds...; maxdim=nothing, kwargs...)
ortho::String = get(kwargs, :ortho, "left")
tags::TagSet = get(kwargs, :tags, "Link,fact")
plev::Int = get(kwargs, :plev, 0)
Expand Down Expand Up @@ -666,7 +666,10 @@ function factorize(A::ITensor, Linds...; kwargs...)
Ris = uniqueinds(A, Lis)
dL, dR = dim(Lis), dim(Ris)
# maxdim is forced to be at most the max given SVD
maxdim = min(get(kwargs, :maxdim, min(dL, dR)), min(dL, dR))
if isnothing(maxdim)
maxdim = min(dL, dR)
end
maxdim = min(maxdim, min(dL, dR))
might_truncate = !isnothing(cutoff) || maxdim < min(dL, dR)

if isnothing(which_decomp)
Expand All @@ -680,7 +683,7 @@ function factorize(A::ITensor, Linds...; kwargs...)
end

if which_decomp == "svd"
LR = factorize_svd(A, Linds...; kwargs...)
LR = factorize_svd(A, Linds...; kwargs..., maxdim=maxdim)
if isnothing(LR)
return nothing
end
Expand Down

0 comments on commit 742498c

Please sign in to comment.