use of org.apache.commons.math3.linear.Array2DRowRealMatrix in project gatk-protected by broadinstitute.
the class GATKProtectedMathUtilsTest method testColumnNaN.
@Test
public void testColumnNaN() {
final double[][] array = { { 1, 2, Double.NaN }, { 5, 5, 5 }, { 7, 8, 9 }, { -15, 2, 12 } };
final double[] guess = GATKProtectedMathUtils.columnSums(new Array2DRowRealMatrix(array));
final double[] gt = { -2, 17, Double.NaN };
Assert.assertEquals(guess.length, 3);
Assert.assertEquals(guess[0], gt[0]);
Assert.assertEquals(guess[1], gt[1]);
Assert.assertTrue(Double.isNaN(guess[2]));
}
use of org.apache.commons.math3.linear.Array2DRowRealMatrix in project gatk-protected by broadinstitute.
the class GATKProtectedMathUtilsTest method testRowVariances.
@Test
public void testRowVariances() {
final double[][] array = { { 1, 2, 3 }, { 5, 5, 5 }, { 7, 8, 9 } };
final double[] rowVariances = GATKProtectedMathUtils.rowVariances(new Array2DRowRealMatrix(array));
Assert.assertEquals(rowVariances[0], 1, 1e-8);
Assert.assertEquals(rowVariances[1], 0, 1e-8);
Assert.assertEquals(rowVariances[2], 1, 1e-8);
}
use of org.apache.commons.math3.linear.Array2DRowRealMatrix in project gatk-protected by broadinstitute.
the class HDF5LibraryUnitTest method createMatrixOfGaussianValues.
private RealMatrix createMatrixOfGaussianValues(int numRows, int numCols, final double mean, final double sigma) {
final RealMatrix bigCounts = new Array2DRowRealMatrix(numRows, numCols);
final RandomDataGenerator randomDataGenerator = new RandomDataGenerator();
randomDataGenerator.reSeed(337337337);
bigCounts.walkInOptimizedOrder(new DefaultRealMatrixChangingVisitor() {
@Override
public double visit(int row, int column, double value) {
return randomDataGenerator.nextGaussian(mean, sigma);
}
});
return bigCounts;
}
use of org.apache.commons.math3.linear.Array2DRowRealMatrix in project gatk-protected by broadinstitute.
the class GATKProtectedMathUtilsTest method testColumnNegInf.
@Test
public void testColumnNegInf() {
final double[][] array = { { 1, 2, Double.NEGATIVE_INFINITY }, { 5, 5, 5 }, { 7, 8, 9 }, { -15, 2, 12 } };
final double[] guess = GATKProtectedMathUtils.columnSums(new Array2DRowRealMatrix(array));
final double[] gt = { -2, 17, Double.NEGATIVE_INFINITY };
Assert.assertEquals(guess.length, 3);
Assert.assertEquals(guess[0], gt[0]);
Assert.assertEquals(guess[1], gt[1]);
Assert.assertTrue(Double.isInfinite(guess[2]));
}
use of org.apache.commons.math3.linear.Array2DRowRealMatrix in project gatk-protected by broadinstitute.
the class GATKProtectedMathUtilsTest method testColumnSum.
@Test
public void testColumnSum() {
final double[][] array = { { 1, 2, 3 }, { 5, 5, 5 }, { 7, 8, 9 }, { -15, 2, 12 } };
final double[] guess = GATKProtectedMathUtils.columnSums(new Array2DRowRealMatrix(array));
final double[] gt = { -2, 17, 29 };
Assert.assertEquals(guess.length, 3);
Assert.assertEquals(guess, gt);
}
Aggregations