I am trying to transpose a sparse matrix. To do that, firstly I am resizing it to a square matrix, as the following code indicates
#include "TMath.h"
#include "TMatrixF.h"
#include "TMatrixFSparse.h"
void TMatrix_Transpose(){
TMatrixFSparse G(5, 1);
//TMatrixFSparse G(5, 2);
int icol[3] = {0, 0, 0};
int irow[3] = {1, 2, 3};
float data[3] = {1.2, 1.3, 1.4};
G.SetMatrixArray(3, irow, icol, data);
G.Print();
G.ResizeTo(5, 5);
G.T();
G.ResizeTo(1, 5);
//G.ResizeTo(2, 5);
G.Print();
}
I am compiling the code in ACLiC
and the output is as expected
5x1 matrix is as follows
| 0 |
------------------
0 | 0
1 | 1.2
2 | 1.3
3 | 1.4
4 | 0
1x5 matrix is as follows
| 0 | 1 | 2 | 3 | 4 |
----------------------------------------------------------------------
0 | 0 1.2 1.3 1.4 0
The problem appears when I am changing the size of the matrix to
TMatrixFSparse G(5, 2);
I get the following output
5x2 matrix is as follows
| 0 | 1 |
-------------------------------
0 | 0 0
1 | 1.2 0
2 | 1.3 0
3 | 1.4 0
4 | 0 0
2x5 matrix is as follows
| 0 | 1 | 2 | 3 | 4 |
----------------------------------------------------------------------
Error in <operator()(Int_t,Int_t) const>: row/col indices are not set
Info in <operator()>: fNrowIndex = 3 fRowIndex[fNrowIndex-1] = 0
Error in <operator()(Int_t,Int_t) const>: row/col indices are not set
Info in <operator()>: fNrowIndex = 3 fRowIndex[fNrowIndex-1] = 0
Error in <operator()(Int_t,Int_t) const>: row/col indices are not set
Info in <operator()>: fNrowIndex = 3 fRowIndex[fNrowIndex-1] = 0
Error in <operator()(Int_t,Int_t) const>: row/col indices are not set
Info in <operator()>: fNrowIndex = 3 fRowIndex[fNrowIndex-1] = 0
Error in <operator()(Int_t,Int_t) const>: row/col indices are not set
Info in <operator()>: fNrowIndex = 3 fRowIndex[fNrowIndex-1] = 0
0 | 0 0 0 0 0
Error in <operator()(Int_t,Int_t) const>: row/col indices are not set
Info in <operator()>: fNrowIndex = 3 fRowIndex[fNrowIndex-1] = 0
Error in <operator()(Int_t,Int_t) const>: row/col indices are not set
Info in <operator()>: fNrowIndex = 3 fRowIndex[fNrowIndex-1] = 0
Error in <operator()(Int_t,Int_t) const>: row/col indices are not set
Info in <operator()>: fNrowIndex = 3 fRowIndex[fNrowIndex-1] = 0
Error in <operator()(Int_t,Int_t) const>: row/col indices are not set
Info in <operator()>: fNrowIndex = 3 fRowIndex[fNrowIndex-1] = 0
Error in <operator()(Int_t,Int_t) const>: row/col indices are not set
Info in <operator()>: fNrowIndex = 3 fRowIndex[fNrowIndex-1] = 0
1 | 0 0 0 0 0
So as you can see the transpose matrix is created but it’e empty.
Any idea on what might be the issue?
Thanks in advance!