public void LuDecompositionConstructorTest()
{
float[][] value =
{
new float[] { 2, -1, 0 },
new float[] { -1, 2, -1 },
new float[] { 0, -1, 2 }
};
float[][] expectedL =
{
new float[] { 1.0000f, 0f, 0f },
new float[] { -0.5000f, 1.0000f, 0f },
new float[] { 0f, -0.6667f, 1.0000f },
};
float[][] expectedU =
{
new float[] { 2.0000f, -1.0000f, 0f },
new float[] { 0f, 1.5000f, -1.0000f },
new float[] { 0f, 0f, 1.3333f },
};
JaggedLuDecompositionF target = new JaggedLuDecompositionF(value);
float[][] actualL = target.LowerTriangularFactor;
float[][] actualU = target.UpperTriangularFactor;
Assert.IsTrue(Matrix.IsEqual(expectedL, actualL, 0.001f));
Assert.IsTrue(Matrix.IsEqual(expectedU, actualU, 0.001f));
target = new JaggedLuDecompositionF(value.Transpose(), true);
actualL = target.LowerTriangularFactor;
actualU = target.UpperTriangularFactor;
Assert.IsTrue(Matrix.IsEqual(expectedL, actualL, 0.001f));
Assert.IsTrue(Matrix.IsEqual(expectedU, actualU, 0.001f));
}