Skip to content

Commit cdd507d

Browse files
committed
Support QR and LQ
1 parent bfb622d commit cdd507d

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,6 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
6262

6363
[targets]
6464
test = ["Aqua", "Combinatorics", "LinearAlgebra", "TensorOperations", "Test", "TestExtras", "ChainRulesCore", "ChainRulesTestUtils", "FiniteDifferences", "Zygote"]
65+
66+
[sources]
67+
MatrixAlgebraKit = {url="https://github.com/QuantumKitHub/MatrixAlgebraKit.jl", rev="ksh/copyfix"}

src/TensorKit.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export mul!, lmul!, rmul!, adjoint!, pinv, axpy!, axpby!
7373
export leftorth, rightorth, leftnull, rightnull,
7474
leftorth!, rightorth!, leftnull!, rightnull!,
7575
left_polar, left_polar!, right_polar, right_polar!,
76+
qr_full, qr_compact, qr_null, lq_full, lq_compact, lq_null,
77+
qr_full!, qr_compact!, qr_null!, lq_full!, lq_compact!, lq_null!,
7678
tsvd!, tsvd, eigen, eigen!, eig, eig!, eigh, eigh!, exp, exp!,
7779
isposdef, isposdef!, ishermitian, isisometry, isunitary, sylvester, rank, cond
7880
export braid, braid!, permute, permute!, transpose, transpose!, twist, twist!, repartition,

src/tensors/factorizations/factorizations.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ export eig, eig!, eigh, eigh!
77
export tsvd, tsvd!, svdvals, svdvals!
88
export leftorth, leftorth!, rightorth, rightorth!
99
export leftnull, leftnull!, rightnull, rightnull!
10+
export qr_full, qr_compact, qr_null
11+
export qr_full!, qr_compact!, qr_null!
12+
export lq_full, lq_compact, lq_null
13+
export lq_full!, lq_compact!, lq_null!
1014
export copy_oftype, permutedcopy_oftype, one!
1115
export TruncationScheme, notrunc, truncbelow, truncerr, truncdim, truncspace, PolarViaSVD
1216

test/factorizations.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,36 @@ for V in spacelist
2929
# Test both a normal tensor and an adjoint one.
3030
ts = (rand(T, W, W'), rand(T, W, W')', rand(T, V1, W'), rand(T, V1, W')')
3131
@testset for t in ts
32+
@testset "qr_full" begin
33+
Q, R = @constinferred qr_full(t)
34+
@test isisometry(Q)
35+
@test Q * R t
36+
end
37+
@testset "qr_compact" begin
38+
Q, R = @constinferred qr_compact(t)
39+
@test isisometry(Q)
40+
@test Q * R t
41+
end
42+
@testset "qr_null" begin
43+
N = @constinferred qr_null(t)
44+
@test isisometry(N)
45+
@test norm(N' * t) < 100 * eps(norm(t))
46+
end
47+
@testset "lq_full" begin
48+
L, Q = @constinferred lq_full(t)
49+
@test isisometry(Q; side=:right)
50+
@test L * Q t
51+
end
52+
@testset "lq_compact" begin
53+
L, Q = @constinferred lq_compact(t)
54+
@test isisometry(Q; side=:right)
55+
@test L * Q t
56+
end
57+
@testset "lq_null" begin
58+
Nᴴ = @constinferred lq_null(t)
59+
@test isisometry(Nᴴ; side=:right)
60+
@test norm(t * Nᴴ') < 100 * eps(norm(t))
61+
end
3262
@testset "leftorth with $alg" for alg in
3363
(TensorKit.LAPACK_HouseholderQR(),
3464
TensorKit.LAPACK_HouseholderQR(;

0 commit comments

Comments
 (0)