I am having issues with TDecompSVD not converging on some occasions and getting the message “Error in TDecompSVD::Diagonalize: no convergence after 31 steps”. I narrowed it down to this minimal example:
main.cpp
// g++ `root-config --cflags --glibs` -o main main.cpp
#include <iostream>
#include "TROOT.h"
#include "TMatrixT.h"
#include "TVectorT.h"
#include "TDecompSVD.h"
#include "RVersion.h"
using namespace std;
int main(int argc, char** argv)
{
cout << ROOT_RELEASE << endl;
double a = 1.689339828220179e-03;
double b = 1.689339828220178e-03;
double c = 1.5e-4;
TMatrixD m(4, 3);
m(0,0) = a; m(0,1) = a; m(0,2) = -c;
m(1,0) = a; m(1,1) = a; m(1,2) = c;
m(2,0) = -b; m(2,1) = -b; m(2,2) = c;
m(3,0) = -b; m(3,1) = -b; m(3,2) = -c;
m.Print();
TDecompSVD s(m);
s.Decompose();
s.Print();
return 0;
}
Compiling with g++ root-config --cflags --glibs
-o main main.cpp and running gives me the output
6.04/14
4x3 matrix is as follows
| 0 | 1 | 2 |
--------------------------------------------
0 | 0.001689 0.001689 -0.00015
1 | 0.001689 0.001689 0.00015
2 | -0.001689 -0.001689 0.00015
3 | -0.001689 -0.001689 -0.00015
Error in <TDecompSVD::Diagonalize>: no convergence after 31 steps
fTol = 2.2204e-16
fDet1 = 0.0000e+00
fDet2 = 0.0000e+00
fCondition = -1.0000e+00
fRowLwb = 0
fColLwb = 0
4x4 matrix is as follows
| 0 | 1 | 2 | 3 |
---------------------------------------------------------
0 | -0.5 -0.5 0.5 0.5
1 | -0.5 0.8333 0.1667 0.1667
2 | 0.2236 0.07454 -0.5217 0.8199
3 | 0.6708 0.2236 0.6708 0.2236
4x3 matrix is as follows
| 0 | 1 | 2 |
--------------------------------------------
0 | -0.7071 -0.7071 0
1 | -0.7071 0.7071 -0
2 | 0 -0 -1
3 | 0 0 -0
Vector (3) fSig is as follows
| 1 |
------------------
0 |0.00477817
1 |-0
2 |0.000223607
The SVD of this matrix does work in both Mathematica and the GNU Scientific Library. Also, note that TDecompSVD does converge if you change the variable b to be exactly the same as a.
Is this a bug maybe, or am I doing something wrong?
main.cpp (702 Bytes)