Search in sources :

Example 41 with DMatrixRMaj

use of org.ejml.data.DMatrixRMaj in project narchy by automenta.

the class PrincipalComponentAnalysis method getBasisVector.

/**
 * Returns a vector from the PCA's basis.
 *
 * @param which Which component's vector is to be returned.
 * @return Vector from the PCA basis.
 */
public double[] getBasisVector(int which) {
    if (which < 0 || which >= numComponents)
        throw new IllegalArgumentException("Invalid component");
    DMatrixRMaj v = new DMatrixRMaj(1, A.numCols);
    extract(V_t, which, which + 1, 0, A.numCols, v, 0, 0);
    return v.data;
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj)

Example 42 with DMatrixRMaj

use of org.ejml.data.DMatrixRMaj in project narchy by automenta.

the class PrincipalComponentAnalysis method response.

/**
 * Computes the dot product of each basis vector against the sample.  Can be used as a measure
 * for membership in the training sample set.  High values correspond to a better fit.
 *
 * @param sample Sample of original data.
 * @return Higher value indicates it is more likely to be a member of input dataset.
 */
public double response(double[] sample) {
    if (sample.length != A.numCols)
        throw new IllegalArgumentException("Expected input vector to be in sample space");
    DMatrixRMaj dots = new DMatrixRMaj(numComponents, 1);
    DMatrixRMaj s = DMatrixRMaj.wrap(A.numCols, 1, sample);
    mult(V_t, s, dots);
    return NormOps_DDRM.normF(dots);
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj)

Example 43 with DMatrixRMaj

use of org.ejml.data.DMatrixRMaj in project narchy by automenta.

the class EjmlOps method fillWithRow.

public static DMatrixRMaj fillWithRow(DMatrixRMaj matrix, int setrow) {
    int rows = matrix.numRows;
    int cols = matrix.numCols;
    DMatrixRMaj result = new DMatrixRMaj(rows, cols);
    for (int row = 0; row < rows; row++) {
        for (int col = 0; col < cols; col++) {
            result.set(row, col, matrix.get(setrow, col));
        }
    }
    return result;
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj)

Example 44 with DMatrixRMaj

use of org.ejml.data.DMatrixRMaj in project narchy by automenta.

the class EJMLVsPython method testAssignCol.

@Test
public void testAssignCol() throws IOException {
    double[][] Xin = MatrixUtils.simpleRead2DMatrix(new StringReader(s), " ");
    DMatrixRMaj X = new DMatrixRMaj(Xin);
    DMatrixRMaj sumR = new DMatrixRMaj(1, X.numCols);
    sumCols(X, sumR);
    double[][] pyasgn = { { 1., 2., 3., 4., 5. }, { 6., 7., 8., 9., 5. }, { 3., 4., 2., 7., 3. }, { 30., 30., 38., 42., 32. }, { 2., 4., 7., 8., 9. }, { 3., 4., 3., 3., 5. }, { 8., 6., 9., 4., 2. } };
    insert(sumR, X, 3, 0);
    assertEqualDoubleArrays(pyasgn, EjmlOps.extractDoubleArray(X), epsilon);
}
Also used : StringReader(java.io.StringReader) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.jupiter.api.Test)

Example 45 with DMatrixRMaj

use of org.ejml.data.DMatrixRMaj in project narchy by automenta.

the class EJMLVsPython method testScaleTimes.

@Test
public void testScaleTimes() throws IOException {
    double[][] Xin = MatrixUtils.simpleRead2DMatrix(new StringReader(s), " ");
    DMatrixRMaj X = new DMatrixRMaj(Xin);
    double[][] pyscle = { { -2., -4., -6., -8., -10. }, { -12., -14., -16., -18., -10. }, { -6., -8., -4., -14., -6. }, { -14., -6., -12., -14., -6. }, { -4., -8., -14., -16., -18. }, { -6., -8., -6., -6., -10. }, { -16., -12., -18., -8., -4. } };
    scale(-2.0, X);
    double[][] scale = EjmlOps.extractDoubleArray(X);
    assertEqualDoubleArrays(pyscle, scale, epsilon);
}
Also used : StringReader(java.io.StringReader) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.jupiter.api.Test)

Aggregations

DMatrixRMaj (org.ejml.data.DMatrixRMaj)454 Test (org.junit.jupiter.api.Test)210 Se3_F64 (georegression.struct.se.Se3_F64)107 Point2D_F64 (georegression.struct.point.Point2D_F64)87 Point3D_F64 (georegression.struct.point.Point3D_F64)68 ArrayList (java.util.ArrayList)55 Vector3D_F64 (georegression.struct.point.Vector3D_F64)54 AssociatedPair (boofcv.struct.geo.AssociatedPair)38 CameraPinhole (boofcv.struct.calib.CameraPinhole)32 Equation (org.ejml.equation.Equation)29 UtilPoint3D_F64 (georegression.geometry.UtilPoint3D_F64)25 Point4D_F64 (georegression.struct.point.Point4D_F64)19 StringReader (java.io.StringReader)16 Test (org.junit.Test)15 AssociatedTriple (boofcv.struct.geo.AssociatedTriple)12 TrifocalTensor (boofcv.struct.geo.TrifocalTensor)11 RectifyCalibrated (boofcv.alg.geo.rectify.RectifyCalibrated)10 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)10 BufferedImage (java.awt.image.BufferedImage)10 SceneStructureProjective (boofcv.abst.geo.bundle.SceneStructureProjective)9