Esempio n. 1
0
    void Test01()
    {
        var A = new double[]{
            1, 2, 3, 4,
            2, 3, 4, 1,
            3, 4, 1, 2,
            4, 1, 2, 3,
        };
        var lu = new LU(A, 4);

        var b = new double[]{ 16, 14, 16, 14 };
        var x = new double[4];
        lu.Solve(b, ref x);
        var refX = new double[] { 1, 2, 1, 2 };
        AssertX (x, refX);
    }
Esempio n. 2
0
    void Test02()
    {
        var A = new double[]{
            0, 1, 2,
            2, 0, 1,
            1, 2, 0
        };
        var lu = new LU(A, 3);
        var refLu = new double[] {
            2f,		0f,		1f,
            1f/2,	2f,		-1f/2,
            0f,		1f/2,	9f/4
        };
        AssertLU(lu, refLu);

        var b = new double[] { 8, 5, 5 };
        var x = new double[3];
        var refX = new double[] { 1, 2, 3 };
        lu.Solve(b, ref x);
        AssertX(x, refX);
    }
Esempio n. 3
0
 public Vector3D MinError()
 {
     var lu = new LU(Derivative(), 4);
     lu.Decompose();
     var x = new double[4];
     lu.Solve(new double[]{ 0.0, 0.0, 0.0, 1.0}, ref x);
     return new Vector3D(x[0], x[1], x[2]);
 }
Esempio n. 4
0
    void Test03()
    {
        var A = new double[]{
            -1, 1, 1,
            1, -1, 1,
            1, 1, -1
        };
        var lu = new LU(A, 3);

        var b = new double[]{ -3, 1, 1 };
        var refX = new double[]{ 1, -1, -1 };
        var x = new double[3];
        lu.Solve(b, ref x);
        AssertX(b, refX);
    }