Skip to content
Merged
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
4 changes: 1 addition & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ OhMyThreads = "67456a42-1dca-4109-a031-0a68de7e3ad5"
PackageExtensionCompat = "65ce6f38-6b18-4e1d-a461-8949797d7930"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ScopedValues = "7e506255-f358-4e82-b7e4-beb19740aa63"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67"
TensorKitSectors = "13a9c161-d5da-41f0-bcbd-e1a08ae0647f"
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
Expand All @@ -34,12 +33,11 @@ Combinatorics = "1"
FiniteDifferences = "0.12"
LRUCache = "1.0.2"
LinearAlgebra = "1"
MatrixAlgebraKit = "0.2.5"
MatrixAlgebraKit = "0.3"
OhMyThreads = "0.8.0"
PackageExtensionCompat = "1"
Random = "1"
ScopedValues = "1.3.0"
SparseArrays = "1"
Strided = "2"
TensorKitSectors = "0.1"
TensorOperations = "5.1"
Expand Down
1 change: 1 addition & 0 deletions src/TensorKit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export inner, dot, norm, normalize, normalize!, tr
export mul!, lmul!, rmul!, adjoint!, pinv, axpy!, axpby!
export leftorth, rightorth, leftnull, rightnull,
leftorth!, rightorth!, leftnull!, rightnull!,
left_polar, left_polar!, right_polar, right_polar!,
tsvd!, tsvd, eigen, eigen!, eig, eig!, eigh, eigh!, exp, exp!,
isposdef, isposdef!, ishermitian, isisometry, isunitary, sylvester, rank, cond
export braid, braid!, permute, permute!, transpose, transpose!, twist, twist!, repartition,
Expand Down
46 changes: 23 additions & 23 deletions src/tensors/factorizations/matrixalgebrakit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ for f! in (:qr_compact!, :qr_full!,
:svd_compact!, :svd_full!,
:left_polar!, :left_orth_polar!, :right_polar!, :right_orth_polar!)
@eval function $f!(t::AbstractTensorMap, F, alg::AbstractAlgorithm)
check_input($f!, t, F)
check_input($f!, t, F, alg)

foreachblock(t, F...) do _, bs
factors = Base.tail(bs)
Expand All @@ -45,7 +45,7 @@ end
# Handle these separately because single output instead of tuple
for f! in (:qr_null!, :lq_null!, :svd_vals!, :eig_vals!, :eigh_vals!)
@eval function $f!(t::AbstractTensorMap, N, alg::AbstractAlgorithm)
check_input($f!, t, N)
check_input($f!, t, N, alg)

foreachblock(t, N) do _, (b, n)
n′ = $f!(b, n, alg)
Expand All @@ -63,7 +63,7 @@ end
const _T_USVᴴ = Tuple{<:AbstractTensorMap,<:AbstractTensorMap,<:AbstractTensorMap}
const _T_USVᴴ_diag = Tuple{<:AbstractTensorMap,<:DiagonalTensorMap,<:AbstractTensorMap}

function check_input(::typeof(svd_full!), t::AbstractTensorMap, (U, S, Vᴴ)::_T_USVᴴ)
function check_input(::typeof(svd_full!), t::AbstractTensorMap, (U, S, Vᴴ)::_T_USVᴴ, ::AbstractAlgorithm)
# scalartype checks
@check_scalar U t
@check_scalar S t real
Expand All @@ -79,7 +79,7 @@ function check_input(::typeof(svd_full!), t::AbstractTensorMap, (U, S, Vᴴ)::_T
return nothing
end

function check_input(::typeof(svd_compact!), t::AbstractTensorMap, (U, S, Vᴴ)::_T_USVᴴ_diag)
function check_input(::typeof(svd_compact!), t::AbstractTensorMap, (U, S, Vᴴ)::_T_USVᴴ_diag, ::AbstractAlgorithm)
# scalartype checks
@check_scalar U t
@check_scalar S t real
Expand All @@ -94,7 +94,7 @@ function check_input(::typeof(svd_compact!), t::AbstractTensorMap, (U, S, Vᴴ):
return nothing
end

function check_input(::typeof(svd_vals!), t::AbstractTensorMap, S::SectorDict)
function check_input(::typeof(svd_vals!), t::AbstractTensorMap, S::SectorDict, ::AbstractAlgorithm)
@check_scalar S t real
V_cod = infimum(fuse(codomain(t)), fuse(domain(t)))
@check_space(S, V_cod ← V_dom)
Expand Down Expand Up @@ -139,7 +139,7 @@ end
# ------------------------
const _T_DV = Tuple{<:DiagonalTensorMap,<:AbstractTensorMap}

function check_input(::typeof(eigh_full!), t::AbstractTensorMap, (D, V)::_T_DV)
function check_input(::typeof(eigh_full!), t::AbstractTensorMap, (D, V)::_T_DV, ::AbstractAlgorithm)
domain(t) == codomain(t) ||
throw(ArgumentError("Eigenvalue decomposition requires square input tensor"))

Expand All @@ -155,7 +155,7 @@ function check_input(::typeof(eigh_full!), t::AbstractTensorMap, (D, V)::_T_DV)
return nothing
end

function check_input(::typeof(eig_full!), t::AbstractTensorMap, (D, V)::_T_DV)
function check_input(::typeof(eig_full!), t::AbstractTensorMap, (D, V)::_T_DV, ::AbstractAlgorithm)
domain(t) == codomain(t) ||
throw(ArgumentError("Eigenvalue decomposition requires square input tensor"))

Expand All @@ -171,14 +171,14 @@ function check_input(::typeof(eig_full!), t::AbstractTensorMap, (D, V)::_T_DV)
return nothing
end

function check_input(::typeof(eigh_vals!), t::AbstractTensorMap, D::DiagonalTensorMap)
function check_input(::typeof(eigh_vals!), t::AbstractTensorMap, D::DiagonalTensorMap, ::AbstractAlgorithm)
@check_scalar D t real
V_D = fuse(domain(t))
@check_space(D, V_D ← V_D)
return nothing
end

function check_input(::typeof(eig_vals!), t::AbstractTensorMap, D::DiagonalTensorMap)
function check_input(::typeof(eig_vals!), t::AbstractTensorMap, D::DiagonalTensorMap, ::AbstractAlgorithm)
@check_scalar D t complex
V_D = fuse(domain(t))
@check_space(D, V_D ← V_D)
Expand Down Expand Up @@ -239,7 +239,7 @@ end
# ----------------
const _T_QR = Tuple{<:AbstractTensorMap,<:AbstractTensorMap}

function check_input(::typeof(qr_full!), t::AbstractTensorMap, (Q, R)::_T_QR)
function check_input(::typeof(qr_full!), t::AbstractTensorMap, (Q, R)::_T_QR, ::AbstractAlgorithm)
# scalartype checks
@check_scalar Q t
@check_scalar R t
Expand All @@ -252,7 +252,7 @@ function check_input(::typeof(qr_full!), t::AbstractTensorMap, (Q, R)::_T_QR)
return nothing
end

function check_input(::typeof(qr_compact!), t::AbstractTensorMap, (Q, R)::_T_QR)
function check_input(::typeof(qr_compact!), t::AbstractTensorMap, (Q, R)::_T_QR, ::AbstractAlgorithm)
# scalartype checks
@check_scalar Q t
@check_scalar R t
Expand All @@ -265,7 +265,7 @@ function check_input(::typeof(qr_compact!), t::AbstractTensorMap, (Q, R)::_T_QR)
return nothing
end

function check_input(::typeof(qr_null!), t::AbstractTensorMap, N::AbstractTensorMap)
function check_input(::typeof(qr_null!), t::AbstractTensorMap, N::AbstractTensorMap, ::AbstractAlgorithm)
# scalartype checks
@check_scalar N t

Expand Down Expand Up @@ -302,7 +302,7 @@ end
# ----------------
const _T_LQ = Tuple{<:AbstractTensorMap,<:AbstractTensorMap}

function check_input(::typeof(lq_full!), t::AbstractTensorMap, (L, Q)::_T_LQ)
function check_input(::typeof(lq_full!), t::AbstractTensorMap, (L, Q)::_T_LQ, ::AbstractAlgorithm)
# scalartype checks
@check_scalar L t
@check_scalar Q t
Expand All @@ -315,7 +315,7 @@ function check_input(::typeof(lq_full!), t::AbstractTensorMap, (L, Q)::_T_LQ)
return nothing
end

function check_input(::typeof(lq_compact!), t::AbstractTensorMap, (L, Q)::_T_LQ)
function check_input(::typeof(lq_compact!), t::AbstractTensorMap, (L, Q)::_T_LQ, ::AbstractAlgorithm)
# scalartype checks
@check_scalar L t
@check_scalar Q t
Expand All @@ -328,7 +328,7 @@ function check_input(::typeof(lq_compact!), t::AbstractTensorMap, (L, Q)::_T_LQ)
return nothing
end

function check_input(::typeof(lq_null!), t::AbstractTensorMap, N)
function check_input(::typeof(lq_null!), t::AbstractTensorMap, N, ::AbstractAlgorithm)
# scalartype checks
@check_scalar N t

Expand Down Expand Up @@ -367,7 +367,7 @@ const _T_WP = Tuple{<:AbstractTensorMap,<:AbstractTensorMap}
const _T_PWᴴ = Tuple{<:AbstractTensorMap,<:AbstractTensorMap}
using MatrixAlgebraKit: PolarViaSVD

function check_input(::typeof(left_polar!), t::AbstractTensorMap, (W, P)::_T_WP)
function check_input(::typeof(left_polar!), t::AbstractTensorMap, (W, P)::_T_WP, ::AbstractAlgorithm)
codomain(t) ≿ domain(t) ||
throw(ArgumentError("Polar decomposition requires `codomain(t) ≿ domain(t)`"))

Expand All @@ -382,7 +382,7 @@ function check_input(::typeof(left_polar!), t::AbstractTensorMap, (W, P)::_T_WP)
return nothing
end

function check_input(::typeof(left_orth_polar!), t::AbstractTensorMap, (W, P)::_T_WP)
function check_input(::typeof(left_orth_polar!), t::AbstractTensorMap, (W, P)::_T_WP, ::AbstractAlgorithm)
codomain(t) ≿ domain(t) ||
throw(ArgumentError("Polar decomposition requires `codomain(t) ≿ domain(t)`"))

Expand All @@ -404,7 +404,7 @@ function initialize_output(::typeof(left_polar!), t::AbstractTensorMap, ::Abstra
return W, P
end

function check_input(::typeof(right_polar!), t::AbstractTensorMap, (P, Wᴴ)::_T_PWᴴ)
function check_input(::typeof(right_polar!), t::AbstractTensorMap, (P, Wᴴ)::_T_PWᴴ, ::AbstractAlgorithm)
codomain(t) ≾ domain(t) ||
throw(ArgumentError("Polar decomposition requires `domain(t) ≿ codomain(t)`"))

Expand All @@ -419,7 +419,7 @@ function check_input(::typeof(right_polar!), t::AbstractTensorMap, (P, Wᴴ)::_T
return nothing
end

function check_input(::typeof(right_orth_polar!), t::AbstractTensorMap, (P, Wᴴ)::_T_PWᴴ)
function check_input(::typeof(right_orth_polar!), t::AbstractTensorMap, (P, Wᴴ)::_T_PWᴴ, ::AbstractAlgorithm)
codomain(t) ≾ domain(t) ||
throw(ArgumentError("Polar decomposition requires `domain(t) ≿ codomain(t)`"))

Expand Down Expand Up @@ -457,7 +457,7 @@ end
const _T_VC = Tuple{<:AbstractTensorMap,<:AbstractTensorMap}
const _T_CVᴴ = Tuple{<:AbstractTensorMap,<:AbstractTensorMap}

function check_input(::typeof(left_orth!), t::AbstractTensorMap, (V, C)::_T_VC)
function check_input(::typeof(left_orth!), t::AbstractTensorMap, (V, C)::_T_VC, ::AbstractAlgorithm)
# scalartype checks
@check_scalar V t
isnothing(C) || @check_scalar C t
Expand All @@ -470,7 +470,7 @@ function check_input(::typeof(left_orth!), t::AbstractTensorMap, (V, C)::_T_VC)
return nothing
end

function check_input(::typeof(right_orth!), t::AbstractTensorMap, (C, Vᴴ)::_T_CVᴴ)
function check_input(::typeof(right_orth!), t::AbstractTensorMap, (C, Vᴴ)::_T_CVᴴ, ::AbstractAlgorithm)
# scalartype checks
isnothing(C) || @check_scalar C t
@check_scalar Vᴴ t
Expand Down Expand Up @@ -499,7 +499,7 @@ end

# Nullspace
# ---------
function check_input(::typeof(left_null!), t::AbstractTensorMap, N)
function check_input(::typeof(left_null!), t::AbstractTensorMap, N, ::AbstractAlgorithm)
# scalartype checks
@check_scalar N t

Expand All @@ -511,7 +511,7 @@ function check_input(::typeof(left_null!), t::AbstractTensorMap, N)
return nothing
end

function check_input(::typeof(right_null!), t::AbstractTensorMap, N)
function check_input(::typeof(right_null!), t::AbstractTensorMap, N, ::AbstractAlgorithm)
@check_scalar N t

# space checks
Expand Down
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ VSU₂U₁ = (Vect[SU2Irrep ⊠ U1Irrep]((0, 0) => 1, (1 // 2, -1) => 1),
# ℂ[SU3Irrep]((0, 0, 0) => 1, (1, 0, 0) => 1, (1, 1, 0) => 1)')

Ti = time()
include("fusiontrees.jl")
#include("fusiontrees.jl")
include("spaces.jl")
include("tensors.jl")
include("diagonal.jl")
include("planar.jl")
# TODO: remove once we know AD is slow on macOS CI
if !(Sys.isapple() && get(ENV, "CI", "false") == "true") && isempty(VERSION.prerelease)
#=if !(Sys.isapple() && get(ENV, "CI", "false") == "true") && isempty(VERSION.prerelease)
include("ad.jl")
end
end=#
include("bugfixes.jl")
Tf = time()
printstyled("Finished all tests in ",
Expand Down