Skip to content

Commit 14c971d

Browse files
committed
More matrix factorizations
1 parent 16aca55 commit 14c971d

File tree

4 files changed

+195
-218
lines changed

4 files changed

+195
-218
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TensorAlgebra"
22
uuid = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.2.9"
4+
version = "0.2.10"
55

66
[deps]
77
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/MatrixAlgebra.jl

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ using MatrixAlgebraKit:
1616
eigh_vals!,
1717
left_orth,
1818
left_orth!,
19+
left_polar,
20+
left_polar!,
1921
lq_full,
2022
lq_full!,
2123
lq_compact,
@@ -26,6 +28,8 @@ using MatrixAlgebraKit:
2628
qr_compact!,
2729
right_orth,
2830
right_orth!,
31+
right_polar,
32+
right_polar!,
2933
svd_full,
3034
svd_full!,
3135
svd_compact,
@@ -91,14 +95,43 @@ for (svd, svd_trunc, svd_full, svd_compact) in (
9195
end
9296
end
9397

94-
for (factorize, left_orth, right_orth) in
95-
((:factorize, :left_orth, :right_orth), (:factorize!, :left_orth!, :right_orth!))
98+
for (polar, left_polar, right_polar) in
99+
((:polar, :left_polar, :right_polar), (:polar!, :left_polar!, :right_polar!))
96100
@eval begin
97-
function $factorize(A::AbstractMatrix; orth=:left, kwargs...)
98-
f = if orth == :left
101+
function $polar(A::AbstractMatrix; side=:left, kwargs...)
102+
f = if side == :left
103+
$left_polar
104+
elseif side == :right
105+
$right_polar
106+
else
107+
throw(ArgumentError("`side=$side` not supported."))
108+
end
109+
return f(A; kwargs...)
110+
end
111+
end
112+
end
113+
114+
for (orth, left_orth, right_orth) in
115+
((:orth, :left_orth, :right_orth), (:orth!, :left_orth!, :right_orth!))
116+
@eval begin
117+
function $orth(A::AbstractMatrix; side=:left, kwargs...)
118+
f = if side == :left
99119
$left_orth
100-
elseif orth == :right
120+
elseif side == :right
101121
$right_orth
122+
else
123+
throw(ArgumentError("`side=$side` not supported."))
124+
end
125+
return f(A; kwargs...)
126+
end
127+
end
128+
end
129+
130+
for (factorize, orth_f) in ((:factorize, :(MatrixAlgebra.orth)), (:factorize!, :orth!))
131+
@eval begin
132+
function $factorize(A::AbstractMatrix; orth=:left, kwargs...)
133+
f = if orth in (:left, :right)
134+
$orth_f
102135
else
103136
throw(ArgumentError("`orth=$orth` not supported."))
104137
end

0 commit comments

Comments
 (0)