Hi rootists!
Having to do a bit linear algebra for an analysis, I have been playing around with the matrix and vector classes in root, namely TMatrixD and TVectorD. After going through the tutorial macro solveLinear.C, I got stuck with a problem when using the Matrix utility classes, e.g. TMatrixDRow, and cint. To demonstrate it, I wrote the following small macro:
/*
File learnit.C
*/
#include <TDecompSVD>
#include <TMatrixD>
#include <TVectorD>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int learnit (void) {
//gROOT->Reset ();
// Define a vector first and print it
Double_t data [] = {4, 2, 1, 5};
TVectorD v (4, data);
v.Print ();
// Declare a Matrix and
// fill it using TMatrixDColumn
TMatrixD B (1, 4);
TMatrixDRow (B, 0) = v;
B.Print ();
return 0;
}
int main (void) {
return learnit ();
}
If I compile the above and run it, I get the expected printout:
[ul]
levent@alsant ~/my_root/Matrixtest $ ./learnit
Vector (4) is as follows
| 1 |
0 |4
1 |2
2 |1
3 |5
1x4 matrix is as follows
| 0 | 1 | 2 | 3 |
0 | 4 2 1 5
[/ul]
However, if I ran it with cint, the matrix row does not get filled with the vector values:
[ul]
levent@alsant ~/my_root/Matrixtest $ root -l ./learnit.C
root [0]
Processing ./learnit.C…
Vector (4) is as follows
| 1 |
0 |4
1 |2
2 |1
3 |5
1x4 matrix is as follows
| 0 | 1 | 2 | 3 |
0 | 0 0 0 0
(int)0
root [1]
[/ul]
I appreciate any help or hints. Thanks!
/Levent