You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/04/26 13:25:13 UTC
[02/50] [abbrv] ignite git commit: IGNITE-5018 review and improve
javadocs in ML module
IGNITE-5018 review and improve javadocs in ML module
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/33079fc9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/33079fc9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/33079fc9
Branch: refs/heads/master
Commit: 33079fc9c6fb6970ff24e88466e5edbf41ff1a28
Parents: 1968e4f
Author: Oleg Ignatenko <oi...@gridgain.com>
Authored: Mon Apr 24 13:18:40 2017 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Apr 24 13:18:40 2017 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/ml/math/Algebra.java | 89 +++++++++-------
.../ignite/ml/math/IdentityValueMapper.java | 3 +-
.../java/org/apache/ignite/ml/math/Matrix.java | 33 +++---
.../org/apache/ignite/ml/math/MurmurHash.java | 16 +--
.../java/org/apache/ignite/ml/math/Tracer.java | 4 +-
.../java/org/apache/ignite/ml/math/Vector.java | 3 +-
.../decompositions/CholeskyDecomposition.java | 8 +-
.../math/decompositions/EigenDecomposition.java | 4 +-
.../ml/math/decompositions/LUDecomposition.java | 8 +-
.../ignite/ml/math/functions/Functions.java | 21 +++-
.../ml/math/impls/matrix/PivotedMatrixView.java | 3 +-
.../impls/matrix/SparseDistributedMatrix.java | 12 +--
.../storage/matrix/CacheMatrixStorage.java | 16 ++-
.../matrix/DenseOffHeapMatrixStorage.java | 15 ++-
.../storage/matrix/FunctionMatrixStorage.java | 17 +--
.../matrix/SparseLocalOnHeapMatrixStorage.java | 20 ++--
.../storage/vector/CacheVectorStorage.java | 13 +--
.../storage/vector/ConstantVectorStorage.java | 10 +-
.../storage/vector/DelegateVectorStorage.java | 1 +
.../storage/vector/FunctionVectorStorage.java | 17 +--
.../storage/vector/MatrixVectorStorage.java | 19 ++--
.../storage/vector/PivotedVectorStorage.java | 16 +--
.../SingleElementVectorDelegateStorage.java | 13 +--
.../vector/SingleElementVectorStorage.java | 11 +-
.../vector/SparseLocalOffHeapVectorStorage.java | 3 +
.../vector/SparseLocalOnHeapVectorStorage.java | 11 +-
.../ml/math/impls/vector/AbstractVector.java | 1 +
.../ml/math/impls/vector/DelegatingVector.java | 1 +
.../ml/math/impls/vector/MatrixVectorView.java | 20 ++--
.../ml/math/impls/vector/PivotedVectorView.java | 14 +--
.../ml/math/impls/vector/RandomVector.java | 4 +-
.../math/impls/vector/SingleElementVector.java | 103 +------------------
.../org/apache/ignite/ml/math/TracerTest.java | 12 ++-
.../ml/math/impls/matrix/CacheMatrixTest.java | 10 +-
.../impls/matrix/MatrixKeyMapperForTests.java | 19 ++--
.../storage/matrix/MatrixStorageFixtures.java | 19 ++--
.../SparseLocalOffHeapVectorStorageTest.java | 3 +-
.../math/impls/vector/AbstractVectorTest.java | 42 ++++----
.../ml/math/impls/vector/CacheVectorTest.java | 5 +-
39 files changed, 331 insertions(+), 308 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java
index b13d9fc..c54e390 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java
@@ -31,7 +31,8 @@ package org.apache.ignite.ml.math;
* Lifted from Apache Mahout.
*/
public class Algebra extends Constants {
- /** */ private static final double[] STIRLING_CORRECTION = {
+ /** */
+ private static final double[] STIRLING_CORRECTION = {
0.0,
8.106146679532726e-02, 4.134069595540929e-02,
2.767792568499834e-02, 2.079067210376509e-02,
@@ -50,7 +51,8 @@ public class Algebra extends Constants {
2.873449362352470e-03, 2.777674929752690e-03,
};
- /** */ private static final double[] LOG_FACTORIALS = {
+ /** */
+ private static final double[] LOG_FACTORIALS = {
0.00000000000000000, 0.00000000000000000, 0.69314718055994531,
1.79175946922805500, 3.17805383034794562, 4.78749174278204599,
6.57925121201010100, 8.52516136106541430, 10.60460290274525023,
@@ -63,7 +65,8 @@ public class Algebra extends Constants {
64.55753862700633106, 67.88974313718153498, 71.25703896716800901
};
- /** */ private static final long[] LONG_FACTORIALS = {
+ /** */
+ private static final long[] LONG_FACTORIALS = {
1L,
1L,
2L,
@@ -87,7 +90,8 @@ public class Algebra extends Constants {
2432902008176640000L
};
- /** */ private static final double[] DOUBLE_FACTORIALS = {
+ /** */
+ private static final double[] DOUBLE_FACTORIALS = {
5.109094217170944E19,
1.1240007277776077E21,
2.585201673888498E22,
@@ -337,19 +341,27 @@ public class Algebra extends Constants {
/**
* Evaluates the series of Chebyshev polynomials Ti at argument x/2. The series is given by
- * <pre>
- * N-1
- * - '
- * y = > coef[i] T (x/2)
- * - i
- * i=0
+ * <pre class="snippet">
+ * N-1
+ * - '
+ * y = > coef[i] T (x/2)
+ * - i
+ * i=0
* </pre>
* Coefficients are stored in reverse order, i.e. the zero order term is last in the array. Note N is the number of
- * coefficients, not the order. <p> If coefficients are for the interval a to b, x must have been transformed to x
+ * coefficients, not the order.
+ * <p>
+ * If coefficients are for the interval a to b, x must have been transformed to x
* -< 2(2x - b - a)/(b-a) before entering the routine. This maps x from (a, b) to (-1, 1), over which the
- * Chebyshev polynomials are defined. <p> If the coefficients are for the inverted interval, in which (a, b) is
+ * Chebyshev polynomials are defined.</p>
+ * <p>
+ * If the coefficients are for the inverted interval, in which (a, b) is
* mapped to (1/b, 1/a), the transformation required is {@code x -> 2(2ab/x - b - a)/(b-a)}. If b is infinity, this
- * becomes {@code x -> 4a/x - 1}. <p> SPEED: <p> Taking advantage of the recurrence properties of the Chebyshev
+ * becomes {@code x -> 4a/x - 1}.</p>
+ * <p>
+ * SPEED:
+ * </p>
+ * Taking advantage of the recurrence properties of the Chebyshev
* polynomials, the routine requires one more addition per loop than evaluating a nested polynomial of the same
* degree.
*
@@ -466,11 +478,11 @@ public class Algebra extends Constants {
/**
* Returns the StirlingCorrection.
- *
+ * <p>
* Correction term of the Stirling approximation for {@code log(k!)} (series in
- * 1/k, or table values for small k) with int parameter k. </p> {@code log k! = (k + 1/2)log(k + 1) - (k + 1) +
+ * 1/k, or table values for small k) with int parameter k. {@code log k! = (k + 1/2)log(k + 1) - (k + 1) +
* (1/2)log(2Pi) + STIRLING_CORRECTION(k + 1) log k! = (k + 1/2)log(k) - k + (1/2)log(2Pi) +
- * STIRLING_CORRECTION(k) }
+ * STIRLING_CORRECTION(k) } </p>
*/
public static double stirlingCorrection(int k) {
if (k > 30) {
@@ -490,21 +502,24 @@ public class Algebra extends Constants {
/**
* Evaluates the given polynomial of degree {@code N} at {@code x}, assuming coefficient of N is 1.0. Otherwise same
* as {@link #evalPoly(double, double[], int)}.
- * <pre>
- * 2 N
+ * <pre class="snippet">
+ * 2 N
* y = C + C x + C x +...+ C x
- * 0 1 2 N
- *
- * where C = 1 and hence is omitted from the array.
- * N
- *
- * Coefficients are stored in reverse order:
- *
+ * 0 1 2 N
+ * </pre>
+ * where <pre class="snippet">
+ * C = 1
+ * N
+ * </pre>
+ * and hence is omitted from the array.
+ * <p>
+ * Coefficients are stored in reverse order:</p>
+ * <pre class="snippet">
* coef[0] = C , ..., coef[N-1] = C .
- * N-1 0
- *
- * Calling arguments are otherwise the same as {@link #evalPoly(double, double[], int)}.
+ * N-1 0
* </pre>
+ * Calling arguments are otherwise the same as {@link #evalPoly(double, double[], int)}.
+ * <p>
* In the interest of speed, there are no checks for out of bounds arithmetic.
*
* @param x Argument to the polynomial.
@@ -522,17 +537,19 @@ public class Algebra extends Constants {
/**
* Evaluates the given polynomial of degree {@code N} at {@code x}.
- * <pre>
- * 2 N
+ * <pre class="snippet">
+ * 2 N
* y = C + C x + C x +...+ C x
- * 0 1 2 N
- *
- * Coefficients are stored in reverse order:
- *
+ * 0 1 2 N
+ * </pre>
+ * <p>
+ * Coefficients are stored in reverse order:</p>
+ * <pre class="snippet">
* coef[0] = C , ..., coef[N] = C .
- * N 0
+ * N 0
* </pre>
- * In the interest of speed, there are no checks for out of bounds arithmetic.
+ * <p>
+ * In the interest of speed, there are no checks for out of bounds arithmetic.</p>
*
* @param x Argument to the polynomial.
* @param coef Coefficients of the polynomial.
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java
index 00bf915..3c94edd 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java
@@ -21,7 +21,8 @@ package org.apache.ignite.ml.math;
* Identity value mapper.
*/
public class IdentityValueMapper implements ValueMapper<Double> {
- /** */ private static final long serialVersionUID = -8010078306142216389L;
+ /** */
+ private static final long serialVersionUID = -8010078306142216389L;
/** {@inheritDoc} */
@Override public Double fromDouble(double v) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
index cc858b7..798d831 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
@@ -18,6 +18,7 @@
package org.apache.ignite.ml.math;
import java.io.Externalizable;
+
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.ml.math.exceptions.CardinalityException;
import org.apache.ignite.ml.math.exceptions.IndexException;
@@ -29,17 +30,17 @@ import org.apache.ignite.ml.math.functions.IntIntToDoubleFunction;
/**
* A matrix interface.
- *
+ * <p>
* Based on its flavor it can have vastly different implementations tailored for
* for different types of data (e.g. dense vs. sparse), different sizes of data or different operation
- * optimizations.
- *
+ * optimizations.</p>
+ * <p>
* Note also that not all operations can be supported by all underlying implementations. If an operation is not
* supported a {@link UnsupportedOperationException} is thrown. This exception can also be thrown in partial cases
* where an operation is unsupported only in special cases, e.g. where a given operation cannot be deterministically
- * completed in polynomial time.
- *
- * Based on ideas from <a href="http://mahout.apache.org/">Apache Mahout</a>.
+ * completed in polynomial time.</p>
+ * <p>
+ * Based on ideas from <a href="http://mahout.apache.org/">Apache Mahout</a>.</p>
*/
public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetrics, Destroyable {
/**
@@ -174,10 +175,10 @@ public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetric
/**
* Maps all values in this matrix through a given function.
- *
- * For this matrix <code>A</code>, argument matrix <code>B</code> and the
- * function <code>F</code> this method maps every cell <code>x, y</code> as:
- * <code>A(x,y) = fun(A(x,y), B(x,y))</code>
+ * <p>
+ * For this matrix {@code A}, argument matrix {@code B} and the
+ * function {@code F} this method maps every cell {@code x, y} as:
+ * {@code A(x,y) = fun(A(x,y), B(x,y))}.</p>
*
* @param mtx Argument matrix.
* @param fun Mapping function.
@@ -306,8 +307,8 @@ public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetric
/**
* Clones this matrix.
- *
- * NOTE: new matrix will have the same flavor as the this matrix but a different ID.
+ * <p>
+ * NOTE: new matrix will have the same flavor as the this matrix but a different ID.</p>
*
* @return New matrix of the same underlying class, the same size and the same values.
*/
@@ -315,8 +316,8 @@ public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetric
/**
* Creates new empty matrix of the same underlying class but of different size.
- *
- * NOTE: new matrix will have the same flavor as the this matrix but a different ID.
+ * <p>
+ * NOTE: new matrix will have the same flavor as the this matrix but a different ID.</p>
*
* @param rows Number of rows for new matrix.
* @param cols Number of columns for new matrix.
@@ -463,8 +464,8 @@ public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetric
/**
* Creates new view into this matrix. Changes to the view will be propagated to this matrix.
*
- * @param off View offset as <code>int[x,y]</code>.
- * @param size View size as <code>int[rows, cols]</code>
+ * @param off View offset as {@code int[x,y]}.
+ * @param size View size as {@code int[rows, cols]}.
* @return New view.
* @throws CardinalityException Thrown if cardinalities mismatch.
* @throws IndexException Thrown in case of offset is out of bound.
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java
index c7dd36b..d1ebf53 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java
@@ -22,8 +22,8 @@ import java.nio.ByteOrder;
/**
* This is a very fast, non-cryptographic hash suitable for general hash-based lookup.
- *
- * See http://murmurhash.googlepages.com/ for mre details.
+ * <p>
+ * See http://murmurhash.googlepages.com/ for mre details.</p>
*/
public class MurmurHash {
/** Hide it. */
@@ -33,13 +33,13 @@ public class MurmurHash {
/**
* This produces exactly the same hash values as the final C+ version of MurmurHash3 and is
* thus suitable for producing the same hash values across platforms.
- *
- * The 32 bit x86 version of this hash should be the fastest variant for relatively short keys like IDs.
- *
+ * <p>
+ * The 32 bit x86 version of this hash should be the fastest variant for relatively short keys like IDs.</p>
+ * <p>
* Note - The x86 and x64 versions do _not_ produce the same results, as the algorithms are
- * optimized for their respective platforms.
- *
- * See also http://github.com/yonik/java_util for future updates to this method.
+ * optimized for their respective platforms.</p>
+ * <p>
+ * See also http://github.com/yonik/java_util for future updates to this method.</p>
*
* @param data Data to hash.
* @param off Where to start munging.
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
index 007a8fe..07cc63c 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
@@ -71,8 +71,10 @@ public class Tracer {
return defaultColorMapper(vec.minValue(), vec.maxValue());
}
- /** Default matrix color mapper implementation that map given double value
+ /**
+ * Default matrix color mapper implementation that map given double value
* to continuous red-blue (R_B) specter.
+ *
* @param mtx Matrix to be mapped.
* @return Color mapper for given matrix.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java
index b5e1d69..e1c5df0 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java
@@ -470,7 +470,8 @@ public interface Vector extends MetaAttributes, Externalizable, StorageOpsMetric
* @return Folded value of these vectors.
* @throws CardinalityException Thrown when cardinalities mismatch.
*/
- public <T> T foldMap(Vector vec, IgniteBiFunction<T, Double, T> foldFun, IgniteBiFunction<Double, Double, Double> combFun,
+ public <T> T foldMap(Vector vec, IgniteBiFunction<T, Double, T> foldFun,
+ IgniteBiFunction<Double, Double, Double> combFun,
T zeroVal);
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java
index 59ebbe0..6053e1c 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java
@@ -25,8 +25,8 @@ import org.apache.ignite.ml.math.exceptions.NonSymmetricMatrixException;
/**
* Calculates the Cholesky decomposition of a matrix.
- *
- * This class inspired by class from Apache Common Math with similar name.
+ * <p>
+ * This class inspired by class from Apache Common Math with similar name.</p>
*
* @see <a href="http://mathworld.wolfram.com/CholeskyDecomposition.html">MathWorld</a>
* @see <a href="http://en.wikipedia.org/wiki/Cholesky_decomposition">Wikipedia</a>
@@ -55,10 +55,10 @@ public class CholeskyDecomposition extends DecompositionSupport {
/**
* Calculates the Cholesky decomposition of the given matrix.
- *
+ * <p>
* Calling this constructor is equivalent to call {@link #CholeskyDecomposition(Matrix, double, double)} with the
* thresholds set to the default values {@link #DFLT_REL_SYMMETRY_THRESHOLD} and
- * {@link #DFLT_ABS_POSITIVITY_THRESHOLD}.
+ * {@link #DFLT_ABS_POSITIVITY_THRESHOLD}.</p>
*
* @param mtx the matrix to decompose.
* @throws CardinalityException if matrix is not square.
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java
index 0353bff..698cbef 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java
@@ -24,8 +24,8 @@ import org.apache.ignite.ml.math.functions.Functions;
/**
* This class provides EigenDecomposition of given matrix. The class is based on
* class with similar name from <a href="http://mahout.apache.org/">Apache Mahout</a> library.
- * <p>
- * @see <a href=http://mathworld.wolfram.com/EigenDecomposition.html>MathWorld</a></p>
+ *
+ * @see <a href=http://mathworld.wolfram.com/EigenDecomposition.html>MathWorld</a>
*/
public class EigenDecomposition extends DecompositionSupport {
/** Row and column dimension (square matrix). */
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java
index 4e9730c..02a3123 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java
@@ -25,8 +25,8 @@ import org.apache.ignite.ml.math.exceptions.SingularMatrixException;
/**
* Calculates the LU-decomposition of a square matrix.
* <p>
- * This class is inspired by class from Apache Common Math with similar name.
- * </p>
+ * This class is inspired by class from Apache Common Math with similar name.</p>
+ *
* @see <a href="http://mathworld.wolfram.com/LUDecomposition.html">MathWorld</a>
* @see <a href="http://en.wikipedia.org/wiki/LU_decomposition">Wikipedia</a>
*/
@@ -36,18 +36,22 @@ public class LUDecomposition extends DecompositionSupport {
/** Pivot permutation associated with LU decomposition. */
private final Vector pivot;
+
/** Parity of the permutation associated with the LU decomposition. */
private boolean even;
/** Singularity indicator. */
private boolean singular;
+
/** Cached value of L. */
private Matrix cachedL;
/** Cached value of U. */
private Matrix cachedU;
/** Cached value of P. */
private Matrix cachedP;
+
/** Original matrix. */
private Matrix matrix;
+
/** Entries of LU decomposition. */
private Matrix lu;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
index 2693fce..2f97067 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
@@ -78,15 +78,14 @@ public final class Functions {
/** Function that returns {@code (a - b) * (a - b)} */
public static final IgniteBiFunction<Double, Double, Double> MINUS_SQUARED = (a, b) -> (a - b) * (a - b);
- /**
- * Function that returns {@code a < b ? -1 : a > b ? 1 : 0}.
- */
+ /** Function that returns {@code a < b ? -1 : a > b ? 1 : 0}. */
public static final IgniteBiFunction<Double, Double, Double> COMPARE = (a, b) -> a < b ? -1.0 : a > b ? 1.0 : 0.0;
/**
* Function that returns {@code a + b}. {@code a} is a variable, {@code b} is fixed.
*
* @param b Value to add.
+ * @return Function for this operation.
*/
public static IgniteDoubleFunction<Double> plus(final double b) {
return (a) -> a + b;
@@ -96,12 +95,18 @@ public final class Functions {
* Function that returns {@code a * b}. {@code a} is a variable, {@code b} is fixed.
*
* @param b Value to multiply to.
+ * @return Function for this operation.
*/
public static IgniteDoubleFunction<Double> mult(final double b) {
return (a) -> a * b;
}
- /** Function that returns {@code a / b}. {@code a} is a variable, {@code b} is fixed. */
+ /**
+ * Function that returns {@code a / b}. {@code a} is a variable, {@code b} is fixed.
+ *
+ * @param b Value to divide to.
+ * @return Function for this operation.
+ */
public static IgniteDoubleFunction<Double> div(double b) {
return mult(1 / b);
}
@@ -109,6 +114,9 @@ public final class Functions {
/**
* Function that returns {@code a + b*constant}. {@code a} and {@code b} are variables,
* {@code constant} is fixed.
+ *
+ * @param constant Value to use in multiply.
+ * @return Function for this operation.
*/
public static IgniteBiFunction<Double, Double, Double> plusMult(double constant) {
return (a, b) -> a + b * constant;
@@ -117,12 +125,17 @@ public final class Functions {
/**
* Function that returns {@code a - b*constant}. {@code a} and {@code b} are variables,
* {@code constant} is fixed.
+ *
+ * @param constant Value to use in multiply.
+ * @return Function for this operation.
*/
public static IgniteBiFunction<Double, Double, Double> minusMult(double constant) {
return (a, b) -> a - b * constant;
}
/**
+ * Function that returns {@code Math.pow(a, b)}.
+ *
* @param b Power value.
* @return Function for given power.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
index 334291e..16bdc3e 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.matrix;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.MatrixStorage;
import org.apache.ignite.ml.math.Vector;
@@ -63,7 +64,7 @@ public class PivotedMatrixView extends AbstractMatrix {
}
/**
- * @param mtx Parent matrix.
+ * @param mtx Parent matrix.
* @param pivot Pivot array for rows and columns.
*/
public PivotedMatrixView(Matrix mtx, int[] pivot) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
index cd75b83..10ebdd0 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
@@ -37,14 +37,14 @@ import org.apache.ignite.ml.math.impls.storage.matrix.SparseDistributedMatrixSto
/**
* Sparse distributed matrix implementation based on data grid.
- *
+ * <p>
* Unlike {@link CacheMatrix} that is based on existing cache, this implementation creates distributed
- * cache internally and doesn't rely on pre-existing cache.
- *
+ * cache internally and doesn't rely on pre-existing cache.</p>
+ * <p>
* You also need to call {@link #destroy()} to remove the underlying cache when you no longer need this
- * matrix.
- *
- * <b>Currently fold supports only commutative operations.<b/>
+ * matrix.</p>
+ * <p>
+ * <b>Currently fold supports only commutative operations.<b/></p>
*/
public class SparseDistributedMatrix extends AbstractMatrix implements StorageConstants {
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
index 1eec6f5..687216b 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.ml.math.MatrixKeyMapper;
@@ -30,11 +31,16 @@ import org.apache.ignite.ml.math.ValueMapper;
* Matrix storage based on arbitrary cache and key and value mapping functions.
*/
public class CacheMatrixStorage<K, V> implements MatrixStorage {
- /** */ private int rows;
- /** */ private int cols;
- /** */ private IgniteCache<K, V> cache;
- /** */ private MatrixKeyMapper<K> keyMapper;
- /** */ private ValueMapper<V> valMapper;
+ /** */
+ private int rows;
+ /** */
+ private int cols;
+ /** */
+ private IgniteCache<K, V> cache;
+ /** */
+ private MatrixKeyMapper<K> keyMapper;
+ /** */
+ private ValueMapper<V> valMapper;
/**
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
index c9e8de8..410da47 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.ml.math.MatrixStorage;
@@ -27,11 +28,15 @@ import org.apache.ignite.ml.math.MatrixStorage;
* Local, dense off-heap matrix storage.
*/
public class DenseOffHeapMatrixStorage implements MatrixStorage {
- /** */ private int rows;
- /** */ private int cols;
- /** */ private transient long ptr;
+ /** */
+ private int rows;
+ /** */
+ private int cols;
+ /** */
+ private transient long ptr;
//TODO: temp solution.
- /** */ private int ptrInitHash;
+ /** */
+ private int ptrInitHash;
/** */
public DenseOffHeapMatrixStorage() {
@@ -152,7 +157,7 @@ public class DenseOffHeapMatrixStorage implements MatrixStorage {
GridUnsafe.freeMemory(ptr);
}
- /** {@inheritDoc} */
+ /** */
private long pointerOffset(int x, int y) {
return ptr + x * cols * Double.BYTES + y * Double.BYTES;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
index acd7c29..5bb2569 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.MatrixStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
import org.apache.ignite.ml.math.functions.IntIntDoubleToVoidFunction;
@@ -29,11 +30,15 @@ import org.apache.ignite.ml.math.functions.IntIntToDoubleFunction;
* Read-only or read-write function-based matrix storage.
*/
public class FunctionMatrixStorage implements MatrixStorage {
- /** */ private int rows;
- /** */ private int cols;
+ /** */
+ private int rows;
+ /** */
+ private int cols;
- /** */ private IntIntToDoubleFunction getFunc;
- /** */ private IntIntDoubleToVoidFunction setFunc;
+ /** */
+ private IntIntToDoubleFunction getFunc;
+ /** */
+ private IntIntDoubleToVoidFunction setFunc;
/**
*
@@ -83,14 +88,14 @@ public class FunctionMatrixStorage implements MatrixStorage {
}
/**
- *
+ * @return Getter function.
*/
public IntIntToDoubleFunction getFunction() {
return getFunc;
}
/**
- *
+ * @return Setter function.
*/
public IntIntDoubleToVoidFunction setFunction() {
return setFunc;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
index 4530900..db85b0f 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
@@ -19,11 +19,13 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2DoubleRBTreeMap;
+
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.HashMap;
import java.util.Map;
+
import org.apache.ignite.ml.math.MatrixStorage;
import org.apache.ignite.ml.math.StorageConstants;
@@ -34,11 +36,15 @@ public class SparseLocalOnHeapMatrixStorage implements MatrixStorage, StorageCon
/** Default zero value. */
private static final double DEFAULT_VALUE = 0.0;
- /** */ private int rows;
- /** */ private int cols;
+ /** */
+ private int rows;
+ /** */
+ private int cols;
- /** */ private int acsMode;
- /** */ private int stoMode;
+ /** */
+ private int acsMode;
+ /** */
+ private int stoMode;
/** Actual map storage. */
private Map<Integer, Map<Integer, Double>> sto;
@@ -64,16 +70,14 @@ public class SparseLocalOnHeapMatrixStorage implements MatrixStorage, StorageCon
}
/**
- *
- *
+ * @return Matrix elements storage mode.
*/
public int getStorageMode() {
return stoMode;
}
/**
- *
- *
+ * @return Matrix elements access mode.
*/
public int getAccessMode() {
return acsMode;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
index f99a216..bec232d 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.ml.math.ValueMapper;
@@ -32,10 +33,12 @@ import org.apache.ignite.ml.math.VectorStorage;
public class CacheVectorStorage<K, V> implements VectorStorage {
/** Storage size. */
private int size;
+
/** Key mapper. */
private VectorKeyMapper<K> keyMapper;
/** Value mapper. */
private ValueMapper<V> valMapper;
+
/** Underlying ignite cache. */
private IgniteCache<K, V> cache;
@@ -66,24 +69,21 @@ public class CacheVectorStorage<K, V> implements VectorStorage {
}
/**
- *
- *
+ * @return Ignite cache.
*/
public IgniteCache<K, V> cache() {
return cache;
}
/**
- *
- *
+ * @return Key mapper to validate cache keys.
*/
public VectorKeyMapper<K> keyMapper() {
return keyMapper;
}
/**
- *
- *
+ * @return Value mapper to obtain vector element values.
*/
public ValueMapper<V> valueMapper() {
return valMapper;
@@ -113,6 +113,7 @@ public class CacheVectorStorage<K, V> implements VectorStorage {
}
/** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
size = in.readInt();
keyMapper = (VectorKeyMapper<K>)in.readObject();
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
index 31469ea..1b899a1 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
@@ -27,8 +28,10 @@ import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
* Constant read-only vector storage.
*/
public class ConstantVectorStorage implements VectorStorage {
- /** */ private int size;
- /** */ private double val;
+ /** */
+ private int size;
+ /** */
+ private double val;
/**
*
@@ -49,8 +52,7 @@ public class ConstantVectorStorage implements VectorStorage {
}
/**
- *
- *
+ * @return Constant stored in Vector elements.
*/
public double constant() {
return val;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
index 6775d44..2a48653 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.VectorStorage;
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
index 0f13bb6..a17eb0b 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
import org.apache.ignite.ml.math.functions.IgniteFunction;
@@ -29,9 +30,12 @@ import org.apache.ignite.ml.math.functions.IntDoubleToVoidFunction;
* Read-only or read-write function-based vector storage.
*/
public class FunctionVectorStorage implements VectorStorage {
- /** */ private IgniteFunction<Integer, Double> getFunc;
- /** */ private IntDoubleToVoidFunction setFunc;
- /** */ private int size;
+ /** */
+ private IgniteFunction<Integer, Double> getFunc;
+ /** */
+ private IntDoubleToVoidFunction setFunc;
+ /** */
+ private int size;
/**
*
@@ -57,16 +61,14 @@ public class FunctionVectorStorage implements VectorStorage {
}
/**
- *
- *
+ * @return Getter function.
*/
public IgniteFunction<Integer, Double> getFunction() {
return getFunc;
}
/**
- *
- *
+ * @return Setter function.
*/
public IntDoubleToVoidFunction setFunction() {
return setFunc;
@@ -108,6 +110,7 @@ public class FunctionVectorStorage implements VectorStorage {
}
/** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
setFunc = (IntDoubleToVoidFunction)in.readObject();
getFunc = (IgniteFunction<Integer, Double>)in.readObject();
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
index 66aa049..59545a4 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.IndexException;
@@ -28,15 +29,21 @@ import org.apache.ignite.ml.math.exceptions.IndexException;
* Row, column or diagonal vector-based view of the matrix
*/
public class MatrixVectorStorage implements VectorStorage {
- /** */ private Matrix parent;
+ /** */
+ private Matrix parent;
- /** */ private int row;
- /** */ private int col;
+ /** */
+ private int row;
+ /** */
+ private int col;
- /** */ private int rowStride;
- /** */ private int colStride;
+ /** */
+ private int rowStride;
+ /** */
+ private int colStride;
- /** */ private int size;
+ /** */
+ private int size;
/**
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
index a524838..537d651 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
@@ -21,16 +21,20 @@ import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Arrays;
+
import org.apache.ignite.ml.math.VectorStorage;
/**
* Pivoted (index mapped) view over another vector storage implementation.
*/
public class PivotedVectorStorage implements VectorStorage {
- /** */ private VectorStorage sto;
+ /** */
+ private VectorStorage sto;
- /** */ private int[] pivot;
- /** */ private int[] unpivot;
+ /** */
+ private int[] pivot;
+ /** */
+ private int[] unpivot;
/**
* @param pivot Pivot array.
@@ -45,16 +49,14 @@ public class PivotedVectorStorage implements VectorStorage {
}
/**
- *
- *
+ * @return Pivot array for this vector view.
*/
public int[] pivot() {
return pivot;
}
/**
- *
- *
+ * @return Unpivot array for this vector view.
*/
public int[] unpivot() {
return unpivot;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
index d472e3a..453c0f7 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
@@ -28,8 +29,10 @@ import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
* Single value view storage over another vector.
*/
public class SingleElementVectorDelegateStorage implements VectorStorage {
- /** */ private int idx;
- /** */ private Vector vec;
+ /** */
+ private int idx;
+ /** */
+ private Vector vec;
/**
*
@@ -51,16 +54,14 @@ public class SingleElementVectorDelegateStorage implements VectorStorage {
}
/**
- *
- *
+ * @return Index of the element in the parent vector.
*/
public int index() {
return idx;
}
/**
- *
- *
+ * @return Parent vector.
*/
public Vector delegate() {
return vec;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
index 854b732..6378399 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
@@ -27,9 +28,12 @@ import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
* Vector storage holding a single non-zero value at some index.
*/
public class SingleElementVectorStorage implements VectorStorage {
- /** */ private int idx;
- /** */ private double val;
- /** */ private int size;
+ /** */
+ private int idx;
+ /** */
+ private double val;
+ /** */
+ private int size;
/**
*
@@ -53,7 +57,6 @@ public class SingleElementVectorStorage implements VectorStorage {
}
/**
- *
* @return Index of the element in the parent vector.
*/
public int index() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
index 035a565..fe70fbd 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.nio.ByteBuffer;
+
import org.apache.ignite.internal.util.offheap.GridOffHeapMap;
import org.apache.ignite.internal.util.offheap.GridOffHeapMapFactory;
import org.apache.ignite.ml.math.VectorStorage;
@@ -33,8 +34,10 @@ import org.apache.ignite.ml.math.impls.vector.SparseLocalOffHeapVector;
public class SparseLocalOffHeapVectorStorage implements VectorStorage {
/** Assume 10% density. */
private static final int INIT_DENSITY = 10;
+
/** Storage capacity. */
private int size;
+
/** Local off heap map. */
private GridOffHeapMap gridOffHeapMap;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
index 75318d6..d3dba8e 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
@@ -19,10 +19,12 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2DoubleRBTreeMap;
+
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Map;
+
import org.apache.ignite.ml.math.StorageConstants;
import org.apache.ignite.ml.math.VectorStorage;
@@ -30,8 +32,10 @@ import org.apache.ignite.ml.math.VectorStorage;
* Sparse, local, on-heap vector storage.
*/
public class SparseLocalOnHeapVectorStorage implements VectorStorage, StorageConstants {
- /** */ private int size;
- /** */ private int acsMode;
+ /** */
+ private int size;
+ /** */
+ private int acsMode;
/** Actual map storage. */
private Map<Integer, Double> sto;
@@ -61,8 +65,7 @@ public class SparseLocalOnHeapVectorStorage implements VectorStorage, StorageCon
}
/**
- *
- *
+ * @return Vector elements access mode.
*/
public int getAccessMode() {
return acsMode;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
index 83ac837..d59964b 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
@@ -28,6 +28,7 @@ import java.util.NoSuchElementException;
import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.function.IntToDoubleFunction;
+
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
index c868160..545d728 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Spliterator;
import java.util.function.IntToDoubleFunction;
+
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
index 1eda7d8..e479945 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.exceptions.IndexException;
@@ -29,13 +30,18 @@ import org.apache.ignite.ml.math.impls.storage.vector.MatrixVectorStorage;
* Row or column vector view off the matrix.
*/
public class MatrixVectorView extends AbstractVector {
- /** */ private Matrix parent;
-
- /** */ private int row;
- /** */ private int col;
-
- /** */ private int rowStride;
- /** */ private int colStride;
+ /** */
+ private Matrix parent;
+
+ /** */
+ private int row;
+ /** */
+ private int col;
+
+ /** */
+ private int rowStride;
+ /** */
+ private int colStride;
/**
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
index 5ad6b89..0d53e71 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
@@ -30,7 +31,8 @@ import org.apache.ignite.ml.math.impls.storage.vector.PivotedVectorStorage;
* Pivoted (index mapped) view over another vector.
*/
public class PivotedVectorView extends AbstractVector {
- /** */ private Vector vec;
+ /** */
+ private Vector vec;
/**
* @param vec Parent vector.
@@ -47,7 +49,7 @@ public class PivotedVectorView extends AbstractVector {
}
/**
- * @param vec Parent vector.
+ * @param vec Parent vector.
* @param pivot Mapping from external index to internal.
*/
public PivotedVectorView(Vector vec, int[] pivot) {
@@ -79,7 +81,7 @@ public class PivotedVectorView extends AbstractVector {
/**
* @param i Index to pivot.
- * @return Mapping from external index to internal for given index.
+ * @return Mapping from external index to internal for given index.
*/
public int pivot(int i) {
return storage().pivot()[i];
@@ -104,17 +106,17 @@ public class PivotedVectorView extends AbstractVector {
int exIdx = storage().pivot()[idx];
return new Vector.Element() {
- /** {@inheritDoc */
+ /** {@inheritDoc} */
@Override public double get() {
return storageGet(idx);
}
- /** {@inheritDoc */
+ /** {@inheritDoc} */
@Override public int index() {
return exIdx;
}
- /** {@inheritDoc */
+ /** {@inheritDoc} */
@Override public void set(double val) {
storageSet(idx, val);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
index d216a90..df6f791 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Map;
+
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
@@ -33,7 +34,8 @@ import org.apache.ignite.ml.math.Vector;
* that by default, the value is determined by a relatively simple hash of the index.
*/
public class RandomVector extends AbstractReadOnlyVector {
- /** */ private boolean fastHash;
+ /** */
+ private boolean fastHash;
/**
* @param size Vector cardinality.
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
index b47dad8..21e8141 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
@@ -1,102 +1 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.ml.math.impls.vector;
-
-import java.util.Map;
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.Vector;
-import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.ml.math.impls.storage.vector.SingleElementVectorStorage;
-
-/**
- * Read-write vector holding a single non-zero value at some index.
- */
-public class SingleElementVector extends AbstractVector {
- /**
- *
- */
- public SingleElementVector() {
- // No-op
- }
-
- /**
- * @param size Parent vector size.
- * @param idx Index of the parent vector element.
- * @param val Value of the vector element.
- */
- public SingleElementVector(int size, int idx, double val) {
- super(new SingleElementVectorStorage(size, idx, val));
- }
-
- /**
- * @param args Parameters to create new vector instance.
- */
- public SingleElementVector(Map<String, Object> args) {
- assert args != null;
-
- if (args.containsKey("size") && args.containsKey("index") && args.containsKey("value")) {
- int size = (int)args.get("size");
- int idx = (int)args.get("index");
- double val = (double)args.get("value");
-
- setStorage(new SingleElementVectorStorage(size, idx, val));
- }
- else
- throw new UnsupportedOperationException("Invalid constructor argument(s).");
- }
-
- /**
- *
- *
- */
- private SingleElementVectorStorage storage() {
- return (SingleElementVectorStorage)getStorage();
- }
-
- /** {@inheritDoc} */
- @Override public Element minElement() {
- return makeElement(storage().index());
- }
-
- /** {@inheritDoc} */
- @Override public Element maxElement() {
- return makeElement(storage().index());
- }
-
- /** {@inheritDoc} */
- @Override public double sum() {
- return getX(storage().index());
- }
-
- /** {@inheritDoc} */
- @Override public int nonZeroElements() {
- return isZero(get(storage().index())) ? 0 : 1;
- }
-
- /** {@inheritDoc} */
- @Override public Vector like(int crd) {
- int idx = storage().index();
-
- return new SingleElementVector(crd, idx, getX(idx));
- }
-
- /** {@inheritDoc} */
- @Override public Matrix likeMatrix(int rows, int cols) {
- throw new UnsupportedOperationException();
- }
-}
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.ignite.ml.math.impls.vector;
import java.util.Map;
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.except
ions.UnsupportedOperationException;
import org.apache.ignite.ml.math.impls.storage.vector.SingleElementVectorStorage;
/**
* Read-write vector holding a single non-zero value at some index.
*/
public class SingleElementVector extends AbstractVector {
/**
*
*/
public SingleElementVector() {
// No-op
}
/**
* @param size Parent vector size.
* @param idx Index of the parent vector element.
* @param val Value of the vector element.
*/
public SingleElementVector(int size, int idx, double val) {
super(new SingleElementVectorStorage(size, idx, val));
}
/**
* @param args Parameters to create new vector instance.
*/
public SingleElementVector(Map<String, Object> args) {
assert args != null;
if (args.containsKey("size") && args.containsKey("index") && args.containsKey("value")) {
int size = (int)args.get("size");
int idx = (int)args.get("index");
doub
le val = (double)args.get("value");
setStorage(new SingleElementVectorStorage(size, idx, val));
}
else
throw new UnsupportedOperationException("Invalid constructor argument(s).");
}
/**
*
*
*/
private SingleElementVectorStorage storage() {
return (SingleElementVectorStorage)getStorage();
}
/** {@inheritDoc} */
@Override public Element minElement() {
return makeElement(storage().index());
}
/** {@inheritDoc} */
@Override public Element maxElement() {
return makeElement(storage().index());
}
/** {@inheritDoc} */
@Override public double sum() {
return getX(storage().index());
}
/** {@inheritDoc} */
@Override public int nonZeroElements() {
return isZero(get(storage().index())) ? 0 : 1;
}
/** {@inheritDoc} */
@Override public Vector like(int crd) {
int idx = storage().index();
return new SingleElemen
tVector(crd, idx, getX(idx));
}
/** {@inheritDoc} */
@Override public Matrix likeMatrix(int rows, int cols) {
throw new UnsupportedOperationException();
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
index d7c746d..b4f7330 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
@@ -23,6 +23,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;
+
import org.apache.ignite.ml.math.impls.MathTestConstants;
import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
@@ -35,8 +36,11 @@ import static org.junit.Assert.assertEquals;
* Tests for {@link Tracer}.
*/
public class TracerTest {
- /** */ private static final String DEFAULT_FORMAT = "%.10f";
- /** */ private static final double DEFAULT_DELTA = 0.000000001d;
+ /** */
+ private static final String DEFAULT_FORMAT = "%.10f";
+
+ /** */
+ private static final double DEFAULT_DELTA = 0.000000001d;
/**
* Color mapper that maps [0, 1] range into three distinct RGB segments.
@@ -153,7 +157,7 @@ public class TracerTest {
List<String> strings = Files.readAllLines(file);
Optional<String> reduce = strings.stream().reduce((s1, s2) -> s1 + s2);
- String[] csvVals = reduce.get().split(",");
+ String[] csvVals = reduce.orElse("").split(",");
for (int i = 0; i < vector.size(); i++) {
Double csvVal = Double.valueOf(csvVals[i]);
@@ -181,7 +185,7 @@ public class TracerTest {
List<String> strings = Files.readAllLines(file);
Optional<String> reduce = strings.stream().reduce((s1, s2) -> s1 + s2);
- String[] csvVals = reduce.get().split(",");
+ String[] csvVals = reduce.orElse("").split(",");
for (int i = 0; i < matrix.rowSize(); i++)
for (int j = 0; j < matrix.columnSize(); j++) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java
index 52badbc..a7e9488 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java
@@ -291,7 +291,7 @@ public class CacheMatrixTest extends GridCommonAbstractTest {
final CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
ExternalizeTest<CacheMatrix<Integer, Double>> externalizeTest = new ExternalizeTest<CacheMatrix<Integer, Double>>() {
-
+ /** {@inheritDoc} */
@Override public void externalizeTest() {
super.externalizeTest(cacheMatrix);
}
@@ -351,14 +351,18 @@ public class CacheMatrixTest extends GridCommonAbstractTest {
return new MatrixKeyMapperForTests(rows, cols);
}
- /** Init the given matrix by random values. */
+ /**
+ * Init the given matrix by random values.
+ */
private void fillMatrix(Matrix m) {
for (int i = 0; i < m.rowSize(); i++)
for (int j = 0; j < m.columnSize(); j++)
m.set(i, j, Math.random());
}
- /** Init the given matrix by zeros. */
+ /**
+ * Init the given matrix by zeros.
+ */
private void initMatrix(Matrix m) {
for (int i = 0; i < m.rowSize(); i++)
for (int j = 0; j < m.columnSize(); j++)
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java
index bc628c9..cfdd0f3 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java
@@ -20,31 +20,36 @@ import org.apache.ignite.ml.math.MatrixKeyMapper;
/** */
public class MatrixKeyMapperForTests implements MatrixKeyMapper<Integer> {
- /** */ private int rows;
- /** */ private int cols;
+ /** */
+ private int rows;
+ /** */
+ private int cols;
/** */
public MatrixKeyMapperForTests() {
// No-op.
}
- /** */
+ /**
+ * @param rows Amount of rows in matrix.
+ * @param cols Amount of columns in matrix.
+ */
public MatrixKeyMapperForTests(int rows, int cols) {
this.rows = rows;
this.cols = cols;
}
- /** */
+ /** {@inheritDoc} */
@Override public Integer apply(int x, int y) {
return x * cols + y;
}
- /** */
+ /** {@inheritDoc} */
@Override public boolean isValid(Integer integer) {
return (rows * cols) > integer;
}
- /** */
+ /** {@inheritDoc} */
@Override public int hashCode() {
int hash = 1;
@@ -54,7 +59,7 @@ public class MatrixKeyMapperForTests implements MatrixKeyMapper<Integer> {
return hash;
}
- /** */
+ /** {@inheritDoc} */
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
index 03473cf..78f3dde 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
@@ -23,17 +23,18 @@ import java.util.List;
import java.util.NoSuchElementException;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
+
import org.apache.ignite.ml.math.MatrixStorage;
import org.apache.ignite.ml.math.StorageConstants;
import org.jetbrains.annotations.NotNull;
/**
- *
+ * Fixtures for matrix tests.
*/
class MatrixStorageFixtures {
/** */
private static final List<Supplier<Iterable<MatrixStorage>>> suppliers = Collections.singletonList(
- (Supplier<Iterable<MatrixStorage>>) SparseLocalMatrixStorageFixture::new
+ (Supplier<Iterable<MatrixStorage>>)SparseLocalMatrixStorageFixture::new
);
/** */
@@ -57,10 +58,12 @@ class MatrixStorageFixtures {
private final Integer[] rows = new Integer[] {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 512, 1024, null};
/** */
private final Integer[] cols = new Integer[] {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 1024, 512, null};
+
/** */
private final Integer[] randomAccess = new Integer[] {StorageConstants.SEQUENTIAL_ACCESS_MODE, StorageConstants.RANDOM_ACCESS_MODE, null};
/** */
private final Integer[] rowStorage = new Integer[] {StorageConstants.ROW_STORAGE_MODE, StorageConstants.COLUMN_STORAGE_MODE, null};
+
/** */
private int sizeIdx = 0;
/** */
@@ -118,19 +121,23 @@ class MatrixStorageFixtures {
", access mode=" + randomAccess[acsModeIdx] + ", storage mode=" + rowStorage[stoModeIdx] + "}";
}
- /** */ private boolean hasNextRow(int idx) {
+ /** */
+ private boolean hasNextRow(int idx) {
return rows[idx] != null;
}
- /** */ private boolean hasNextCol(int idx) {
+ /** */
+ private boolean hasNextCol(int idx) {
return cols[idx] != null;
}
- /** */ private boolean hasNextAcsMode(int idx) {
+ /** */
+ private boolean hasNextAcsMode(int idx) {
return randomAccess[idx] != null;
}
- /** */ private boolean hasNextStoMode(int idx) {
+ /** */
+ private boolean hasNextStoMode(int idx) {
return rowStorage[idx] != null;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
index 7e5fc48..0b4392e 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
@@ -33,7 +33,8 @@ import static org.junit.Assert.assertTrue;
* Tests for {@link SparseLocalOffHeapVectorStorage}.
*/
public class SparseLocalOffHeapVectorStorageTest extends ExternalizeTest<SparseLocalOffHeapVectorStorage> {
- /** */ private SparseLocalOffHeapVectorStorage testVectorStorage;
+ /** */
+ private SparseLocalOffHeapVectorStorage testVectorStorage;
/** */
@Before
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
index 7d12773..0707e0a 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.ml.math.impls.vector;
import java.util.Arrays;
import java.util.stream.StreamSupport;
+
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.VectorStorage;
@@ -355,54 +356,55 @@ public class AbstractVectorTest {
* @param storage {@link VectorStorage}
* @return AbstractVector.
*/
+ @SuppressWarnings("ClassWithoutNoArgConstructor")
private AbstractVector getAbstractVector(VectorStorage storage) {
return new AbstractVector(storage) { // TODO: find out how to fix warning about missing constructor
- /** */
+ /** {@inheritDoc} */
@Override public boolean isDense() {
return false;
}
- /** */
+ /** {@inheritDoc} */
@Override public boolean isSequentialAccess() {
return false;
}
- /** */
+ /** {@inheritDoc} */
@Override public Matrix likeMatrix(int rows, int cols) {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector copy() {
return getAbstractVector(this.getStorage());
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector like(int crd) {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector normalize() {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector normalize(double power) {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector logNormalize() {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector logNormalize(double power) {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector viewPart(int off, int len) {
return null;
}
@@ -426,52 +428,52 @@ public class AbstractVectorTest {
*/
private AbstractVector getAbstractVector() {
return new AbstractVector() { // TODO: find out how to fix warning about missing constructor
- /** */
+ /** {@inheritDoc} */
@Override public boolean isDense() {
return false;
}
- /** */
+ /** {@inheritDoc} */
@Override public Matrix likeMatrix(int rows, int cols) {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public boolean isSequentialAccess() {
return false;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector copy() {
return getAbstractVector(this.getStorage());
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector like(int crd) {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector normalize() {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector normalize(double power) {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector logNormalize() {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector logNormalize(double power) {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector viewPart(int off, int len) {
return null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
index 0026e2b..ce9f98a 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.stream.IntStream;
+
import junit.framework.TestCase;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
@@ -48,6 +49,7 @@ public class CacheVectorTest extends GridCommonAbstractTest {
private static final String CACHE_NAME = "test-cache";
/** Cache size. */
private static final int size = MathTestConstants.STORAGE_SIZE;
+
/** Grid instance. */
private Ignite ignite;
/** Default key mapper. */
@@ -420,7 +422,8 @@ public class CacheVectorTest extends GridCommonAbstractTest {
return cache;
}
- /** */ private static class TestKeyMapper implements VectorKeyMapper<Integer> {
+ /** */
+ private static class TestKeyMapper implements VectorKeyMapper<Integer> {
/** {@inheritDoc} */
@Override public Integer apply(int i) {
return i;