Cytnx icon indicating copy to clipboard operation
Cytnx copied to clipboard

Divide symmetric tensor by scalar

Open manuschneider opened this issue 3 months ago • 8 comments

The division of a symmetric tensor by a scalar is implemented.

manuschneider avatar Sep 16 '25 09:09 manuschneider

Codecov Report

:x: Patch coverage is 52.63158% with 27 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 28.15%. Comparing base (2932e64) to head (6706900). :warning: Report is 51 commits behind head on master.

Files with missing lines Patch % Lines
include/UniTensor.hpp 0.00% 12 Missing :warning:
src/BlockFermionicUniTensor.cpp 66.66% 0 Missing and 6 partials :warning:
src/BlockUniTensor.cpp 68.75% 0 Missing and 5 partials :warning:
src/linalg/Div.cpp 0.00% 2 Missing :warning:
src/linalg/Mod.cpp 0.00% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #674      +/-   ##
==========================================
+ Coverage   28.05%   28.15%   +0.10%     
==========================================
  Files         215      215              
  Lines       43948    43974      +26     
  Branches    16805    16825      +20     
==========================================
+ Hits        12328    12381      +53     
+ Misses      29617    29568      -49     
- Partials     2003     2025      +22     

: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 16 '25 10:09 codecov[bot]

We should prepare another PR to update the error message.

jysh1214 avatar Sep 17 '25 07:09 jysh1214

We should prepare another PR to update the error message.

Is there an issue with it? I thought it is such a minor change that I do not bother everyone with a new PR. But if it is needed I can create a separate one.

manuschneider avatar Sep 18 '25 09:09 manuschneider

Can 5d21fc8 be compiled without 28b86ff? 5d21fc8 removed the definitions of some functions.

IvanaGyro avatar Sep 18 '25 17:09 IvanaGyro

5d21fc8 can be compiled without 28b86ff. It should fall back to the UniTensor_base implementation, which just drops an error message. For the division to work correctly the implementations of Div_ in 28b86ff are needed.

manuschneider avatar Sep 19 '25 04:09 manuschneider

5d21fc8 can be compiled without 28b86ff. It should fall back to the UniTensor_base implementation, which just drops an error message. For the division to work correctly the implementations of Div_ in 28b86ff are needed.

Here is the link error while I tried to build a simple program at 5d21fc8.

/lib/gcc/x86_64-conda-linux-gnu/13.4.0/../../../../x86_64-conda-linux-gnu/bin/ld: /tmp/cckLbN6y.ltrans0.ltrans.o:(.data.rel.ro+0x2c0): undefined reference to `cytnx::BlockUniTensor::Div_(boost::intrusive_ptr<cytnx::UniTensor_base> const&)'
/lib/gcc/x86_64-conda-linux-gnu/13.4.0/../../../../x86_64-conda-linux-gnu/bin/ld: /tmp/cckLbN6y.ltrans1.ltrans.o:(.data.rel.ro+0x288): undefined reference to `cytnx::BlockFermionicUniTensor::Div_(boost::intrusive_ptr<cytnx::UniTensor_base> const&)'
collect2: error: ld returned 1 exit status

program:

#include "cytnx.hpp"

int main() {
    cytnx::Bond bond(cytnx::BD_IN, {cytnx::Qs(1) >> 1}, {cytnx::Symmetry::FermionNumber()});
    cytnx::UniTensor unitensor({bond});
    unitensor.Div_(cytnx::Scalar(1.1));
    unitensor.Div_(unitensor);
}

IvanaGyro avatar Sep 19 '25 10:09 IvanaGyro

You are right, Div_ is declared for Block(Fermionic)UniTensors but not implemented in 5d21fc8. So please ignore that commit by itself. I added the implementation in 28b86ff.

Also, I confused myself: this pull request is not about the division by a scalar (which is already implemented and working), but about the element-wise division by a tensor.

Sorry for all the confusion.

I added some unittests for elementwise linalg operations.

manuschneider avatar Sep 19 '25 15:09 manuschneider

Is there any issue left with this pull request?

manuschneider avatar Sep 29 '25 02:09 manuschneider