You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by sm...@apache.org on 2016/05/01 07:14:41 UTC
mahout git commit: MAHOUT-1841: Matrices.symmetricUniformView(...)
returning values in the wrong range
Repository: mahout
Updated Branches:
refs/heads/master 4105063d8 -> 1127661fd
MAHOUT-1841: Matrices.symmetricUniformView(...) returning values in the wrong range
Project: http://git-wip-us.apache.org/repos/asf/mahout/repo
Commit: http://git-wip-us.apache.org/repos/asf/mahout/commit/1127661f
Tree: http://git-wip-us.apache.org/repos/asf/mahout/tree/1127661f
Diff: http://git-wip-us.apache.org/repos/asf/mahout/diff/1127661f
Branch: refs/heads/master
Commit: 1127661fd96cac6d7584ba50b717bc67bda4aa43
Parents: 4105063
Author: smarthi <sm...@apache.org>
Authored: Sat Apr 30 21:16:37 2016 -0400
Committer: smarthi <sm...@apache.org>
Committed: Sat Apr 30 21:16:37 2016 -0400
----------------------------------------------------------------------
.../java/org/apache/mahout/math/Matrices.java | 30 +++++++++-----------
1 file changed, 14 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mahout/blob/1127661f/math/src/main/java/org/apache/mahout/math/Matrices.java
----------------------------------------------------------------------
diff --git a/math/src/main/java/org/apache/mahout/math/Matrices.java b/math/src/main/java/org/apache/mahout/math/Matrices.java
index fc45a16..aae3b79 100644
--- a/math/src/main/java/org/apache/mahout/math/Matrices.java
+++ b/math/src/main/java/org/apache/mahout/math/Matrices.java
@@ -19,7 +19,6 @@ package org.apache.mahout.math;
import com.google.common.base.Preconditions;
import org.apache.mahout.common.RandomUtils;
-import org.apache.mahout.math.flavor.TraversingStructureEnum;
import org.apache.mahout.math.function.DoubleFunction;
import org.apache.mahout.math.function.Functions;
import org.apache.mahout.math.function.IntIntFunction;
@@ -41,7 +40,7 @@ public final class Matrices {
* @param denseLike type of matrix returne dby {@link org.apache.mahout.math.Matrix#like()}.
* @return new matrix view.
*/
- public static final Matrix functionalMatrixView(final int rows,
+ public static Matrix functionalMatrixView(final int rows,
final int columns,
final IntIntFunction gf,
final boolean denseLike) {
@@ -52,7 +51,7 @@ public final class Matrices {
* Shorter form of {@link Matrices#functionalMatrixView(int, int,
* org.apache.mahout.math.function.IntIntFunction, boolean)}.
*/
- public static final Matrix functionalMatrixView(final int rows,
+ public static Matrix functionalMatrixView(final int rows,
final int columns,
final IntIntFunction gf) {
return new FunctionalMatrixView(rows, columns, gf);
@@ -64,7 +63,7 @@ public final class Matrices {
* @param m original matrix
* @return transposed view of original matrix
*/
- public static final Matrix transposedView(final Matrix m) {
+ public static Matrix transposedView(final Matrix m) {
Preconditions.checkArgument(!(m instanceof SparseColumnMatrix));
@@ -80,7 +79,7 @@ public final class Matrices {
*
* @param seed generator seed
*/
- public static final Matrix gaussianView(final int rows,
+ public static Matrix gaussianView(final int rows,
final int columns,
long seed) {
return functionalMatrixView(rows, columns, gaussianGenerator(seed), true);
@@ -92,7 +91,7 @@ public final class Matrices {
*
* @param seed generator seed
*/
- public static final Matrix symmetricUniformView(final int rows,
+ public static Matrix symmetricUniformView(final int rows,
final int columns,
int seed) {
return functionalMatrixView(rows, columns, uniformSymmetricGenerator(seed), true);
@@ -103,7 +102,7 @@ public final class Matrices {
*
* @param seed generator seed
*/
- public static final Matrix uniformView(final int rows,
+ public static Matrix uniformView(final int rows,
final int columns,
int seed) {
return functionalMatrixView(rows, columns, uniformGenerator(seed), true);
@@ -115,19 +114,18 @@ public final class Matrices {
* @param seed The seed for the matrix.
* @return Gaussian {@link IntIntFunction} generating matrix view with normal values
*/
- public static final IntIntFunction gaussianGenerator(final long seed) {
+ public static IntIntFunction gaussianGenerator(final long seed) {
final Random rnd = RandomUtils.getRandom(seed);
- IntIntFunction gaussianGF = new IntIntFunction() {
+ return new IntIntFunction() {
@Override
public double apply(int first, int second) {
- rnd.setSeed(seed ^ (((long) first << 32) | (second & 0xffffffffl)));
+ rnd.setSeed(seed ^ (((long) first << 32) | (second & 0xffffffffL)));
return rnd.nextGaussian();
}
};
- return gaussianGF;
}
- private static final double UNIFORM_DIVISOR = Math.pow(2.0, 64);
+ private static final double UNIFORM_DIVISOR = Math.pow(2.0, 63);
/**
* Uniform [-1,1) matrix generator function.
@@ -138,14 +136,14 @@ public final class Matrices {
* @param seed
* @return Uniform {@link IntIntFunction} generator
*/
- public static final IntIntFunction uniformSymmetricGenerator(final int seed) {
+ public static IntIntFunction uniformSymmetricGenerator(final int seed) {
return new IntIntFunction() {
private byte[] data = new byte[8];
@Override
public double apply(int row, int column) {
- long d = ((long) row << Integer.SIZE) | (column & 0xffffffffl);
- for (int i = 0; i < 8; i++, d >>>= 8) data[i] = (byte) d;
+ long d = ((long) row << Integer.SIZE) | (column & 0xffffffffL);
+ for (int i = 0; i < 8; i++, d >>>= 4) data[i] = (byte) d;
long hash = MurmurHash.hash64A(data, seed);
return hash / UNIFORM_DIVISOR;
}
@@ -157,7 +155,7 @@ public final class Matrices {
*
* @param seed generator seed
*/
- public static final IntIntFunction uniformGenerator(final int seed) {
+ public static IntIntFunction uniformGenerator(final int seed) {
return Functions.chain(new DoubleFunction() {
@Override
public double apply(double x) {