forked from root-project/root
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[matrix] Fix TMatrixTSparse::SetMatrixArray for RowLwb!=0:
Addresses root-project#13848 Thanks, Eddy!
- Loading branch information
1 parent
f5040c3
commit 9ff6706
Showing
4 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,3 +81,6 @@ ROOT_STANDARD_LIBRARY_PACKAGE(Matrix | |
DICTIONARY_OPTIONS | ||
-writeEmptyRootPCM | ||
) | ||
|
||
ROOT_ADD_TEST_SUBDIRECTORY(test) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Copyright (C) 1995-2023, Rene Brun and Fons Rademakers. | ||
# All rights reserved. | ||
# | ||
# For the licensing terms see $ROOTSYS/LICENSE. | ||
# For the list of contributors see $ROOTSYS/README/CREDITS. | ||
|
||
ROOT_ADD_GTEST(testMatrixTSparse testMatrixTSparse.cxx LIBRARIES Matrix) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Authors: Eddy Offermann Oct 2023 | ||
|
||
/************************************************************************* | ||
* Copyright (C) 1995-2023, Rene Brun and Fons Rademakers. * | ||
* All rights reserved. * | ||
* * | ||
* For the licensing terms see $ROOTSYS/LICENSE. * | ||
* For the list of contributors see $ROOTSYS/README/CREDITS. * | ||
*************************************************************************/ | ||
|
||
#include "TMatrixD.h" | ||
#include "TMatrixDSparse.h" | ||
#include "TMath.h" | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include <array> | ||
|
||
// https://github.com/root-project/root/issues/13848 | ||
TEST(testSparse, LwbInit) | ||
{ | ||
constexpr int msize = 5; | ||
TMatrixDSparse m1(1, 4, 0, msize - 1); | ||
{ | ||
constexpr int nr = 4 * msize; | ||
std::array<int, nr> irow; | ||
std::array<int, nr> icol; | ||
std::array<double, nr> val; | ||
|
||
Int_t n = 0; | ||
for (int i = m1.GetRowLwb(); i <= m1.GetRowUpb(); i++) { | ||
for (int 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.data(), icol.data(), val.data()); | ||
} | ||
|
||
TMatrixD m2(1, 4, 0, msize - 1); | ||
for (int i = m2.GetRowLwb(); i <= m2.GetRowUpb(); i++) | ||
for (int j = m2.GetColLwb(); j <= m2.GetColUpb(); j++) | ||
m2(i,j) = TMath::Pi() * i + TMath::E() * j; | ||
|
||
EXPECT_EQ(m1, m2); | ||
} |