Search in sources :

Example 11 with GVector

use of javax.vecmath.GVector in project bb4-common by bb4.

the class ConjugateGradientSolverTest method solveSimple4by4System.

@Test
public void solveSimple4by4System() {
    GVector b = new GVector(new double[] { 1, 1, 1, 1 });
    solver = new ConjugateGradientSolver(MATRIX_4x4, b);
    GVector solution = solver.solve();
    System.out.println("Solution = " + solution);
    GVector expectedSolution = new GVector(new double[] { 0.588235329, -0.76470588, 0.176470588, 1.098039215 });
    assertTrue("Unexpected solution:" + solution, LinearUtil.appxVectorsEqual(expectedSolution, solution, 0.000001));
}
Also used : GVector(javax.vecmath.GVector) Test(org.junit.Test)

Example 12 with GVector

use of javax.vecmath.GVector in project bb4-common by bb4.

the class ConjugateGradientSolverTest method solveSimple2by2System.

@Test
public void solveSimple2by2System() {
    GMatrix A = new GMatrix(2, 2, new double[] { 4, 1, 1, 3 });
    GVector b = new GVector(new double[] { 1, 2 });
    solver = new ConjugateGradientSolver(A, b);
    GVector solution = solver.solve();
    System.out.println("Solution = " + solution);
    GVector expectedSolution = new GVector(new double[] { 1.0 / 11.0, 7.0 / 11.0 });
    assertTrue("Unexpected solution:" + solution, LinearUtil.appxVectorsEqual(expectedSolution, solution, 0.000001));
}
Also used : GVector(javax.vecmath.GVector) GMatrix(javax.vecmath.GMatrix) Test(org.junit.Test)

Example 13 with GVector

use of javax.vecmath.GVector in project jwt by emweb.

the class WebGLUtils method multiply.

public static GVector multiply(Matrix4f M, GVector v) {
    assert (v.getSize() == 4);
    GVector result = new GVector(4);
    GMatrix gM = new GMatrix(4, 4);
    gM.set(M);
    result.mul(gM, v);
    return result;
}
Also used : GVector(javax.vecmath.GVector) GMatrix(javax.vecmath.GMatrix)

Aggregations

GVector (javax.vecmath.GVector)13 GMatrix (javax.vecmath.GMatrix)4 Test (org.junit.Test)4