private static float[,] createFundamentalMatrix(float[,] A)
{
float[,] U, V;
float[] D;
SingularValueDecompositionF svd = new SingularValueDecompositionF(A,
computeLeftSingularVectors: false, computeRightSingularVectors: true,
autoTranspose: true, inPlace: true);
V = svd.RightSingularVectors;
int s = svd.RightSingularVectors.GetLength(1) - 1;
float[,] F =
{
{ V[0, s], V[1, s], V[2, s] },
{ V[3, s], V[4, s], V[5, s] },
{ V[6, s], V[7, s], V[8, s] },
};
svd = new SingularValueDecompositionF(F,
computeLeftSingularVectors: true, computeRightSingularVectors: true,
autoTranspose: true, inPlace: false);
U = svd.LeftSingularVectors;
D = svd.Diagonal;
V = svd.RightSingularVectors;
D[2] = 0;
// Reconstruct with rank 2 approximation
var newF = U.DotWithDiagonal(D).Dot(V.Transpose());
F = newF;
return F;
}
#endregion