Skip to content

Commit fd98f25

Browse files
committed
formatter
1 parent 1ecc8d0 commit fd98f25

File tree

6 files changed

+49
-35
lines changed

6 files changed

+49
-35
lines changed

src/auxiliary/linalg.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,3 @@ Base.adjoint(alg::Union{SVD,SDD,Polar}) = alg
4545

4646
const OFA = OrthogonalFactorizationAlgorithm
4747
const SVDAlg = Union{SVD,SDD}
48-

src/tensors/diagonal.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,15 @@ end
283283
function LinearAlgebra.lmul!(D::DiagonalTensorMap, t::AbstractTensorMap)
284284
domain(D) == codomain(t) || throw(SpaceMismatch())
285285
foreachblock(D, t) do c, bs
286-
lmul!(bs...)
286+
return lmul!(bs...)
287287
end
288288
return t
289289
end
290290

291291
function LinearAlgebra.rmul!(t::AbstractTensorMap, D::DiagonalTensorMap)
292292
codomain(D) == domain(t) || throw(SpaceMismatch())
293293
foreachblock(t, D) do c, bs
294-
rmul!(bs...)
294+
return rmul!(bs...)
295295
end
296296
return t
297297
end

src/tensors/factorizations/adjoint.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ function initialize_output(::typeof(svd_trunc!), t::AdjointTensorMap,
7272
return initialize_output(svd_compact!, t, alg.alg)
7373
end
7474
# to fix ambiguity
75-
function svd_trunc!(t::AdjointTensorMap, USVᴴ::Tuple{AdjointTensorMap,DiagonalTensorMap,AdjointTensorMap}, alg::TruncatedAlgorithm)
75+
function svd_trunc!(t::AdjointTensorMap,
76+
USVᴴ::Tuple{AdjointTensorMap,DiagonalTensorMap,AdjointTensorMap},
77+
alg::TruncatedAlgorithm)
7678
USVᴴ′ = svd_compact!(t, USVᴴ, alg.alg)
7779
return truncate!(svd_trunc!, USVᴴ′, alg.trunc)
7880
end

src/tensors/factorizations/diagonal.jl

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,28 @@
22
# -----------------
33
_repack_diagonal(d::DiagonalTensorMap) = Diagonal(d.data)
44

5-
for f in (
6-
:svd_compact, :svd_full, :svd_trunc, :svd_vals, :qr_compact, :qr_full, :qr_null,
7-
:lq_compact, :lq_full, :lq_null, :eig_full, :eig_trunc, :eig_vals, :eigh_full,
8-
:eigh_trunc, :eigh_vals, :left_polar, :right_polar,
9-
)
5+
for f in (:svd_compact, :svd_full, :svd_trunc, :svd_vals, :qr_compact, :qr_full, :qr_null,
6+
:lq_compact, :lq_full, :lq_null, :eig_full, :eig_trunc, :eig_vals, :eigh_full,
7+
:eigh_trunc, :eigh_vals, :left_polar, :right_polar)
108
@eval copy_input(::typeof($f), d::DiagonalTensorMap) = copy(d)
119
end
1210

1311
for f! in (:qr_full!, :qr_compact!, :eig_full!, :eig_trunc!, :eigh_full!, :eigh_trunc!)
14-
@eval function initialize_output(::typeof($f!), d::AbstractTensorMap, ::DiagonalAlgorithm)
12+
@eval function initialize_output(::typeof($f!), d::AbstractTensorMap,
13+
::DiagonalAlgorithm)
1514
return d, similar(d)
1615
end
1716
end
1817
for f! in (:lq_full!, :lq_compact!)
19-
@eval function initialize_output(::typeof($f!), d::AbstractTensorMap, ::DiagonalAlgorithm)
18+
@eval function initialize_output(::typeof($f!), d::AbstractTensorMap,
19+
::DiagonalAlgorithm)
2020
return similar(d), d
2121
end
2222
end
2323

24-
for f! in (:qr_full!, :qr_compact!, :lq_full!, :lq_compact!, :eig_full!, :eig_trunc!, :eigh_full!, :eigh_trunc!)
24+
for f! in
25+
(:qr_full!, :qr_compact!, :lq_full!, :lq_compact!, :eig_full!, :eig_trunc!, :eigh_full!,
26+
:eigh_trunc!)
2527
@eval function $f!(d::DiagonalTensorMap, F, alg::DiagonalAlgorithm)
2628
check_input($f!, d, F, alg)
2729
$f!(_repack_diagonal(d), _repack_diagonal.(F), alg)
@@ -30,7 +32,8 @@ for f! in (:qr_full!, :qr_compact!, :lq_full!, :lq_compact!, :eig_full!, :eig_tr
3032
end
3133

3234
for f! in (:qr_full!, :qr_compact!)
33-
@eval function check_input(::typeof($f!), d::AbstractTensorMap, (Q, R)::_T_QR, ::DiagonalAlgorithm)
35+
@eval function check_input(::typeof($f!), d::AbstractTensorMap, (Q, R)::_T_QR,
36+
::DiagonalAlgorithm)
3437
@assert d isa DiagonalTensorMap
3538
@assert Q isa DiagonalTensorMap && R isa DiagonalTensorMap
3639
@check_scalar Q d
@@ -43,7 +46,8 @@ for f! in (:qr_full!, :qr_compact!)
4346
end
4447

4548
for f! in (:lq_full!, :lq_compact!)
46-
@eval function check_input(::typeof($f!), d::AbstractTensorMap, (L, Q)::_T_LQ, ::DiagonalAlgorithm)
49+
@eval function check_input(::typeof($f!), d::AbstractTensorMap, (L, Q)::_T_LQ,
50+
::DiagonalAlgorithm)
4751
@assert d isa DiagonalTensorMap
4852
@assert Q isa DiagonalTensorMap && L isa DiagonalTensorMap
4953
@check_scalar Q d
@@ -64,7 +68,8 @@ for f! in (:eig_vals!, :eigh_vals!, :svd_vals!)
6468
$f!(_repack_diagonal(d), diagview(_repack_diagonal(V)), alg)
6569
return V
6670
end
67-
@eval function initialize_output(::typeof($f!), d::DiagonalTensorMap, alg::DiagonalAlgorithm)
71+
@eval function initialize_output(::typeof($f!), d::DiagonalTensorMap,
72+
alg::DiagonalAlgorithm)
6873
data = initialize_output($f!, _repack_diagonal(d), alg)
6974
return DiagonalTensorMap(data, d.domain)
7075
end

src/tensors/factorizations/implementations.jl

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ function _leftorth!(t, alg::Union{OFA,AbstractAlgorithm}; kwargs...)
3131

3232
kind = _kindof(alg)
3333
if kind == :svd
34-
alg_svd = alg === LAPACK_QRIteration() ? alg :
35-
alg === LAPACK_DivideAndConquer() ? alg :
34+
alg_svd = alg === LAPACK_QRIteration() ? alg :
35+
alg === LAPACK_DivideAndConquer() ? alg :
3636
alg === SVD() ? LAPACK_QRIteration() :
3737
alg === SDD() ? LAPACK_DivideAndConquer() :
3838
throw(ArgumentError(lazy"Unknown algorithm $alg"))
@@ -50,7 +50,9 @@ end
5050
_leftorth!(t, alg; kwargs...) = left_orth!(t, alg; kwargs...)
5151

5252
function leftnull!(t::AbstractTensorMap;
53-
alg::Union{LAPACK_HouseholderQR,LAPACK_QRIteration, LAPACK_DivideAndConquer,PolarViaSVD,QR,QRpos,SVD,SDD,Nothing}=nothing, kwargs...)
53+
alg::Union{LAPACK_HouseholderQR,LAPACK_QRIteration,
54+
LAPACK_DivideAndConquer,PolarViaSVD,QR,QRpos,SVD,SDD,Nothing}=nothing,
55+
kwargs...)
5456
InnerProductStyle(t) === EuclideanInnerProduct() ||
5557
throw_invalid_innerproduct(:leftnull!)
5658
trunc = isempty(kwargs) ? nothing : (; kwargs...)
@@ -60,8 +62,8 @@ function leftnull!(t::AbstractTensorMap;
6062

6163
kind = _kindof(alg)
6264
if kind == :svd
63-
alg_svd = alg === LAPACK_QRIteration() ? alg :
64-
alg === LAPACK_DivideAndConquer() ? alg :
65+
alg_svd = alg === LAPACK_QRIteration() ? alg :
66+
alg === LAPACK_DivideAndConquer() ? alg :
6567
alg === SVD() ? LAPACK_QRIteration() :
6668
alg === SDD() ? LAPACK_DivideAndConquer() :
6769
throw(ArgumentError(lazy"Unknown algorithm $alg"))
@@ -75,11 +77,13 @@ function leftnull!(t::AbstractTensorMap;
7577
end
7678

7779
function rightorth!(t::AbstractTensorMap;
78-
alg::Union{LAPACK_HouseholderLQ,LAPACK_QRIteration, LAPACK_DivideAndConquer,PolarViaSVD,LQ,LQpos,RQ,RQpos,SVD,SDD,Polar,Nothing}=nothing, kwargs...)
80+
alg::Union{LAPACK_HouseholderLQ,LAPACK_QRIteration,
81+
LAPACK_DivideAndConquer,PolarViaSVD,LQ,LQpos,RQ,RQpos,SVD,
82+
SDD,Polar,Nothing}=nothing, kwargs...)
7983
InnerProductStyle(t) === EuclideanInnerProduct() ||
8084
throw_invalid_innerproduct(:rightorth!)
8185
trunc = isempty(kwargs) ? nothing : (; kwargs...)
82-
86+
8387
alg isa OFA && Base.depwarn(lazy"$alg is deprecated", :rightorth!)
8488

8589
isnothing(alg) && return right_orth!(t; trunc)
@@ -94,8 +98,8 @@ function rightorth!(t::AbstractTensorMap;
9498

9599
kind = _kindof(alg)
96100
if kind == :svd
97-
alg_svd = alg === LAPACK_QRIteration() ? alg :
98-
alg === LAPACK_DivideAndConquer() ? alg :
101+
alg_svd = alg === LAPACK_QRIteration() ? alg :
102+
alg === LAPACK_DivideAndConquer() ? alg :
99103
alg === SVD() ? LAPACK_QRIteration() :
100104
alg === SDD() ? LAPACK_DivideAndConquer() :
101105
throw(ArgumentError(lazy"Unknown algorithm $alg"))
@@ -111,7 +115,9 @@ function rightorth!(t::AbstractTensorMap;
111115
end
112116

113117
function rightnull!(t::AbstractTensorMap;
114-
alg::Union{LAPACK_HouseholderLQ, LAPACK_QRIteration, LAPACK_DivideAndConquer,PolarViaSVD,LQ,LQpos,SVD,SDD,Nothing}=nothing, kwargs...)
118+
alg::Union{LAPACK_HouseholderLQ,LAPACK_QRIteration,
119+
LAPACK_DivideAndConquer,PolarViaSVD,LQ,LQpos,SVD,SDD,
120+
Nothing}=nothing, kwargs...)
115121
InnerProductStyle(t) === EuclideanInnerProduct() ||
116122
throw_invalid_innerproduct(:rightnull!)
117123
trunc = isempty(kwargs) ? nothing : (; kwargs...)
@@ -122,8 +128,8 @@ function rightnull!(t::AbstractTensorMap;
122128

123129
kind = _kindof(alg)
124130
if kind == :svd
125-
alg_svd = alg === LAPACK_QRIteration() ? alg :
126-
alg === LAPACK_DivideAndConquer() ? alg :
131+
alg_svd = alg === LAPACK_QRIteration() ? alg :
132+
alg === LAPACK_DivideAndConquer() ? alg :
127133
alg === SVD() ? LAPACK_QRIteration() :
128134
alg === SDD() ? LAPACK_DivideAndConquer() :
129135
throw(ArgumentError(lazy"Unknown algorithm $alg"))

test/factorizations.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ for V in spacelist
3232
# test squares and rectangles here
3333
@testset "leftorth with $alg" for alg in
3434
(TensorKit.LAPACK_HouseholderQR(),
35-
TensorKit.LAPACK_HouseholderQR(positive=true),
35+
TensorKit.LAPACK_HouseholderQR(;
36+
positive=true),
3637
#TensorKit.QL(),
3738
#TensorKit.QLpos(),
3839
TensorKit.PolarViaSVD(TensorKit.LAPACK_QRIteration()),
@@ -53,9 +54,9 @@ for V in spacelist
5354
@test norm(N' * t) < 100 * eps(norm(t))
5455
end
5556
@testset "rightorth with $alg" for alg in
56-
(#TensorKit.RQ(), TensorKit.RQpos(),
57-
TensorKit.LAPACK_HouseholderLQ(),
58-
TensorKit.LAPACK_HouseholderLQ(positive=true),
57+
(TensorKit.LAPACK_HouseholderLQ(),
58+
TensorKit.LAPACK_HouseholderLQ(;
59+
positive=true),
5960
TensorKit.PolarViaSVD(TensorKit.LAPACK_QRIteration()),
6061
TensorKit.PolarViaSVD(TensorKit.LAPACK_DivideAndConquer()),
6162
TensorKit.LAPACK_QRIteration(),
@@ -115,7 +116,8 @@ for V in spacelist
115116
t = randn(T, V1 V2, zero(V1))
116117
@testset "leftorth with $alg" for alg in
117118
(TensorKit.LAPACK_HouseholderQR(),
118-
TensorKit.LAPACK_HouseholderQR(positive=true),
119+
TensorKit.LAPACK_HouseholderQR(;
120+
positive=true),
119121
#TensorKit.QL(), TensorKit.QLpos(),
120122
TensorKit.PolarViaSVD(TensorKit.LAPACK_QRIteration()),
121123
TensorKit.PolarViaSVD(TensorKit.LAPACK_DivideAndConquer()),
@@ -133,9 +135,9 @@ for V in spacelist
133135
@test isunitary(N)
134136
end
135137
@testset "rightorth with $alg" for alg in
136-
(#TensorKit.RQ(), TensorKit.RQpos(),
137-
TensorKit.LAPACK_HouseholderLQ(),
138-
TensorKit.LAPACK_HouseholderLQ(positive=true),
138+
(TensorKit.LAPACK_HouseholderLQ(),
139+
TensorKit.LAPACK_HouseholderLQ(;
140+
positive=true),
139141
TensorKit.PolarViaSVD(TensorKit.LAPACK_QRIteration()),
140142
TensorKit.PolarViaSVD(TensorKit.LAPACK_DivideAndConquer()),
141143
TensorKit.LAPACK_QRIteration(),

0 commit comments

Comments
 (0)