Skip to content

Commit b9a0173

Browse files
committed
Implement isposdef
1 parent 383d808 commit b9a0173

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

src/tensors/factorizations/factorizations.jl

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,6 @@ include("matrixalgebrakit.jl")
4545
include("truncation.jl")
4646
include("deprecations.jl")
4747

48-
"""
49-
isposdef(t::AbstractTensor, (leftind, rightind)::Index2Tuple) -> ::Bool
50-
51-
Test whether a tensor `t` is positive definite as linear map from `rightind` to `leftind`.
52-
53-
If `leftind` and `rightind` are not specified, the current partition of left and right
54-
indices of `t` is used. In that case, less memory is allocated if one allows the data in
55-
`t` to be destroyed/overwritten, by using `isposdef!(t)`. Note that the permuted tensor on
56-
which `isposdef!` is called should have equal domain and codomain, as otherwise it is
57-
meaningless.
58-
"""
59-
function LinearAlgebra.isposdef(t::AbstractTensorMap, (p₁, p₂)::Index2Tuple)
60-
tcopy = permutedcopy_oftype(t, factorisation_scalartype(isposdef, t), p)
61-
return isposdef!(tcopy)
62-
end
63-
function LinearAlgebra.isposdef(t::AbstractTensorMap)
64-
tcopy = copy_oftype(t, float(scalartype(t)))
65-
return isposdef!(tcopy)
66-
end
6748

6849
function isisometry(t::AbstractTensorMap, (p₁, p₂)::Index2Tuple)
6950
t = permute(t, (p₁, p₂); copy=false)

src/tensors/factorizations/interface.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,21 @@ matrices. See the corresponding documentation for more information.
217217
See also [`eig(!)`](@ref eig) and [`eigh(!)`](@ref)
218218
""" eigen(::AbstractTensorMap), eigen!(::AbstractTensorMap)
219219

220+
@doc """
221+
isposdef(t::AbstractTensor, [(leftind, rightind)::Index2Tuple]) -> ::Bool
222+
223+
Test whether a tensor `t` is positive definite as linear map from `rightind` to `leftind`.
224+
225+
If `leftind` and `rightind` are not specified, the current partition of left and right
226+
indices of `t` is used. In that case, less memory is allocated if one allows the data in
227+
`t` to be destroyed/overwritten, by using `isposdef!(t)`. Note that the permuted tensor on
228+
which `isposdef!` is called should have equal domain and codomain, as otherwise it is
229+
meaningless.
230+
""" isposdef(::AbstractTensorMap), isposdef!(::AbstractTensorMap)
231+
220232
for f in
221233
(:tsvd, :eig, :eigh, :eigen, :leftorth, :rightorth, :leftpolar, :rightpolar, :leftnull,
222-
:rightnull)
234+
:rightnull, :isposdef)
223235
f! = Symbol(f, :!)
224236
@eval function $f(t::AbstractTensorMap, p::Index2Tuple; kwargs...)
225237
tcopy = permutedcopy_oftype(t, factorisation_scalartype($f, t), p)

0 commit comments

Comments
 (0)