ichbinstudent commented on code in PR #2186:
URL: https://github.com/apache/systemds/pull/2186#discussion_r1929771516
##########
src/test/java/org/apache/sysds/test/component/matrix/LibMatrixDatagenTest.java:
##########
@@ -0,0 +1,94 @@
+package org.apache.sysds.test.component.matrix;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.math3.random.Well1024a;
+import org.apache.sysds.runtime.matrix.data.LibMatrixDatagen;
+import org.apache.sysds.runtime.matrix.data.MatrixBlock;
+import org.apache.sysds.runtime.matrix.data.RandomMatrixGenerator;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+import static org.junit.Assert.*;
+
+public class LibMatrixDatagenTest {
+ protected static final Log LOG =
LogFactory.getLog(LibMatrixDatagenTest.class.getName());
+
+ @Test
+ public void testGenerateUniformMatrixPhilox() {
+ MatrixBlock mb = new MatrixBlock();
+ RandomMatrixGenerator rgen = new
RandomMatrixGenerator(RandomMatrixGenerator.PDF.CB_UNIFORM, 10, 10, 10, 1, 0.,
1.);
+ LibMatrixDatagen.generateRandomMatrix(mb, rgen, null, 0L);
+ for(int i = 0; i < 10; i++) {
+ for(int j = 0; j < 10; j++) {
+ assertTrue("Value: " + mb.get(i, j) + "needs to
be less than 1", mb.get(i, j) < 1);
+ assertTrue("Value: " + mb.get(i, j) + "needs to
be greater than 0", mb.get(i, j) > 0);
+ }
+ }
+ }
+
+ @Test
+ public void testGenerateNormalMatrixPhilox() {
+ MatrixBlock mb = new MatrixBlock();
+ RandomMatrixGenerator rgen = new
RandomMatrixGenerator(RandomMatrixGenerator.PDF.CB_NORMAL, 1000, 1000, 1000 *
1000, 1);
+ LibMatrixDatagen.generateRandomMatrix(mb, rgen, null,
123123123123L);
+ double mean = mb.mean();
+ double[] bv = mb.getDenseBlockValues();
+ double variance = Arrays.stream(bv).map(x -> Math.pow(x - mean,
2)).sum() / bv.length;
+ assertEquals("Mean should be 0", 0, mean, 0.01);
+ assertEquals("Variance should be 1", 1, variance, 0.001);
+ }
+
+ @Test
+ @Ignore
Review Comment:
They were just for testing the performance. Shouldn't have been included in
the PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]