Skip to content
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

Incorrect initialization of TMatrixTSparse #13848

Closed
1 task
Axel-Naumann opened this issue Oct 12, 2023 · 0 comments · Fixed by #13956
Closed
1 task

Incorrect initialization of TMatrixTSparse #13848

Axel-Naumann opened this issue Oct 12, 2023 · 0 comments · Fixed by #13956
Assignees
Labels
Milestone

Comments

@Axel-Naumann
Copy link
Member

Check duplicate issues.

  • Checked for duplicates

Description

See https://root-forum.cern.ch/t/shift-of-row-index-in-tmatrixtsparse/56525

According to Eddy it's a bug in the initialization of a sparse matrix with a row index not starting at 0.

Reproducer

void testSparse(Int_t msize=5)
{
  TMatrixDSparse m1(1,4,0,msize-1);
  {
    Int_t nr = 4*msize;
    Int_t    *irow = new Int_t[nr];
    Int_t    *icol = new Int_t[nr];
    Double_t *val  = new Double_t[nr];

    Int_t n = 0;
    for (UInt_t i = m1.GetRowLwb(); i <= m1.GetRowUpb(); i++) {
      for (UInt_t j = m1.GetColLwb(); j <= m1.GetColUpb(); j++) {
        irow[n] = i;
        icol[n] = j;
        val[n] = TMath::Pi()*i+TMath::E()*j;
        n++;
      }
    }
    m1.SetMatrixArray(nr,irow,icol,val);
    delete [] irow;
    delete [] icol;
    delete [] val;
  }

  m1.Print();

  TMatrixD m2(1,4,0,msize-1);
  for (UInt_t i = m2.GetRowLwb(); i <= m2.GetRowUpb(); i++)
    for (UInt_t j = m2.GetColLwb(); j <= m2.GetColUpb(); j++)
      m2(i,j) = TMath::Pi()*i+TMath::E()*j;
  m2.Print();

  std::cout << "matrices identical " << ((m1 == m2) ? "OK" : "FAILED") << std::endl;
}

ROOT version

master

Installation method

any

Operating system

any

Additional context

No response

@Axel-Naumann Axel-Naumann self-assigned this Oct 12, 2023
Axel-Naumann added a commit to Axel-Naumann/root that referenced this issue Oct 12, 2023
@Axel-Naumann Axel-Naumann added this to the 6.30/00 milestone Oct 12, 2023
Axel-Naumann added a commit to Axel-Naumann/root that referenced this issue Oct 12, 2023
Axel-Naumann added a commit to Axel-Naumann/root that referenced this issue Oct 27, 2023
Axel-Naumann added a commit that referenced this issue Oct 27, 2023
Axel-Naumann added a commit that referenced this issue Oct 27, 2023
@Axel-Naumann Axel-Naumann added this to Issues in Fixed in 6.30/00 via automation Oct 27, 2023
@Axel-Naumann Axel-Naumann linked a pull request Oct 27, 2023 that will close this issue
2 tasks
maksgraczyk pushed a commit to maksgraczyk/root that referenced this issue Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

1 participant