-
Notifications
You must be signed in to change notification settings - Fork 49
[WIP] MatrixAlgebraKit decompositions #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #230 +/- ##
==========================================
- Coverage 82.63% 73.28% -9.35%
==========================================
Files 43 45 +2
Lines 5557 5649 +92
==========================================
- Hits 4592 4140 -452
- Misses 965 1509 +544 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The test failures on empty tensors should be resolved once QuantumKitHub/MatrixAlgebraKit.jl#37 is merged. @Jutho I think this is ready for another round of review, it definitely requires a bunch more cleanup but I think I am getting somewhere now, the improvements in MatrixAlgebraKit have definitely helped a bunch. |
@@ -265,6 +275,21 @@ function LinearAlgebra.mul!(dC::DiagonalTensorMap, | |||
return dC | |||
end | |||
|
|||
function LinearAlgebra.lmul!(D::DiagonalTensorMap, t::AbstractTensorMap) | |||
domain(D) == codomain(t) || throw(SpaceMismatch()) | |||
for (c, b) in blocks(t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we immediately want to write this using foreachblock
?
end | ||
function LinearAlgebra.rmul!(t::AbstractTensorMap, D::DiagonalTensorMap) | ||
codomain(D) == domain(t) || throw(SpaceMismatch()) | ||
for (c, b) in blocks(t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment/question.
return isposdef!(tcopy) | ||
end | ||
function LinearAlgebra.isposdef(t::AbstractTensorMap) | ||
tcopy = copy_oftype(t, float(scalartype(t))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the second argument also be factorisation_scalartype(isposdef, t)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to ask this still: do you think it is reasonable to just adopt isposdef
in the list above, and actually define it both for isposdef(t, p)
and isposdef
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and implemented this as such, if you disagree I'm happy to change it back.
This PR is part of a large set of changes that alters the backend from
TensorKit.MatrixAlgebra
toMatrixAlgebraKit
for the factorizations.Concretely, this is achieved through a new submodule
TensorKit.Factorizations
that implements most of theMatrixAlgebraKit
interface, along with some overloads and reimplementations to be somewhat backwards compatible.New features
foreachblock(f, t::AbstractTensorMap...)
is a new function that is meant to provide a uniform interface to iterate through the blocks of a collection of tensors. The main purpose is to centralize this concept to easily add multithreading over the blocks. In order to break up this PR the actual multithreading implementation is left for a follow-up PR.eig
,eigh
andeigen
now have preliminary support for a truncated version of these algorithms.ominus
and its unicode variant can now be used to obtain the orthogonal complement of a space, ie ifW = oplus(V1, V2)
,V2 = ominus(W, V1)
.Breaking changes
tsvd
function no longer outputs the truncation error, and instead just givesU, S, Vh
.MatrixAlgebraKit
. This meanstruncdim
is replaced bytruncrank
,trunctol
is replaced bytruncbelow
, and there are deprecation warnings for the old functions.leftorth
andrightorth
functions will now always output tensors with a single space connecting them, which was not the case forPolar
decompositions previously. To retrieve the old behavior withisposdef
R
factors (equal domain and codomain instead of isomorphic), new functionsleftpolar
andrightpolar
are added.leftorth
andrightorth
functions will now always have a connecting space withisdual=false
. This is different from the previous behavior where someN,1
or1,N
tensors kept theisdual
flag on the connecting leg.