Cytnx icon indicating copy to clipboard operation
Cytnx copied to clipboard

Inv: bug fix and implementation for UniTensor

Open manuschneider opened this issue 3 months ago • 4 comments

-fixed a bug in Inv, where the clipping was applied to the value instead of the absolute part of it for real valued Tensors. -implemented Inv for UniTensor

manuschneider avatar Sep 20 '25 05:09 manuschneider

Codecov Report

:x: Patch coverage is 55.31915% with 42 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 32.16%. Comparing base (be1cfcf) to head (e839fa8). :warning: Report is 66 commits behind head on master.

Files with missing lines Patch % Lines
...ckend/linalg_internal_cpu/Inv_inplace_internal.cpp 25.00% 16 Missing and 2 partials :warning:
include/UniTensor.hpp 38.46% 0 Missing and 8 partials :warning:
src/linalg/Inv.cpp 61.53% 3 Missing and 2 partials :warning:
src/linalg/Inv_.cpp 50.00% 4 Missing and 1 partial :warning:
src/linalg/Pow.cpp 60.00% 1 Missing and 1 partial :warning:
src/linalg/Pow_.cpp 60.00% 1 Missing and 1 partial :warning:
src/linalg/Gesvd_truncate.cpp 90.00% 1 Missing :warning:
src/linalg/Svd_truncate.cpp 90.00% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #680      +/-   ##
==========================================
+ Coverage   32.07%   32.16%   +0.08%     
==========================================
  Files         215      215              
  Lines       36242    36316      +74     
  Branches    14543    14583      +40     
==========================================
+ Hits        11626    11680      +54     
- Misses      22692    22700       +8     
- Partials     1924     1936      +12     

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

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Sep 20 '25 05:09 codecov[bot]

I revised Inv and Pow. Both is available in cytnx::linalg and as methods of UniTensor. I updated the comments and wrote tests. These two functions can be taken as blueprints to implement the other elementwise linalg functions for UniTensor, as suggested in https://github.com/Cytnx-dev/Cytnx/issues/681 Breaking changes: The condition $\sqrt{Re^2 + Im^2} \le \mathrm{clip}$ is used for the pseudo-inverse. This way, real and complex numbers are treated similarly. The implementation is fast.

The changes can be reviewed and merged now.

manuschneider avatar Sep 24 '25 21:09 manuschneider

The TDVP check fails. It seems that the Lanczos does not converge. However, the algorithm should not be affected by any of the changes in this branch. Could it be that TDVP is sensitive to the random seed? On my machine the TDVP check works fine (Linux). Any suggestions?

manuschneider avatar Sep 25 '25 05:09 manuschneider

The TDVP check fails. It seems that the Lanczos does not converge. However, the algorithm should not be affected by any of the changes in this branch. Could it be that TDVP is sensitive to the random seed? On my machine the TDVP check works fine (Linux). Any suggestions?

I will check.

hunghaoti avatar Sep 27 '25 03:09 hunghaoti

#690 is still open, I would like to fix it before merging, since some breaking changes are introduced here.

manuschneider avatar Nov 27 '25 10:11 manuschneider