diff --git a/ROADMAP b/ROADMAP index a07f0246..1fde85c9 100644 --- a/ROADMAP +++ b/ROADMAP @@ -1,3 +1,14 @@ +Roadmap to jblas 1.2.1 + +1. Linux / 32 bit / sse2 +2. Linux / 32 bit / sse3 +3. Linux / 64 bit / sse2 +4. Linux / 64 bit / sse3 +5. Mac OS X / 64 bit / sse3 +6. Windows / 32 bit / sse2 +7. Windows / 32 bit / sse3 +8. Windows / 64 bit / lapack lite only + Roadmap to jblas-0.3.1 - collect static builds for Windows(32), Linux(32/64), MacOSX(32/64). diff --git a/jblas.iml b/jblas.iml new file mode 100644 index 00000000..c85beeef --- /dev/null +++ b/jblas.iml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/src/main/java/org/jblas/DoubleMatrix.java b/src/main/java/org/jblas/DoubleMatrix.java index 0109047b..69a33508 100644 --- a/src/main/java/org/jblas/DoubleMatrix.java +++ b/src/main/java/org/jblas/DoubleMatrix.java @@ -39,6 +39,8 @@ import org.jblas.exceptions.SizeException; import org.jblas.ranges.Range; +import org.jblas.util.Random; + import java.io.BufferedReader; import java.io.DataInputStream; import java.io.DataOutputStream; @@ -436,9 +438,8 @@ private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundEx public static DoubleMatrix rand(int rows, int columns) { DoubleMatrix m = new DoubleMatrix(rows, columns); - java.util.Random r = new java.util.Random(); for (int i = 0; i < rows * columns; i++) { - m.data[i] = r.nextDouble(); + m.data[i] = (double) Random.nextDouble(); } return m; @@ -453,9 +454,8 @@ public static DoubleMatrix rand(int len) { public static DoubleMatrix randn(int rows, int columns) { DoubleMatrix m = new DoubleMatrix(rows, columns); - java.util.Random r = new java.util.Random(); for (int i = 0; i < rows * columns; i++) { - m.data[i] = (double) r.nextGaussian(); + m.data[i] = (double) Random.nextGaussian(); } return m; @@ -904,6 +904,7 @@ public DoubleMatrix put(Range rs, Range cs, DoubleMatrix x) { x.checkColumns(cs.length()); for (; rs.hasMore(); rs.next()) { + cs.init(0, columns); for (; cs.hasMore(); cs.next()) { put(rs.value(), cs.value(), x.get(rs.index(), cs.index())); } diff --git a/src/main/java/org/jblas/FloatMatrix.java b/src/main/java/org/jblas/FloatMatrix.java index 1251a39d..c05efbea 100644 --- a/src/main/java/org/jblas/FloatMatrix.java +++ b/src/main/java/org/jblas/FloatMatrix.java @@ -39,6 +39,8 @@ import org.jblas.exceptions.SizeException; import org.jblas.ranges.Range; +import org.jblas.util.Random; + import java.io.BufferedReader; import java.io.DataInputStream; import java.io.DataOutputStream; @@ -436,9 +438,8 @@ private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundEx public static FloatMatrix rand(int rows, int columns) { FloatMatrix m = new FloatMatrix(rows, columns); - java.util.Random r = new java.util.Random(); for (int i = 0; i < rows * columns; i++) { - m.data[i] = r.nextFloat(); + m.data[i] = (float) Random.nextFloat(); } return m; @@ -453,9 +454,8 @@ public static FloatMatrix rand(int len) { public static FloatMatrix randn(int rows, int columns) { FloatMatrix m = new FloatMatrix(rows, columns); - java.util.Random r = new java.util.Random(); for (int i = 0; i < rows * columns; i++) { - m.data[i] = (float) r.nextGaussian(); + m.data[i] = (float) Random.nextGaussian(); } return m; @@ -904,6 +904,7 @@ public FloatMatrix put(Range rs, Range cs, FloatMatrix x) { x.checkColumns(cs.length()); for (; rs.hasMore(); rs.next()) { + cs.init(0, columns); for (; cs.hasMore(); cs.next()) { put(rs.value(), cs.value(), x.get(rs.index(), cs.index())); } diff --git a/src/main/java/org/jblas/util/Random.java b/src/main/java/org/jblas/util/Random.java new file mode 100644 index 00000000..bb1d1d2e --- /dev/null +++ b/src/main/java/org/jblas/util/Random.java @@ -0,0 +1,33 @@ +package org.jblas.util; + +/** + * Created by IntelliJ IDEA. + * User: mikio + * Date: 6/24/11 + * Time: 10:45 AM + * To change this template use File | Settings | File Templates. + */ + +public class Random { + private static java.util.Random r = new java.util.Random(); + + public static void seed(long newSeed) { + r = new java.util.Random(newSeed); + } + + public static double nextDouble() { + return r.nextDouble(); + } + + public static float nextFloat() { + return r.nextFloat(); + } + + public static int nextInt(int max) { + return r.nextInt(max); + } + + public static double nextGaussian() { + return r.nextGaussian(); + } +} diff --git a/src/test/java/org/jblas/TestDoubleMatrix.java b/src/test/java/org/jblas/TestDoubleMatrix.java index b3f5a498..e0bb6029 100644 --- a/src/test/java/org/jblas/TestDoubleMatrix.java +++ b/src/test/java/org/jblas/TestDoubleMatrix.java @@ -39,6 +39,8 @@ import java.io.File; import java.io.PrintStream; import junit.framework.TestCase; +import org.jblas.util.Random; + import java.util.Arrays; import static org.jblas.ranges.RangeUtils.*; @@ -640,8 +642,24 @@ public void testLoadAsciiFile() { } public void testRanges() { - // Hm... Broken? - //System.out.printf("Ranges: %s\n", A.get(interval(0, 2), interval(0, 1)).toString()); - //assertEquals(new DoubleMatrix(3, 2, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0), ); + DoubleMatrix A = new DoubleMatrix(3, 3, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0); + DoubleMatrix B = new DoubleMatrix(2, 3, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0); + + A.put(interval(0, 2), interval(0, 3), B); + + /*assertEquals(-1.0, A.get(0, 0)); + assertEquals(-2.0, A.get(0, 1)); + assertEquals(-3.0, A.get(0, 2)); + assertEquals(-4.0, A.get(1, 0)); + assertEquals(-5.0, A.get(1, 1)); + assertEquals(-6.0, A.get(1, 2));*/ + } + + public void testRandWithSeed() { + Random.seed(1); + DoubleMatrix A = DoubleMatrix.rand(3, 3); + Random.seed(1); + DoubleMatrix B = DoubleMatrix.rand(3, 3); + assertEquals(0.0, A.sub(B).normmax(), 1e-9); } } diff --git a/src/test/java/org/jblas/TestFloatMatrix.java b/src/test/java/org/jblas/TestFloatMatrix.java index c669188d..2cb7c66d 100644 --- a/src/test/java/org/jblas/TestFloatMatrix.java +++ b/src/test/java/org/jblas/TestFloatMatrix.java @@ -39,6 +39,8 @@ import java.io.File; import java.io.PrintStream; import junit.framework.TestCase; +import org.jblas.util.Random; + import java.util.Arrays; import static org.jblas.ranges.RangeUtils.*; @@ -640,8 +642,24 @@ public void testLoadAsciiFile() { } public void testRanges() { - // Hm... Broken? - //System.out.printf("Ranges: %s\n", A.get(interval(0, 2), interval(0, 1)).toString()); - //assertEquals(new FloatMatrix(3, 2, 1.0f, 2.0f, 3.0f, 5.0f, 6.0f, 7.0f), ); + FloatMatrix A = new FloatMatrix(3, 3, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f); + FloatMatrix B = new FloatMatrix(2, 3, -1.0f, -2.0f, -3.0f, -4.0f, -5.0f, -6.0f); + + A.put(interval(0, 2), interval(0, 3), B); + + /*assertEquals(-1.0f, A.get(0, 0)); + assertEquals(-2.0f, A.get(0, 1)); + assertEquals(-3.0f, A.get(0, 2)); + assertEquals(-4.0f, A.get(1, 0)); + assertEquals(-5.0f, A.get(1, 1)); + assertEquals(-6.0f, A.get(1, 2));*/ + } + + public void testRandWithSeed() { + Random.seed(1); + FloatMatrix A = FloatMatrix.rand(3, 3); + Random.seed(1); + FloatMatrix B = FloatMatrix.rand(3, 3); + assertEquals(0.0f, A.sub(B).normmax(), 1e-9); } }