Jutho / TensorKit.jl

A Julia package for large-scale tensor computations, with a hint of category theory
MIT License
231 stars 41 forks source link

small fix in backward rule for leftorth, rightorth #123

Closed tangwei94 closed 5 months ago

tangwei94 commented 5 months ago

Previously, the backwards for leftorth and rightorth occasionally give wrong results when R or L are not used in forward computations. For example,

    function f(C1)
        U, _ = leftorth(C1; alg=QRpos())
        return norm(tr(U))
    end
    C = TensorMap(rand, ComplexF64,  ℂ^4,  ℂ^4);
    f'(C) # this gradient may be wrong
codecov[bot] commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 81.44%. Comparing base (79c2ae0) to head (225a423).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #123 +/- ## ======================================= Coverage 81.44% 81.44% ======================================= Files 42 42 Lines 5588 5588 ======================================= Hits 4551 4551 Misses 1037 1037 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Jutho commented 5 months ago

Well spotted, I can imagine that this was a tough one to debug. I will merge as soon as CI finished running.