Search in sources :

Example 81 with SimpleMatrix

use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.

the class TestHomographyTotalLeastSquares method computePseudo.

@Test
void computePseudo() {
    SimpleMatrix P = SimpleMatrix.random_DDRM(10, 2, -1, 1, rand);
    SimpleMatrix found = new SimpleMatrix(1, 1);
    HomographyTotalLeastSquares.computePseudo(P.getDDRM(), found.getDDRM());
    SimpleMatrix expected = P.transpose().mult(P).invert().mult(P.transpose());
    assertTrue(expected.isIdentical(found, UtilEjml.TEST_F64));
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Test(org.junit.jupiter.api.Test)

Example 82 with SimpleMatrix

use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.

the class TestHomographyTotalLeastSquares method computePPpX.

@Test
void computePPpX() {
    SimpleMatrix P = SimpleMatrix.random_DDRM(10, 2, -1, 1, rand);
    SimpleMatrix P_plus = SimpleMatrix.random_DDRM(2, 10, -1, 1, rand);
    SimpleMatrix X = SimpleMatrix.random_DDRM(10, 2, -1, 1, rand);
    SimpleMatrix found = new SimpleMatrix(1, 1);
    for (int i = 0; i < 2; i++) {
        HomographyTotalLeastSquares.computePPpX(P.getDDRM(), P_plus.getDDRM(), X.getDDRM(), i, found.getDDRM());
        SimpleMatrix Xx = X.extractVector(false, i);
        SimpleMatrix expected = P.mult(P_plus).mult(Xx.negative());
        assertTrue(expected.isIdentical(found, UtilEjml.TEST_F64));
    }
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Test(org.junit.jupiter.api.Test)

Example 83 with SimpleMatrix

use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.

the class TestHomographyTotalLeastSquares method constructA678.

@Test
void constructA678() {
    int N = 10;
    SimpleMatrix P = SimpleMatrix.random_DDRM(N, 2, -1, 1, rand);
    SimpleMatrix X = SimpleMatrix.random_DDRM(N, 2, -1, 1, rand);
    Equation eq = new Equation();
    eq.alias(P.copy(), "P", X.copy(), "X", N, "N");
    eq.process("X=-X");
    eq.process("Xd = diag(X(:,0))");
    eq.process("Yd = diag(X(:,1))");
    eq.process("One=ones(N,1)");
    eq.process("Pp=inv(P'*P)*P'");
    eq.process("XP=(X'*P)/N");
    eq.process("top    = [Xd*P-One*XP(0,:)-P*Pp*Xd*P , X(:,0)-P*Pp*X(:,0)]");
    eq.process("bottom = [Yd*P-One*XP(1,:)-P*Pp*Yd*P , X(:,1)-P*Pp*X(:,1)]");
    eq.process("A=[top;bottom]");
    HomographyTotalLeastSquares alg = new HomographyTotalLeastSquares();
    alg.X1.setTo(P.getDDRM());
    alg.X2.setTo(X.getDDRM());
    alg.constructA678();
    assertTrue(MatrixFeatures_DDRM.isIdentical(eq.lookupDDRM("A"), alg.A, UtilEjml.TEST_F64));
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Equation(org.ejml.equation.Equation) Test(org.junit.jupiter.api.Test)

Example 84 with SimpleMatrix

use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.

the class TestHomographyTotalLeastSquares method computePPXP.

@Test
void computePPXP() {
    SimpleMatrix P = SimpleMatrix.random_DDRM(10, 2, -1, 1, rand);
    SimpleMatrix P_plus = SimpleMatrix.random_DDRM(2, 10, -1, 1, rand);
    SimpleMatrix X = SimpleMatrix.random_DDRM(10, 2, -1, 1, rand);
    SimpleMatrix found = new SimpleMatrix(1, 1);
    for (int i = 0; i < 2; i++) {
        HomographyTotalLeastSquares.computePPXP(P.getDDRM(), P_plus.getDDRM(), X.getDDRM(), i, found.getDDRM());
        SimpleMatrix Xx = X.extractVector(false, i);
        SimpleMatrix expected = P.mult(P_plus).mult(Xx.negative().diag()).mult(P);
        assertTrue(expected.isIdentical(found, UtilEjml.TEST_F64));
    }
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Test(org.junit.jupiter.api.Test)

Example 85 with SimpleMatrix

use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.

the class TestPnPLepetitEPnP method extractNullPoints.

@Test
void extractNullPoints() {
    // create a singular matrix
    SimpleMatrix M = SimpleMatrix.wrap(RandomMatrices_DDRM.singular(12, 40, rand, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 0));
    PnPLepetitEPnP alg = new PnPLepetitEPnP();
    alg.numControl = 4;
    alg.extractNullPoints(M.getDDRM());
    // see if the first set of null points is the null space pf M*M
    List<Point3D_F64> l = alg.nullPts[0];
    SimpleMatrix v = new SimpleMatrix(12, 1);
    for (int i = 0; i < 4; i++) {
        Point3D_F64 p = l.get(i);
        v.set(3 * i + 0, p.x);
        v.set(3 * i + 1, p.y);
        v.set(3 * i + 2, p.z);
    }
    SimpleMatrix MM = M.mult(M.transpose());
    SimpleMatrix x = MM.mult(v);
    double mag = x.normF();
    assertEquals(0, mag, 1e-8);
}
Also used : SimpleMatrix(org.ejml.simple.SimpleMatrix) Point3D_F64(georegression.struct.point.Point3D_F64) Test(org.junit.jupiter.api.Test)

Aggregations

SimpleMatrix (org.ejml.simple.SimpleMatrix)156 Test (org.junit.Test)30 Layer (org.gitia.froog.layer.Layer)14 Test (org.junit.jupiter.api.Test)13 Map (java.util.Map)12 ArrayList (java.util.ArrayList)11 TransferFunction (org.gitia.froog.transferfunction.TransferFunction)10 Tree (edu.stanford.nlp.trees.Tree)9 TwoDimensionalMap (edu.stanford.nlp.util.TwoDimensionalMap)9 List (java.util.List)8 LexicalizedParser (edu.stanford.nlp.parser.lexparser.LexicalizedParser)7 Pair (edu.stanford.nlp.util.Pair)6 EmbeddingExtractor (edu.stanford.nlp.coref.neural.EmbeddingExtractor)5 Embedding (edu.stanford.nlp.neural.Embedding)5 DeepTree (edu.stanford.nlp.trees.DeepTree)5 CoreLabel (edu.stanford.nlp.ling.CoreLabel)4 SimpleTensor (edu.stanford.nlp.neural.SimpleTensor)4 DVModel (edu.stanford.nlp.parser.dvparser.DVModel)4 Logsig (org.gitia.froog.transferfunction.Logsig)4 Ignore (org.junit.Ignore)4