using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing ;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Meta.Numerics.Matrices;
double[,] ptsImgOne = new double[3, 5];
double[,] ptsImgTwo = new double[3, 5];
ptsImgOne = new double[,] { { 0.41726, 0.94478, 0.33771, 0.11120, 0.24169 },
{ 0.04965, 0.49086, 0.90005, 0.78025, 0.40391},
{ 0.90271, 0.48925, 0.36924, 0.38973, 0.09645 } };
ptsImgTwo = new double[,] { { 0.13197, 0.57520, 0.35315, 0.04302, 0.73172 },
{ 0.94205, 0.05977, 0.82119, 0.16899, 0.64774 },
{ 0.95613, 0.23477, 0.01540, 0.64911, 0.45092 } };
RectangularMatrix q1 = new RectangularMatrix(ptsImgOne);
RectangularMatrix q2 = new RectangularMatrix(ptsImgTwo);
RectangularMatrix Qmultiply = new RectangularMatrix(5, 9);
for (int i = 0; i < q2.ColumnCount; i++)
{
Qmultiply[i, 0] = q1[0, i] * q2[0, i];
Qmultiply[i, 1] = q1[1, i] * q2[0, i];
Qmultiply[i, 2] = q1[2, i] * q2[0, i];
Qmultiply[i, 3] = q1[0, i] * q2[1, i];
Qmultiply[i, 4] = q1[1, i] * q2[1, i];
Qmultiply[i, 5] = q1[2, i] * q2[1, i];
Qmultiply[i, 6] = q1[0, i] * q2[2, i];
Qmultiply[i, 7] = q1[1, i] * q2[2, i];
Qmultiply[i, 8] = q1[2, i] * q2[2, i];
}
SingularValueDecomposition singValDec= Qmultiply.SingularValueDecomposition();
}
}
}
I am using Meta.Numerics.Matrices to work with matrices and calculate SVD,
but whenever the compiler get to to the last line of code:
“SingularValueDecomposition singValDec=Qmultiply.SingularValueDecomposition();”
I get an error saying Index was outisde the bounds of array. I double-checked boundries for the Qmultiply array and the rest.I tried to debug it, but the error persists.
Can anyone help me fix this issue?
It seems Meta package has some bugs in calculation of SVD.
I used MathNet with same code and it worked very well.
To be on the safe side, use MathNet(Math.Numeric).