public static boolean isEventHappening(double probability) { return nextDouble() < probability; }
public double getDouble(long... coordinates) { return MathUtil.nextDouble(min, max); }
e0 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); t0 = System.nanoTime(); r = m.times(MathUtil.nextDouble()); t1 = System.nanoTime(); e1 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
double value = MathUtil.nextDouble(); m.setAsObject(value, random.nextInt(MATRIXSIZE), random.nextInt(MATRIXSIZE)); int writtenEntryCount = 0; while (System.currentTimeMillis() - t < MAXTIME * 1000 && writtenEntryCount < MAXENTRYCOUNT) { double value = MathUtil.nextDouble(); m.setAsObject(value, random.nextInt(MATRIXSIZE), random.nextInt(MATRIXSIZE)); writtenEntryCount++; double value = MathUtil.nextDouble(); m.setAsObject(value, random.nextInt(MATRIXSIZE), random.nextInt(MATRIXSIZE)); for (long r = 0; r < m.getRowCount(); r++) { for (long c = 0; r < m.getColumnCount(); c++) { double value = MathUtil.nextDouble(); m.setAsObject(value, r, c); writtenEntryCount++;
@Test public void testPlusScalarSmall() throws Exception { Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(11, 10); double ref2 = MathUtil.nextDouble(); Matrix ref3 = ref1.plus(Ret.LINK, true, ref2); for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) { Matrix m1 = getMatrix(mclass, ref1); Matrix m3 = m1.plus(ref2); Matrix delta = ref3.minus(m3); assertEquals(mclass.toString(), 0.0, delta.getRMS(), TOLERANCE); } }
@Test public void testMinusScalarSmall() throws Exception { Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(11, 10); double ref2 = MathUtil.nextDouble(); Matrix ref3 = ref1.minus(Ret.LINK, true, ref2); for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) { Matrix m1 = getMatrix(mclass, ref1); Matrix m3 = m1.minus(ref2); assertEquals(mclass.toString(), 0.0, ref3.minus(m3).getRMS(), TOLERANCE); } }
@Test public void testMinusScalarLarge() throws Exception { Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(101, 100); double ref2 = MathUtil.nextDouble(); Matrix ref3 = ref1.minus(Ret.LINK, true, ref2); for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) { Matrix m1 = getMatrix(mclass, ref1); Matrix m3 = m1.minus(ref2); assertEquals(mclass.toString(), 0.0, ref3.minus(m3).getRMS(), TOLERANCE); } }
@Test public void testTimesScalarLarge() throws Exception { Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(101, 100); double ref2 = MathUtil.nextDouble(); Matrix ref3 = ref1.times(Ret.LINK, true, ref2); for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) { Matrix m1 = getMatrix(mclass, ref1); Matrix m3 = m1.times(ref2); assertEquals(mclass.toString(), 0.0, ref3.minus(m3).getRMS(), TOLERANCE); } }
@Test public void testTimesScalarSmall() throws Exception { Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(11, 10); double ref2 = MathUtil.nextDouble(); Matrix ref3 = ref1.times(Ret.LINK, true, ref2); for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) { Matrix m1 = getMatrix(mclass, ref1); Matrix m3 = m1.times(ref2); assertEquals(mclass.toString(), 0.0, ref3.minus(m3).getRMS(), TOLERANCE); } }
@Test public void testPlusScalarLarge() throws Exception { Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(101, 100); double ref2 = MathUtil.nextDouble(); Matrix ref3 = ref1.plus(Ret.LINK, true, ref2); for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) { Matrix m1 = getMatrix(mclass, ref1); Matrix m3 = m1.plus(ref2); assertEquals(mclass.toString(), 0.0, ref3.minus(m3).getRMS(), TOLERANCE); } }
@Test public void testDivideScalarSmall() throws Exception { Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(11, 10); double ref2 = MathUtil.nextDouble(); Matrix ref3 = ref1.divide(Ret.LINK, true, ref2); for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) { Matrix m1 = getMatrix(mclass, ref1); Matrix m3 = m1.divide(ref2); assertEquals(mclass.toString(), 0.0, ref3.minus(m3).getRMS(), TOLERANCE); } }
@Test public void testDivideScalarLarge() throws Exception { Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(101, 100); double ref2 = MathUtil.nextDouble(); Matrix ref3 = ref1.divide(Ret.LINK, true, ref2); for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) { Matrix m1 = getMatrix(mclass, ref1); Matrix m3 = m1.divide(ref2); assertEquals(mclass.toString(), 0.0, ref3.minus(m3).getRMS(), TOLERANCE); } }