Search in sources :

Example 76 with Array2DRowRealMatrix

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]));
}
Also used : Array2DRowRealMatrix(org.apache.commons.math3.linear.Array2DRowRealMatrix) Test(org.testng.annotations.Test)

Example 77 with Array2DRowRealMatrix

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);
}
Also used : Array2DRowRealMatrix(org.apache.commons.math3.linear.Array2DRowRealMatrix) Test(org.testng.annotations.Test)

Example 78 with Array2DRowRealMatrix

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;
}
Also used : Array2DRowRealMatrix(org.apache.commons.math3.linear.Array2DRowRealMatrix) RealMatrix(org.apache.commons.math3.linear.RealMatrix) Array2DRowRealMatrix(org.apache.commons.math3.linear.Array2DRowRealMatrix) RandomDataGenerator(org.apache.commons.math3.random.RandomDataGenerator) DefaultRealMatrixChangingVisitor(org.apache.commons.math3.linear.DefaultRealMatrixChangingVisitor)

Example 79 with Array2DRowRealMatrix

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]));
}
Also used : Array2DRowRealMatrix(org.apache.commons.math3.linear.Array2DRowRealMatrix) Test(org.testng.annotations.Test)

Example 80 with Array2DRowRealMatrix

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);
}
Also used : Array2DRowRealMatrix(org.apache.commons.math3.linear.Array2DRowRealMatrix) Test(org.testng.annotations.Test)

Aggregations

Array2DRowRealMatrix (org.apache.commons.math3.linear.Array2DRowRealMatrix)141 RealMatrix (org.apache.commons.math3.linear.RealMatrix)101 Test (org.testng.annotations.Test)60 IntStream (java.util.stream.IntStream)31 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)28 File (java.io.File)27 Collectors (java.util.stream.Collectors)25 ArrayList (java.util.ArrayList)24 Assert (org.testng.Assert)24 List (java.util.List)22 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)22 Target (org.broadinstitute.hellbender.tools.exome.Target)18 java.util (java.util)15 Random (java.util.Random)14 ReadCountCollection (org.broadinstitute.hellbender.tools.exome.ReadCountCollection)14 ParamUtils (org.broadinstitute.hellbender.utils.param.ParamUtils)14 DataProvider (org.testng.annotations.DataProvider)14 Stream (java.util.stream.Stream)13 Arrays (java.util.Arrays)12 DoubleStream (java.util.stream.DoubleStream)12