You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hivemall.apache.org by my...@apache.org on 2019/10/18 08:42:23 UTC

[incubator-hivemall] branch master updated: [HIVEMALL-269] Modified to use matrix4j for matrix module

This is an automated email from the ASF dual-hosted git repository.

myui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hivemall.git


The following commit(s) were added to refs/heads/master by this push:
     new ecc98a5  [HIVEMALL-269] Modified to use matrix4j for matrix module
ecc98a5 is described below

commit ecc98a5f1385faeaac28d251616a453d19ac3b3c
Author: Makoto Yui <my...@apache.org>
AuthorDate: Fri Oct 18 17:42:16 2019 +0900

    [HIVEMALL-269] Modified to use matrix4j for matrix module
    
    ## What changes were proposed in this pull request?
    
     Use matrix4j for matrix module
    
    ## What type of PR is it?
    
    Hot Fix | Refactoring
    
    ## What is the Jira issue?
    
    https://issues.apache.org/jira/browse/HIVEMALL-269
    
    ## How was this patch tested?
    
    unit tests
    
    ## Checklist
    
    (Please remove this section if not needed; check `x` for YES, blank for NO)
    
    - [x] Did you apply source code formatter, i.e., `./bin/format_code.sh`, for your commit?
    - [ ] Did you run system tests on Hive (or Spark)?
    
    Author: Makoto Yui <my...@apache.org>
    
    Closes #202 from myui/HIVEMALL-269.
---
 core/pom.xml                                       |  18 +-
 .../java/hivemall/math/matrix/AbstractMatrix.java  | 136 -----
 .../math/matrix/ColumnMajorFloatMatrix.java        |  51 --
 .../hivemall/math/matrix/ColumnMajorMatrix.java    |  59 --
 .../java/hivemall/math/matrix/FloatMatrix.java     |  76 ---
 .../src/main/java/hivemall/math/matrix/Matrix.java | 129 ----
 .../java/hivemall/math/matrix/MatrixUtils.java     | 335 -----------
 .../hivemall/math/matrix/RowMajorFloatMatrix.java  |  51 --
 .../java/hivemall/math/matrix/RowMajorMatrix.java  |  69 ---
 .../math/matrix/builders/CSCMatrixBuilder.java     | 123 ----
 .../math/matrix/builders/CSRMatrixBuilder.java     |  79 ---
 .../builders/ColumnMajorDenseMatrixBuilder.java    |  84 ---
 .../math/matrix/builders/DoKMatrixBuilder.java     |  58 --
 .../math/matrix/builders/MatrixBuilder.java        |  97 ---
 .../builders/RowMajorDenseMatrixBuilder.java       |  88 ---
 .../matrix/dense/ColumnMajorDenseMatrix2d.java     | 300 ----------
 .../math/matrix/dense/RowMajorDenseMatrix2d.java   | 349 -----------
 .../math/matrix/ints/AbstractIntMatrix.java        | 127 ----
 .../matrix/ints/ColumnMajorDenseIntMatrix2d.java   | 199 ------
 .../math/matrix/ints/ColumnMajorIntMatrix.java     |  46 --
 .../hivemall/math/matrix/ints/DoKIntMatrix.java    | 277 ---------
 .../java/hivemall/math/matrix/ints/IntMatrix.java  | 104 ----
 .../hivemall/math/matrix/sparse/CSCMatrix.java     | 296 ---------
 .../hivemall/math/matrix/sparse/CSRMatrix.java     | 282 ---------
 .../hivemall/math/matrix/sparse/DoKMatrix.java     | 371 ------------
 .../math/matrix/sparse/floats/CSCFloatMatrix.java  | 317 ----------
 .../math/matrix/sparse/floats/CSRFloatMatrix.java  | 294 ---------
 .../math/matrix/sparse/floats/DoKFloatMatrix.java  | 402 -------------
 .../java/hivemall/math/vector/AbstractVector.java  |  59 --
 .../hivemall/math/vector/DenseFloatVector.java     | 107 ----
 .../java/hivemall/math/vector/DenseVector.java     |  90 ---
 .../hivemall/math/vector/SparseFloatVector.java    |  86 ---
 .../java/hivemall/math/vector/SparseVector.java    |  76 ---
 .../src/main/java/hivemall/math/vector/Vector.java |  55 --
 .../java/hivemall/math/vector/VectorProcedure.java |  46 --
 .../src/main/java/hivemall/recommend/SlimUDTF.java |   6 +-
 .../smile/classification/DecisionTree.java         |  10 +-
 .../GradientTreeBoostingClassifierUDTF.java        |  16 +-
 .../classification/RandomForestClassifierUDTF.java |  18 +-
 .../regression/RandomForestRegressionUDTF.java     |  12 +-
 .../hivemall/smile/regression/RegressionTree.java  |  10 +-
 .../java/hivemall/smile/tools/DecisionPathUDF.java |   6 +-
 .../java/hivemall/smile/tools/TreePredictUDF.java  |   6 +-
 .../java/hivemall/smile/utils/SmileExtUtils.java   |   8 +-
 .../collections/arrays/SparseDoubleArray.java      |   2 +-
 .../utils/collections/arrays/SparseFloatArray.java |   2 +-
 .../hivemall/math/matrix/MatrixBuilderTest.java    | 664 ---------------------
 .../java/hivemall/math/matrix/MatrixUtilsTest.java | 132 ----
 .../hivemall/math/matrix/ints/IntMatrixTest.java   | 361 -----------
 .../hivemall/math/matrix/sparse/DoKMatrixTest.java |  83 ---
 .../matrix/sparse/floats/DoKFloatMatrixTest.java   |  60 --
 .../smile/classification/DecisionTreeTest.java     |   8 +-
 .../smile/regression/RegressionTreeTest.java       |   6 +-
 .../hivemall/smile/tools/TreePredictUDFTest.java   |   2 +-
 .../hivemall/smile/tools/TreePredictUDFv1Test.java |   2 +-
 dist/pom.xml                                       |   1 +
 56 files changed, 71 insertions(+), 6680 deletions(-)

diff --git a/core/pom.xml b/core/pom.xml
index fe756a0..645967d 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -16,7 +16,9 @@
   specific language governing permissions and limitations
   under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 
 	<parent>
@@ -84,6 +86,12 @@
 
 		<!-- compile scope -->
 		<dependency>
+			<groupId>io.github.myui</groupId>
+			<artifactId>matrix4j</artifactId>
+			<version>0.9.0</version>
+			<scope>compile</scope>
+		</dependency>
+		<dependency>
 			<!-- required for mixing client -->
 			<groupId>io.netty</groupId>
 			<artifactId>netty-all</artifactId>
@@ -128,10 +136,10 @@
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
-		  <groupId>com.clearspring.analytics</groupId>
-		  <artifactId>stream</artifactId>
-		  <version>2.9.5</version>
-		  <scope>compile</scope>
+			<groupId>com.clearspring.analytics</groupId>
+			<artifactId>stream</artifactId>
+			<version>2.9.5</version>
+			<scope>compile</scope>
 		</dependency>
 
 		<!-- test scope -->
diff --git a/core/src/main/java/hivemall/math/matrix/AbstractMatrix.java b/core/src/main/java/hivemall/math/matrix/AbstractMatrix.java
deleted file mode 100644
index b9abd0f..0000000
--- a/core/src/main/java/hivemall/math/matrix/AbstractMatrix.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * 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 hivemall.math.matrix;
-
-import hivemall.math.vector.SparseVector;
-import hivemall.math.vector.Vector;
-import hivemall.math.vector.VectorProcedure;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public abstract class AbstractMatrix implements Matrix {
-
-    public AbstractMatrix() {}
-
-    @Override
-    public double[] row() {
-        int cols = numColumns();
-        return new double[cols];
-    }
-
-    @Override
-    public Vector rowVector() {
-        return new SparseVector();
-    }
-
-    @Override
-    public final double get(@Nonnegative final int row, @Nonnegative final int col) {
-        return get(row, col, 0.d);
-    }
-
-    protected static final void checkRowIndex(final int row, final int numRows) {
-        if (row < 0 || row >= numRows) {
-            throw new IndexOutOfBoundsException("Row index " + row + " out of bounds " + numRows);
-        }
-    }
-
-    protected static final void checkColIndex(final int col, final int numColumns) {
-        if (col < 0 || col >= numColumns) {
-            throw new IndexOutOfBoundsException(
-                "Col index " + col + " out of bounds " + numColumns);
-        }
-    }
-
-    protected static final void checkIndex(final int index) {
-        if (index < 0) {
-            throw new IndexOutOfBoundsException("Invalid index " + index);
-        }
-    }
-
-    protected static final void checkIndex(final int row, final int col) {
-        if (row < 0) {
-            throw new IndexOutOfBoundsException("Invalid row index " + row);
-        }
-        if (col < 0) {
-            throw new IndexOutOfBoundsException("Invalid col index " + col);
-        }
-    }
-
-    protected static final void checkIndex(final int row, final int col, final int numRows,
-            final int numColumns) {
-        if (row < 0 || row >= numRows) {
-            throw new IndexOutOfBoundsException("Row index " + row + " out of bounds " + numRows);
-        }
-        if (col < 0 || col >= numColumns) {
-            throw new IndexOutOfBoundsException(
-                "Col index " + col + " out of bounds " + numColumns);
-        }
-    }
-
-    @Override
-    public void eachInRow(final int row, @Nonnull final VectorProcedure procedure) {
-        eachInRow(row, procedure, true);
-    }
-
-    @Override
-    public void eachInColumn(final int col, @Nonnull final VectorProcedure procedure) {
-        eachInColumn(col, procedure, true);
-    }
-
-    @Override
-    public void eachNonNullInRow(final int row, @Nonnull final VectorProcedure procedure) {
-        eachInRow(row, procedure, false);
-    }
-
-    @Override
-    public void eachNonNullInColumn(final int col, @Nonnull final VectorProcedure procedure) {
-        eachInColumn(col, procedure, false);
-    }
-
-    @Override
-    public void eachNonZeroCell(VectorProcedure procedure) {
-        throw new UnsupportedOperationException("Not yet supported");
-    }
-
-    @Override
-    public String toString() {
-        final int printSize = 7;
-        final StringBuilder buf = new StringBuilder();
-
-        final int rows = numRows();
-        final int cols = numColumns();
-
-        final String newline = cols > printSize ? "...\n" : "\n";
-
-        for (int i = 0, maxRows = Math.min(printSize, rows); i < maxRows; i++) {
-            for (int j = 0, maxCols = Math.min(printSize, cols); j < maxCols; j++) {
-                buf.append(String.format("%8.4f  ", get(i, j)));
-            }
-            buf.append(newline);
-        }
-
-        if (rows > printSize) {
-            buf.append("  ...\n");
-        }
-
-        return buf.toString();
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/ColumnMajorFloatMatrix.java b/core/src/main/java/hivemall/math/matrix/ColumnMajorFloatMatrix.java
deleted file mode 100644
index c63febc..0000000
--- a/core/src/main/java/hivemall/math/matrix/ColumnMajorFloatMatrix.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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 hivemall.math.matrix;
-
-import javax.annotation.Nonnegative;
-
-public abstract class ColumnMajorFloatMatrix extends ColumnMajorMatrix implements FloatMatrix {
-
-    public ColumnMajorFloatMatrix() {
-        super();
-    }
-
-    @Override
-    public ColumnMajorFloatMatrix toColumnMajorMatrix() {
-        return this;
-    }
-
-    @Override
-    public double get(@Nonnegative final int row, @Nonnegative final int col,
-            final double defaultValue) {
-        return get(row, col, (float) defaultValue);
-    }
-
-    @Override
-    public void set(@Nonnegative final int row, @Nonnegative final int col, final double value) {
-        set(row, col, (float) value);
-    }
-
-    @Override
-    public double getAndSet(@Nonnegative final int row, @Nonnegative final int col,
-            final double value) {
-        return getAndSet(row, col, (float) value);
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/ColumnMajorMatrix.java b/core/src/main/java/hivemall/math/matrix/ColumnMajorMatrix.java
deleted file mode 100644
index 51c80aa..0000000
--- a/core/src/main/java/hivemall/math/matrix/ColumnMajorMatrix.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 hivemall.math.matrix;
-
-import hivemall.math.vector.VectorProcedure;
-
-public abstract class ColumnMajorMatrix extends AbstractMatrix {
-
-    public ColumnMajorMatrix() {
-        super();
-    }
-
-    @Override
-    public boolean isRowMajorMatrix() {
-        return false;
-    }
-
-    @Override
-    public boolean isColumnMajorMatrix() {
-        return true;
-    }
-
-    @Override
-    public void eachInRow(int row, VectorProcedure procedure, boolean nullOutput) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void eachColumnIndexInRow(int row, VectorProcedure procedure) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void eachNonZeroInRow(int row, VectorProcedure procedure) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public ColumnMajorMatrix toColumnMajorMatrix() {
-        return this;
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/FloatMatrix.java b/core/src/main/java/hivemall/math/matrix/FloatMatrix.java
deleted file mode 100644
index afc54a0..0000000
--- a/core/src/main/java/hivemall/math/matrix/FloatMatrix.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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 hivemall.math.matrix;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public interface FloatMatrix extends Matrix {
-
-    /**
-     * @throws IndexOutOfBoundsException
-     */
-    public float get(@Nonnegative final int row, @Nonnegative final int col,
-            final float defaultValue);
-
-    /**
-     * @throws IndexOutOfBoundsException
-     * @throws UnsupportedOperationException
-     */
-    public void set(@Nonnegative final int row, @Nonnegative final int col, final float value);
-
-    /**
-     * @throws IndexOutOfBoundsException
-     * @throws UnsupportedOperationException
-     */
-    public float getAndSet(@Nonnegative final int row, @Nonnegative final int col,
-            final float value);
-
-    /**
-     * @return returns dst
-     */
-    @Nonnull
-    public float[] getRow(@Nonnegative int index, @Nonnull float[] dst);
-
-    /*
-    @Override
-    default double get(@Nonnegative final int row, @Nonnegative final int col,
-            final double defaultValue) {
-        return get(row, col, (float) defaultValue);
-    }
-    
-    @Override
-    default void set(@Nonnegative final int row, @Nonnegative final int col, final double value) {
-        set(row, col, (float) value);
-    }
-    
-    @Override
-    default double getAndSet(@Nonnegative final int row, @Nonnegative final int col,
-            final double value) {
-        return getAndSet(row, col, (float) value);
-    }
-    */
-
-    @Override
-    public RowMajorFloatMatrix toRowMajorMatrix();
-
-    @Override
-    public ColumnMajorFloatMatrix toColumnMajorMatrix();
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/Matrix.java b/core/src/main/java/hivemall/math/matrix/Matrix.java
deleted file mode 100644
index 338a4c2..0000000
--- a/core/src/main/java/hivemall/math/matrix/Matrix.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 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 hivemall.math.matrix;
-
-import hivemall.math.matrix.builders.MatrixBuilder;
-import hivemall.math.vector.Vector;
-import hivemall.math.vector.VectorProcedure;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-import javax.annotation.concurrent.NotThreadSafe;
-
-/**
- * Double matrix.
- */
-@NotThreadSafe
-public interface Matrix {
-
-    public boolean isSparse();
-
-    public boolean isRowMajorMatrix();
-
-    public boolean isColumnMajorMatrix();
-
-    public boolean readOnly();
-
-    public boolean swappable();
-
-    /** The Number of Non-Zeros */
-    public int nnz();
-
-    @Nonnegative
-    public int numRows();
-
-    @Nonnegative
-    public int numColumns();
-
-    @Nonnegative
-    public int numColumns(@Nonnegative int row);
-
-    @Nonnull
-    public double[] row();
-
-    @Nonnull
-    public Vector rowVector();
-
-    @Nonnull
-    public double[] getRow(@Nonnegative int index);
-
-    /**
-     * @return returns dst
-     */
-    @Nonnull
-    public double[] getRow(@Nonnegative int index, @Nonnull double[] dst);
-
-    public void getRow(@Nonnegative int index, @Nonnull Vector row);
-
-    /**
-     * @throws IndexOutOfBoundsException
-     */
-    public double get(@Nonnegative int row, @Nonnegative int col);
-
-    /**
-     * @throws IndexOutOfBoundsException
-     */
-    public double get(@Nonnegative int row, @Nonnegative int col, double defaultValue);
-
-    /**
-     * @throws IndexOutOfBoundsException
-     * @throws UnsupportedOperationException
-     */
-    public void set(@Nonnegative int row, @Nonnegative int col, double value);
-
-    /**
-     * @throws IndexOutOfBoundsException
-     * @throws UnsupportedOperationException
-     */
-    public double getAndSet(@Nonnegative int row, @Nonnegative int col, double value);
-
-    public void swap(@Nonnegative int row1, @Nonnegative int row2);
-
-    public void eachInRow(@Nonnegative int row, @Nonnull VectorProcedure procedure);
-
-    public void eachInRow(@Nonnegative int row, @Nonnull VectorProcedure procedure,
-            boolean nullOutput);
-
-    public void eachNonNullInRow(@Nonnegative int row, @Nonnull VectorProcedure procedure);
-
-    public void eachNonZeroInRow(@Nonnegative int row, @Nonnull VectorProcedure procedure);
-
-    public void eachColumnIndexInRow(@Nonnegative int row, @Nonnull VectorProcedure procedure);
-
-    public void eachInColumn(@Nonnegative int col, @Nonnull VectorProcedure procedure);
-
-    public void eachInColumn(@Nonnegative int col, @Nonnull VectorProcedure procedure,
-            boolean nullOutput);
-
-    public void eachNonNullInColumn(@Nonnegative int col, @Nonnull VectorProcedure procedure);
-
-    public void eachNonZeroInColumn(@Nonnegative int col, @Nonnull VectorProcedure procedure);
-
-    public void eachNonZeroCell(@Nonnull final VectorProcedure procedure);
-
-    @Nonnull
-    public RowMajorMatrix toRowMajorMatrix();
-
-    @Nonnull
-    public ColumnMajorMatrix toColumnMajorMatrix();
-
-    @Nonnull
-    public MatrixBuilder builder();
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/MatrixUtils.java b/core/src/main/java/hivemall/math/matrix/MatrixUtils.java
deleted file mode 100644
index cd137ed..0000000
--- a/core/src/main/java/hivemall/math/matrix/MatrixUtils.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * 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 hivemall.math.matrix;
-
-import hivemall.math.matrix.builders.MatrixBuilder;
-import hivemall.math.matrix.ints.IntMatrix;
-import hivemall.math.matrix.sparse.CSCMatrix;
-import hivemall.math.matrix.sparse.CSRMatrix;
-import hivemall.math.matrix.sparse.floats.CSCFloatMatrix;
-import hivemall.math.matrix.sparse.floats.CSRFloatMatrix;
-import hivemall.math.vector.VectorProcedure;
-import hivemall.utils.lang.Preconditions;
-import hivemall.utils.lang.mutable.MutableInt;
-
-import java.util.Arrays;
-import java.util.Comparator;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public final class MatrixUtils {
-
-    private MatrixUtils() {}
-
-    @Nonnull
-    public static Matrix shuffle(@Nonnull final Matrix m, @Nonnull final int[] indices) {
-        Preconditions.checkArgument(m.numRows() <= indices.length, "m.numRow() `" + m.numRows()
-                + "` MUST be equals to or less than |swapIndices| `" + indices.length + "`");
-
-        final MatrixBuilder builder = m.builder();
-        final VectorProcedure proc = new VectorProcedure() {
-            public void apply(int col, double value) {
-                builder.nextColumn(col, value);
-            }
-        };
-        for (int i = 0; i < indices.length; i++) {
-            int idx = indices[i];
-            m.eachNonNullInRow(idx, proc);
-            builder.nextRow();
-        }
-        return builder.buildMatrix();
-    }
-
-    /**
-     * Returns the index of maximum value of an array.
-     * 
-     * @return -1 if there are no columns
-     */
-    public static int whichMax(@Nonnull final IntMatrix matrix, @Nonnegative final int row) {
-        final MutableInt m = new MutableInt(Integer.MIN_VALUE);
-        final MutableInt which = new MutableInt(-1);
-        matrix.eachInRow(row, new VectorProcedure() {
-            @Override
-            public void apply(int i, int value) {
-                if (value > m.getValue()) {
-                    m.setValue(value);
-                    which.setValue(i);
-                }
-            }
-        }, false);
-        return which.getValue();
-    }
-
-    /**
-     * @param data non-zero entries
-     */
-    @Nonnull
-    public static CSRMatrix coo2csr(@Nonnull final int[] rows, @Nonnull final int[] cols,
-            @Nonnull final double[] data, @Nonnegative final int numRows,
-            @Nonnegative final int numCols, final boolean sortColumns) {
-        final int nnz = data.length;
-        Preconditions.checkArgument(rows.length == nnz);
-        Preconditions.checkArgument(cols.length == nnz);
-
-        final int[] rowPointers = new int[numRows + 1];
-        final int[] colIndices = new int[nnz];
-        final double[] values = new double[nnz];
-
-        coo2csr(rows, cols, data, rowPointers, colIndices, values, numRows, numCols, nnz);
-
-        if (sortColumns) {
-            sortIndices(rowPointers, colIndices, values);
-        }
-        return new CSRMatrix(rowPointers, colIndices, values, numCols);
-    }
-
-    /**
-     * @param data non-zero entries
-     */
-    @Nonnull
-    public static CSRFloatMatrix coo2csr(@Nonnull final int[] rows, @Nonnull final int[] cols,
-            @Nonnull final float[] data, @Nonnegative final int numRows,
-            @Nonnegative final int numCols, final boolean sortColumns) {
-        final int nnz = data.length;
-        Preconditions.checkArgument(rows.length == nnz);
-        Preconditions.checkArgument(cols.length == nnz);
-
-        final int[] rowPointers = new int[numRows + 1];
-        final int[] colIndices = new int[nnz];
-        final float[] values = new float[nnz];
-
-        coo2csr(rows, cols, data, rowPointers, colIndices, values, numRows, numCols, nnz);
-
-        if (sortColumns) {
-            sortIndices(rowPointers, colIndices, values);
-        }
-        return new CSRFloatMatrix(rowPointers, colIndices, values, numCols);
-    }
-
-    @Nonnull
-    public static CSCMatrix coo2csc(@Nonnull final int[] rows, @Nonnull final int[] cols,
-            @Nonnull final double[] data, @Nonnegative final int numRows,
-            @Nonnegative final int numCols, final boolean sortRows) {
-        final int nnz = data.length;
-        Preconditions.checkArgument(rows.length == nnz);
-        Preconditions.checkArgument(cols.length == nnz);
-
-        final int[] columnPointers = new int[numCols + 1];
-        final int[] rowIndices = new int[nnz];
-        final double[] values = new double[nnz];
-
-        coo2csr(cols, rows, data, columnPointers, rowIndices, values, numCols, numRows, nnz);
-
-        if (sortRows) {
-            sortIndices(columnPointers, rowIndices, values);
-        }
-        return new CSCMatrix(columnPointers, rowIndices, values, numRows, numCols);
-    }
-
-    @Nonnull
-    public static CSCFloatMatrix coo2csc(@Nonnull final int[] rows, @Nonnull final int[] cols,
-            @Nonnull final float[] data, @Nonnegative final int numRows,
-            @Nonnegative final int numCols, final boolean sortRows) {
-        final int nnz = data.length;
-        Preconditions.checkArgument(rows.length == nnz);
-        Preconditions.checkArgument(cols.length == nnz);
-
-        final int[] columnPointers = new int[numCols + 1];
-        final int[] rowIndices = new int[nnz];
-        final float[] values = new float[nnz];
-
-        coo2csr(cols, rows, data, columnPointers, rowIndices, values, numCols, numRows, nnz);
-
-        if (sortRows) {
-            sortIndices(columnPointers, rowIndices, values);
-        }
-
-        return new CSCFloatMatrix(columnPointers, rowIndices, values, numRows, numCols);
-    }
-
-    private static void coo2csr(@Nonnull final int[] rows, @Nonnull final int[] cols,
-            @Nonnull final double[] data, @Nonnull final int[] rowPointers,
-            @Nonnull final int[] colIndices, @Nonnull final double[] values,
-            @Nonnegative final int numRows, @Nonnegative final int numCols, final int nnz) {
-        // compute nnz per for each row to get rowPointers
-        for (int n = 0; n < nnz; n++) {
-            rowPointers[rows[n]]++;
-        }
-        for (int i = 0, sum = 0; i < numRows; i++) {
-            int curr = rowPointers[i];
-            rowPointers[i] = sum;
-            sum += curr;
-        }
-        rowPointers[numRows] = nnz;
-
-        // copy cols, data to colIndices, csrValues
-        for (int n = 0; n < nnz; n++) {
-            int row = rows[n];
-            int dst = rowPointers[row];
-
-            colIndices[dst] = cols[n];
-            values[dst] = data[n];
-
-            rowPointers[row]++;
-        }
-
-        for (int i = 0, last = 0; i <= numRows; i++) {
-            int tmp = rowPointers[i];
-            rowPointers[i] = last;
-            last = tmp;
-        }
-    }
-
-    private static void coo2csr(@Nonnull final int[] rows, @Nonnull final int[] cols,
-            @Nonnull final float[] data, @Nonnull final int[] rowPointers,
-            @Nonnull final int[] colIndices, @Nonnull final float[] values,
-            @Nonnegative final int numRows, @Nonnegative final int numCols, final int nnz) {
-        // compute nnz per for each row to get rowPointers
-        for (int n = 0; n < nnz; n++) {
-            rowPointers[rows[n]]++;
-        }
-        for (int i = 0, sum = 0; i < numRows; i++) {
-            int curr = rowPointers[i];
-            rowPointers[i] = sum;
-            sum += curr;
-        }
-        rowPointers[numRows] = nnz;
-
-        // copy cols, data to colIndices, csrValues
-        for (int n = 0; n < nnz; n++) {
-            int row = rows[n];
-            int dst = rowPointers[row];
-
-            colIndices[dst] = cols[n];
-            values[dst] = data[n];
-
-            rowPointers[row]++;
-        }
-
-        for (int i = 0, last = 0; i <= numRows; i++) {
-            int tmp = rowPointers[i];
-            rowPointers[i] = last;
-            last = tmp;
-        }
-    }
-
-    private static void sortIndices(@Nonnull final int[] majorAxisPointers,
-            @Nonnull final int[] minorAxisIndices, @Nonnull final double[] values) {
-        final int numRows = majorAxisPointers.length - 1;
-        if (numRows <= 1) {
-            return;
-        }
-
-        for (int i = 0; i < numRows; i++) {
-            final int rowStart = majorAxisPointers[i];
-            final int rowEnd = majorAxisPointers[i + 1];
-
-            final int numCols = rowEnd - rowStart;
-            if (numCols == 0) {
-                continue;
-            } else if (numCols < 0) {
-                throw new IllegalArgumentException(
-                    "numCols SHOULD be greater than zero. numCols = rowEnd - rowStart = " + rowEnd
-                            + " - " + rowStart + " = " + numCols + " at i=" + i);
-            }
-
-            final IntDoublePair[] pairs = new IntDoublePair[numCols];
-            for (int jj = rowStart, n = 0; jj < rowEnd; jj++, n++) {
-                pairs[n] = new IntDoublePair(minorAxisIndices[jj], values[jj]);
-            }
-
-            Arrays.sort(pairs, new Comparator<IntDoublePair>() {
-                @Override
-                public int compare(IntDoublePair x, IntDoublePair y) {
-                    return Integer.compare(x.key, y.key);
-                }
-            });
-
-            for (int jj = rowStart, n = 0; jj < rowEnd; jj++, n++) {
-                IntDoublePair tmp = pairs[n];
-                minorAxisIndices[jj] = tmp.key;
-                values[jj] = tmp.value;
-            }
-        }
-    }
-
-    private static void sortIndices(@Nonnull final int[] majorAxisPointers,
-            @Nonnull final int[] minorAxisIndices, @Nonnull final float[] values) {
-        final int numRows = majorAxisPointers.length - 1;
-        if (numRows <= 1) {
-            return;
-        }
-
-        for (int i = 0; i < numRows; i++) {
-            final int rowStart = majorAxisPointers[i];
-            final int rowEnd = majorAxisPointers[i + 1];
-
-            final int numCols = rowEnd - rowStart;
-            if (numCols == 0) {
-                continue;
-            } else if (numCols < 0) {
-                throw new IllegalArgumentException(
-                    "numCols SHOULD be greater than or equal to zero. numCols = rowEnd - rowStart = "
-                            + rowEnd + " - " + rowStart + " = " + numCols + " at i=" + i);
-            }
-
-            final IntFloatPair[] pairs = new IntFloatPair[numCols];
-            for (int jj = rowStart, n = 0; jj < rowEnd; jj++, n++) {
-                pairs[n] = new IntFloatPair(minorAxisIndices[jj], values[jj]);
-            }
-
-            Arrays.sort(pairs, new Comparator<IntFloatPair>() {
-                @Override
-                public int compare(IntFloatPair x, IntFloatPair y) {
-                    return Integer.compare(x.key, y.key);
-                }
-            });
-
-            for (int jj = rowStart, n = 0; jj < rowEnd; jj++, n++) {
-                IntFloatPair tmp = pairs[n];
-                minorAxisIndices[jj] = tmp.key;
-                values[jj] = tmp.value;
-            }
-        }
-    }
-
-    private static final class IntDoublePair {
-
-        final int key;
-        final double value;
-
-        IntDoublePair(int key, double value) {
-            this.key = key;
-            this.value = value;
-        }
-    }
-
-    private static final class IntFloatPair {
-
-        final int key;
-        final float value;
-
-        IntFloatPair(int key, float value) {
-            this.key = key;
-            this.value = value;
-        }
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/RowMajorFloatMatrix.java b/core/src/main/java/hivemall/math/matrix/RowMajorFloatMatrix.java
deleted file mode 100644
index 7cfd98f..0000000
--- a/core/src/main/java/hivemall/math/matrix/RowMajorFloatMatrix.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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 hivemall.math.matrix;
-
-import javax.annotation.Nonnegative;
-
-public abstract class RowMajorFloatMatrix extends RowMajorMatrix implements FloatMatrix {
-
-    public RowMajorFloatMatrix() {
-        super();
-    }
-
-    @Override
-    public RowMajorFloatMatrix toRowMajorMatrix() {
-        return this;
-    }
-
-    @Override
-    public double get(@Nonnegative final int row, @Nonnegative final int col,
-            final double defaultValue) {
-        return get(row, col, (float) defaultValue);
-    }
-
-    @Override
-    public void set(@Nonnegative final int row, @Nonnegative final int col, final double value) {
-        set(row, col, (float) value);
-    }
-
-    @Override
-    public double getAndSet(@Nonnegative final int row, @Nonnegative final int col,
-            final double value) {
-        return getAndSet(row, col, (float) value);
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/RowMajorMatrix.java b/core/src/main/java/hivemall/math/matrix/RowMajorMatrix.java
deleted file mode 100644
index 2c611bd..0000000
--- a/core/src/main/java/hivemall/math/matrix/RowMajorMatrix.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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 hivemall.math.matrix;
-
-import hivemall.math.vector.Vector;
-import hivemall.math.vector.VectorProcedure;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public abstract class RowMajorMatrix extends AbstractMatrix {
-
-    public RowMajorMatrix() {
-        super();
-    }
-
-    @Override
-    public boolean isRowMajorMatrix() {
-        return true;
-    }
-
-    @Override
-    public boolean isColumnMajorMatrix() {
-        return false;
-    }
-
-    @Override
-    public void getRow(@Nonnegative final int index, @Nonnull final Vector row) {
-        row.clear();
-        eachNonNullInRow(index, new VectorProcedure() {
-            @Override
-            public void apply(final int i, final double value) {
-                row.set(i, value);
-            }
-        });
-    }
-
-    @Override
-    public void eachInColumn(int col, VectorProcedure procedure, boolean nullOutput) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void eachNonZeroInColumn(int col, VectorProcedure procedure) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public RowMajorMatrix toRowMajorMatrix() {
-        return this;
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/builders/CSCMatrixBuilder.java b/core/src/main/java/hivemall/math/matrix/builders/CSCMatrixBuilder.java
deleted file mode 100644
index ffe0cba..0000000
--- a/core/src/main/java/hivemall/math/matrix/builders/CSCMatrixBuilder.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * 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 hivemall.math.matrix.builders;
-
-import hivemall.math.matrix.sparse.CSCMatrix;
-import hivemall.utils.collections.lists.DoubleArrayList;
-import hivemall.utils.collections.lists.IntArrayList;
-
-import java.util.Arrays;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public final class CSCMatrixBuilder extends MatrixBuilder {
-
-    @Nonnull
-    private final IntArrayList rows;
-    @Nonnull
-    private final IntArrayList cols;
-    @Nonnull
-    private final DoubleArrayList values;
-
-    private int row;
-    private int maxNumColumns;
-
-    public CSCMatrixBuilder(int initSize) {
-        super();
-        this.rows = new IntArrayList(initSize);
-        this.cols = new IntArrayList(initSize);
-        this.values = new DoubleArrayList(initSize);
-        this.row = 0;
-        this.maxNumColumns = 0;
-    }
-
-    @Override
-    public CSCMatrixBuilder nextRow() {
-        row++;
-        return this;
-    }
-
-    @Override
-    public CSCMatrixBuilder nextColumn(@Nonnegative final int col, final double value) {
-        checkColIndex(col);
-
-        rows.add(row);
-        cols.add(col);
-        values.add(value);
-        this.maxNumColumns = Math.max(col + 1, maxNumColumns);
-        return this;
-    }
-
-    @Override
-    public CSCMatrix buildMatrix() {
-        if (rows.isEmpty() || cols.isEmpty()) {
-            throw new IllegalStateException("No element in the matrix");
-        }
-
-        final int[] columnIndices = cols.toArray(true);
-        final int[] rowsIndices = rows.toArray(true);
-        final double[] valuesArray = values.toArray(true);
-
-        // convert to column major
-        final int nnz = valuesArray.length;
-        SortObj[] sortObjs = new SortObj[nnz];
-        for (int i = 0; i < nnz; i++) {
-            sortObjs[i] = new SortObj(columnIndices[i], rowsIndices[i], valuesArray[i]);
-        }
-        Arrays.sort(sortObjs);
-        for (int i = 0; i < nnz; i++) {
-            columnIndices[i] = sortObjs[i].columnIndex;
-            rowsIndices[i] = sortObjs[i].rowsIndex;
-            valuesArray[i] = sortObjs[i].value;
-        }
-        sortObjs = null;
-
-        final int[] columnPointers = new int[maxNumColumns + 1];
-        int prevCol = -1;
-        for (int j = 0; j < columnIndices.length; j++) {
-            int currCol = columnIndices[j];
-            if (currCol != prevCol) {
-                columnPointers[currCol] = j;
-                prevCol = currCol;
-            }
-        }
-        columnPointers[maxNumColumns] = nnz; // nnz
-
-        return new CSCMatrix(columnPointers, rowsIndices, valuesArray, row, maxNumColumns);
-    }
-
-    private static final class SortObj implements Comparable<SortObj> {
-        final int columnIndex;
-        final int rowsIndex;
-        final double value;
-
-        SortObj(int columnIndex, int rowsIndex, double value) {
-            this.columnIndex = columnIndex;
-            this.rowsIndex = rowsIndex;
-            this.value = value;
-        }
-
-        @Override
-        public int compareTo(SortObj o) {
-            return Integer.compare(columnIndex, o.columnIndex);
-        }
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/builders/CSRMatrixBuilder.java b/core/src/main/java/hivemall/math/matrix/builders/CSRMatrixBuilder.java
deleted file mode 100644
index 83be589..0000000
--- a/core/src/main/java/hivemall/math/matrix/builders/CSRMatrixBuilder.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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 hivemall.math.matrix.builders;
-
-import hivemall.math.matrix.sparse.CSRMatrix;
-import hivemall.utils.collections.lists.DoubleArrayList;
-import hivemall.utils.collections.lists.IntArrayList;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-/**
- * Compressed Sparse Row Matrix builder.
- */
-public final class CSRMatrixBuilder extends MatrixBuilder {
-
-    @Nonnull
-    private final IntArrayList rowPointers;
-    @Nonnull
-    private final IntArrayList columnIndices;
-    @Nonnull
-    private final DoubleArrayList values;
-
-    private int maxNumColumns;
-
-    public CSRMatrixBuilder(@Nonnegative int initSize) {
-        super();
-        this.rowPointers = new IntArrayList(initSize + 1);
-        rowPointers.add(0);
-        this.columnIndices = new IntArrayList(initSize);
-        this.values = new DoubleArrayList(initSize);
-        this.maxNumColumns = 0;
-    }
-
-    @Override
-    public CSRMatrixBuilder nextRow() {
-        int ptr = values.size();
-        rowPointers.add(ptr);
-        return this;
-    }
-
-    @Override
-    public CSRMatrixBuilder nextColumn(@Nonnegative int col, double value) {
-        checkColIndex(col);
-
-        this.maxNumColumns = Math.max(col + 1, maxNumColumns);
-        if (value == 0.d) {
-            return this;
-        }
-
-        columnIndices.add(col);
-        values.add(value);
-        return this;
-    }
-
-    @Override
-    public CSRMatrix buildMatrix() {
-        CSRMatrix matrix = new CSRMatrix(rowPointers.toArray(true), columnIndices.toArray(true),
-            values.toArray(true), maxNumColumns);
-        return matrix;
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/builders/ColumnMajorDenseMatrixBuilder.java b/core/src/main/java/hivemall/math/matrix/builders/ColumnMajorDenseMatrixBuilder.java
deleted file mode 100644
index 9130efb..0000000
--- a/core/src/main/java/hivemall/math/matrix/builders/ColumnMajorDenseMatrixBuilder.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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 hivemall.math.matrix.builders;
-
-import hivemall.math.matrix.dense.ColumnMajorDenseMatrix2d;
-import hivemall.utils.collections.Fastutil;
-import hivemall.utils.collections.arrays.SparseDoubleArray;
-import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
-import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public final class ColumnMajorDenseMatrixBuilder extends MatrixBuilder {
-
-    @Nonnull
-    private final Int2ObjectMap<SparseDoubleArray> col2rows;
-    private int row;
-    private int maxNumColumns;
-    private int nnz;
-
-    public ColumnMajorDenseMatrixBuilder(int initSize) {
-        this.col2rows = new Int2ObjectOpenHashMap<SparseDoubleArray>(initSize);
-        this.row = 0;
-        this.maxNumColumns = 0;
-        this.nnz = 0;
-    }
-
-    @Override
-    public ColumnMajorDenseMatrixBuilder nextRow() {
-        row++;
-        return this;
-    }
-
-    @Override
-    public ColumnMajorDenseMatrixBuilder nextColumn(@Nonnegative final int col,
-            final double value) {
-        checkColIndex(col);
-
-        this.maxNumColumns = Math.max(col + 1, maxNumColumns);
-        if (value == 0.d) {
-            return this;
-        }
-
-        SparseDoubleArray rows = col2rows.get(col);
-        if (rows == null) {
-            rows = new SparseDoubleArray(4);
-            col2rows.put(col, rows);
-        }
-        rows.put(row, value);
-        nnz++;
-        return this;
-    }
-
-    @Override
-    public ColumnMajorDenseMatrix2d buildMatrix() {
-        final double[][] data = new double[maxNumColumns][];
-
-        for (Int2ObjectMap.Entry<SparseDoubleArray> e : Fastutil.fastIterable(col2rows)) {
-            int col = e.getIntKey();
-            SparseDoubleArray rows = e.getValue();
-            data[col] = rows.toArray();
-        }
-
-        return new ColumnMajorDenseMatrix2d(data, row, nnz);
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/builders/DoKMatrixBuilder.java b/core/src/main/java/hivemall/math/matrix/builders/DoKMatrixBuilder.java
deleted file mode 100644
index f6e9781..0000000
--- a/core/src/main/java/hivemall/math/matrix/builders/DoKMatrixBuilder.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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 hivemall.math.matrix.builders;
-
-import hivemall.math.matrix.sparse.DoKMatrix;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public final class DoKMatrixBuilder extends MatrixBuilder {
-
-    @Nonnull
-    private final DoKMatrix matrix;
-
-    private int row;
-
-    public DoKMatrixBuilder(@Nonnegative int initSize) {
-        super();
-        this.row = 0;
-        this.matrix = new DoKMatrix(initSize);
-    }
-
-    @Override
-    public DoKMatrixBuilder nextRow() {
-        row++;
-        return this;
-    }
-
-    @Override
-    public DoKMatrixBuilder nextColumn(@Nonnegative final int col, final double value) {
-        checkColIndex(col);
-
-        matrix.set(row, col, value);
-        return this;
-    }
-
-    @Override
-    public DoKMatrix buildMatrix() {
-        return matrix;
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/builders/MatrixBuilder.java b/core/src/main/java/hivemall/math/matrix/builders/MatrixBuilder.java
deleted file mode 100644
index 5b10c43..0000000
--- a/core/src/main/java/hivemall/math/matrix/builders/MatrixBuilder.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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 hivemall.math.matrix.builders;
-
-import hivemall.math.matrix.Matrix;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public abstract class MatrixBuilder {
-
-    public MatrixBuilder() {}
-
-    protected static final void checkColIndex(final int col) {
-        if (col < 0) {
-            throw new IllegalArgumentException("Found negative column index: " + col);
-        }
-    }
-
-    public void nextRow(@Nonnull final double[] row) {
-        for (int col = 0; col < row.length; col++) {
-            nextColumn(col, row[col]);
-        }
-        nextRow();
-    }
-
-    public void nextRow(@Nonnull final String[] row) {
-        for (String col : row) {
-            if (col == null) {
-                continue;
-            }
-            nextColumn(col);
-        }
-        nextRow();
-    }
-
-    @Nonnull
-    public abstract MatrixBuilder nextRow();
-
-    @Nonnull
-    public abstract MatrixBuilder nextColumn(@Nonnegative int col, double value);
-
-    /**
-     * @throws IllegalArgumentException
-     * @throws NumberFormatException
-     */
-    @Nonnull
-    public MatrixBuilder nextColumn(@Nonnull final String col) {
-        final int pos = col.indexOf(':');
-        if (pos == 0) {
-            throw new IllegalArgumentException("Invalid feature value representation: " + col);
-        }
-
-        final String feature;
-        final double value;
-        if (pos > 0) {
-            feature = col.substring(0, pos);
-            String s2 = col.substring(pos + 1);
-            value = Double.parseDouble(s2);
-        } else {
-            feature = col;
-            value = 1.d;
-        }
-
-        if (feature.indexOf(':') != -1) {
-            throw new IllegalArgumentException("Invalid feature format `<index>:<value>`: " + col);
-        }
-
-        int colIndex = Integer.parseInt(feature);
-        if (colIndex < 0) {
-            throw new IllegalArgumentException(
-                "Col index MUST be greater than or equals to 0: " + colIndex);
-        }
-
-        return nextColumn(colIndex, value);
-    }
-
-    @Nonnull
-    public abstract Matrix buildMatrix();
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/builders/RowMajorDenseMatrixBuilder.java b/core/src/main/java/hivemall/math/matrix/builders/RowMajorDenseMatrixBuilder.java
deleted file mode 100644
index 5b32101..0000000
--- a/core/src/main/java/hivemall/math/matrix/builders/RowMajorDenseMatrixBuilder.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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 hivemall.math.matrix.builders;
-
-import hivemall.math.matrix.dense.RowMajorDenseMatrix2d;
-import hivemall.utils.collections.arrays.SparseDoubleArray;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public final class RowMajorDenseMatrixBuilder extends MatrixBuilder {
-
-    @Nonnull
-    private final List<double[]> rows;
-    private int maxNumColumns;
-    private int nnz;
-
-    @Nonnull
-    private final SparseDoubleArray rowProbe;
-
-    public RowMajorDenseMatrixBuilder(@Nonnegative int initSize) {
-        super();
-        this.rows = new ArrayList<double[]>(initSize);
-        this.maxNumColumns = 0;
-        this.nnz = 0;
-        this.rowProbe = new SparseDoubleArray(32);
-    }
-
-    @Override
-    public RowMajorDenseMatrixBuilder nextColumn(@Nonnegative final int col, final double value) {
-        checkColIndex(col);
-
-        this.maxNumColumns = Math.max(col + 1, maxNumColumns);
-        if (value == 0.d) {
-            return this;
-        }
-        rowProbe.put(col, value);
-        nnz++;
-        return this;
-    }
-
-    @Override
-    public RowMajorDenseMatrixBuilder nextRow() {
-        double[] row = rowProbe.toArray();
-        rowProbe.clear();
-        rows.add(row);
-        //this.maxNumColumns = Math.max(row.length, maxNumColumns);
-        return this;
-    }
-
-    @Override
-    public void nextRow(@Nonnull double[] row) {
-        for (double v : row) {
-            if (v != 0.d) {
-                nnz++;
-            }
-        }
-        rows.add(row);
-        this.maxNumColumns = Math.max(row.length, maxNumColumns);
-    }
-
-    @Override
-    public RowMajorDenseMatrix2d buildMatrix() {
-        int numRows = rows.size();
-        double[][] data = rows.toArray(new double[numRows][]);
-        return new RowMajorDenseMatrix2d(data, maxNumColumns, nnz);
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/dense/ColumnMajorDenseMatrix2d.java b/core/src/main/java/hivemall/math/matrix/dense/ColumnMajorDenseMatrix2d.java
deleted file mode 100644
index 2c5fd45..0000000
--- a/core/src/main/java/hivemall/math/matrix/dense/ColumnMajorDenseMatrix2d.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * 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 hivemall.math.matrix.dense;
-
-import hivemall.math.matrix.ColumnMajorMatrix;
-import hivemall.math.matrix.builders.ColumnMajorDenseMatrixBuilder;
-import hivemall.math.vector.Vector;
-import hivemall.math.vector.VectorProcedure;
-import hivemall.utils.lang.Preconditions;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-/**
- * Fixed-size Dense 2-d double Matrix.
- */
-public final class ColumnMajorDenseMatrix2d extends ColumnMajorMatrix {
-
-    @Nonnull
-    private final double[][] data; // col-row
-
-    @Nonnegative
-    private final int numRows;
-    @Nonnegative
-    private final int numColumns;
-    @Nonnegative
-    private int nnz;
-
-    public ColumnMajorDenseMatrix2d(@Nonnull double[][] data, @Nonnegative int numRows) {
-        this(data, numRows, nnz(data));
-    }
-
-    public ColumnMajorDenseMatrix2d(@Nonnull double[][] data, @Nonnegative int numRows,
-            @Nonnegative int nnz) {
-        super();
-        this.data = data;
-        this.numRows = numRows;
-        this.numColumns = data.length;
-        this.nnz = nnz;
-    }
-
-    @Override
-    public boolean isSparse() {
-        return false;
-    }
-
-    @Override
-    public boolean readOnly() {
-        return true;
-    }
-
-    @Override
-    public boolean swappable() {
-        return false;
-    }
-
-    @Override
-    public int nnz() {
-        return nnz;
-    }
-
-    @Override
-    public int numRows() {
-        return numRows;
-    }
-
-    @Override
-    public int numColumns() {
-        return numColumns;
-    }
-
-    @Override
-    public int numColumns(final int row) {
-        checkRowIndex(row, numRows);
-
-        int numColumns = 0;
-        for (int j = 0; j < data.length; j++) {
-            final double[] col = data[j];
-            if (col == null) {
-                continue;
-            }
-            if (row < col.length && col[row] != 0.d) {
-                numColumns++;
-            }
-        }
-        return numColumns;
-    }
-
-    @Override
-    public double[] getRow(final int index) {
-        checkRowIndex(index, numRows);
-
-        double[] row = new double[numColumns];
-        return getRow(index, row);
-    }
-
-    @Override
-    public double[] getRow(final int index, @Nonnull final double[] dst) {
-        checkRowIndex(index, numRows);
-
-        for (int j = 0; j < data.length; j++) {
-            final double[] col = data[j];
-            if (col == null) {
-                continue;
-            }
-            if (index < col.length) {
-                dst[j] = col[index];
-            }
-        }
-        return dst;
-    }
-
-    @Override
-    public void getRow(final int index, @Nonnull final Vector row) {
-        checkRowIndex(index, numRows);
-        row.clear();
-
-        for (int j = 0; j < data.length; j++) {
-            final double[] col = data[j];
-            if (col == null) {
-                continue;
-            }
-            if (index < col.length) {
-                double v = col[index];
-                row.set(j, v);
-            }
-        }
-    }
-
-    @Override
-    public double get(final int row, final int col, final double defaultValue) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final double[] colData = data[col];
-        if (colData == null || row >= colData.length) {
-            return defaultValue;
-        }
-        return colData[row];
-    }
-
-    @Override
-    public double getAndSet(final int row, final int col, final double value) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final double[] colData = data[col];
-        Preconditions.checkNotNull(colData, "col does not exists: " + col);
-        checkRowIndex(row, colData.length);
-
-        final double old = colData[row];
-        colData[row] = value;
-        if (old == 0.d && value != 0.d) {
-            ++nnz;
-        }
-        return old;
-    }
-
-    @Override
-    public void set(final int row, final int col, final double value) {
-        checkIndex(row, col, numRows, numColumns);
-        if (value == 0.d) {
-            return;
-        }
-
-        final double[] colData = data[col];
-        Preconditions.checkNotNull(colData, "col does not exists: " + col);
-        checkRowIndex(row, colData.length);
-
-        if (colData[row] == 0.d) {
-            ++nnz;
-        }
-        colData[row] = value;
-    }
-
-    @Override
-    public void swap(int row1, int row2) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void eachInColumn(final int col, @Nonnull final VectorProcedure procedure,
-            final boolean nullOutput) {
-        checkColIndex(col, numColumns);
-
-        final double[] colData = data[col];
-        if (colData == null) {
-            if (nullOutput) {
-                for (int i = 0; i < numRows; i++) {
-                    procedure.apply(i, 0.d);
-                }
-            }
-            return;
-        }
-
-        int row = 0;
-        for (int len = colData.length; row < len; row++) {
-            procedure.apply(row, colData[row]);
-        }
-        if (nullOutput) {
-            for (; row < numRows; row++) {
-                procedure.apply(row, 0.d);
-            }
-        }
-    }
-
-    @Override
-    public void eachNonZeroInColumn(final int col, @Nonnull final VectorProcedure procedure) {
-        checkColIndex(col, numColumns);
-
-        final double[] colData = data[col];
-        if (colData == null) {
-            return;
-        }
-        int row = 0;
-        for (int len = colData.length; row < len; row++) {
-            final double v = colData[row];
-            if (v != 0.d) {
-                procedure.apply(row, v);
-            }
-        }
-    }
-
-    @Override
-    public RowMajorDenseMatrix2d toRowMajorMatrix() {
-        final double[][] rowcol = new double[numRows][numColumns];
-        int nnz = 0;
-        for (int j = 0; j < data.length; j++) {
-            final double[] colData = data[j];
-            if (colData == null) {
-                continue;
-            }
-            for (int i = 0; i < colData.length; i++) {
-                final double v = colData[i];
-                if (v == 0.d) {
-                    continue;
-                }
-                rowcol[i][j] = v;
-                nnz++;
-            }
-        }
-        for (int i = 0; i < rowcol.length; i++) {
-            final double[] row = rowcol[i];
-            final int last = numColumns - 1;
-            int maxj = last;
-            for (; maxj >= 0; maxj--) {
-                if (row[maxj] != 0.d) {
-                    break;
-                }
-            }
-            if (maxj == last) {
-                continue;
-            } else if (maxj < 0) {
-                rowcol[i] = null;
-                continue;
-            }
-            final double[] dstRow = new double[maxj + 1];
-            System.arraycopy(row, 0, dstRow, 0, dstRow.length);
-            rowcol[i] = dstRow;
-        }
-
-        return new RowMajorDenseMatrix2d(rowcol, numColumns, nnz);
-    }
-
-    @Override
-    public ColumnMajorDenseMatrixBuilder builder() {
-        return new ColumnMajorDenseMatrixBuilder(numColumns);
-    }
-
-    private static int nnz(@Nonnull final double[][] data) {
-        int count = 0;
-        for (int j = 0; j < data.length; j++) {
-            final double[] col = data[j];
-            if (col == null) {
-                continue;
-            }
-            for (int i = 0; i < col.length; i++) {
-                if (col[i] != 0.d) {
-                    ++count;
-                }
-            }
-        }
-        return count;
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/dense/RowMajorDenseMatrix2d.java b/core/src/main/java/hivemall/math/matrix/dense/RowMajorDenseMatrix2d.java
deleted file mode 100644
index 54302e1..0000000
--- a/core/src/main/java/hivemall/math/matrix/dense/RowMajorDenseMatrix2d.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- * 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 hivemall.math.matrix.dense;
-
-import hivemall.math.matrix.RowMajorMatrix;
-import hivemall.math.matrix.builders.RowMajorDenseMatrixBuilder;
-import hivemall.math.vector.DenseVector;
-import hivemall.math.vector.VectorProcedure;
-import hivemall.utils.lang.Preconditions;
-
-import java.util.Arrays;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-/**
- * Fixed-size Dense 2-d double Matrix.
- */
-public final class RowMajorDenseMatrix2d extends RowMajorMatrix {
-
-    @Nonnull
-    private final double[][] data;
-
-    @Nonnegative
-    private final int numRows;
-    @Nonnegative
-    private final int numColumns;
-    @Nonnegative
-    private int nnz;
-
-    public RowMajorDenseMatrix2d(@Nonnull double[][] data, @Nonnegative int numColumns) {
-        this(data, numColumns, nnz(data));
-    }
-
-    public RowMajorDenseMatrix2d(@Nonnull double[][] data, @Nonnegative int numColumns,
-            @Nonnegative int nnz) {
-        super();
-        this.data = data;
-        this.numRows = data.length;
-        this.numColumns = numColumns;
-        this.nnz = nnz;
-    }
-
-    @Override
-    public boolean isSparse() {
-        return false;
-    }
-
-    @Override
-    public boolean readOnly() {
-        return true;
-    }
-
-    @Override
-    public boolean swappable() {
-        return true;
-    }
-
-    @Override
-    public int nnz() {
-        return nnz;
-    }
-
-    @Override
-    public int numRows() {
-        return numRows;
-    }
-
-    @Override
-    public int numColumns() {
-        return numColumns;
-    }
-
-    @Override
-    public int numColumns(@Nonnegative final int row) {
-        checkRowIndex(row, numRows);
-
-        final double[] r = data[row];
-        if (r == null) {
-            return 0;
-        }
-        return r.length;
-    }
-
-    @Override
-    public DenseVector rowVector() {
-        return new DenseVector(numColumns);
-    }
-
-    @Override
-    public double[] getRow(@Nonnegative final int index) {
-        checkRowIndex(index, numRows);
-
-        final double[] row = data[index];
-        if (row == null) {
-            return new double[0];
-        } else if (row.length == numRows) {
-            return row;
-        }
-
-        final double[] result = new double[numRows];
-        System.arraycopy(row, 0, result, 0, row.length);
-        return result;
-    }
-
-    @Override
-    public double[] getRow(@Nonnull final int index, @Nonnull final double[] dst) {
-        checkRowIndex(index, numRows);
-
-        final double[] row = data[index];
-        if (row == null) {
-            return new double[0];
-        }
-
-        System.arraycopy(row, 0, dst, 0, row.length);
-        if (dst.length > row.length) {// zerofill
-            Arrays.fill(dst, row.length, dst.length, 0.d);
-        }
-        return dst;
-    }
-
-    @Override
-    public double get(@Nonnegative final int row, @Nonnegative final int col,
-            final double defaultValue) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final double[] rowData = data[row];
-        if (rowData == null || col >= rowData.length) {
-            return defaultValue;
-        }
-        return rowData[col];
-    }
-
-    @Override
-    public double getAndSet(@Nonnegative final int row, @Nonnegative final int col,
-            final double value) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final double[] rowData = data[row];
-        Preconditions.checkNotNull(rowData, "row does not exists: " + row);
-        checkColIndex(col, rowData.length);
-
-        double old = rowData[col];
-        rowData[col] = value;
-        if (old == 0.d && value != 0.d) {
-            ++nnz;
-        }
-        return old;
-    }
-
-    @Override
-    public void set(@Nonnegative final int row, @Nonnegative final int col, final double value) {
-        checkIndex(row, col, numRows, numColumns);
-        if (value == 0.d) {
-            return;
-        }
-
-        final double[] rowData = data[row];
-        Preconditions.checkNotNull(rowData, "row does not exists: " + row);
-        checkColIndex(col, rowData.length);
-
-        if (rowData[col] == 0.d) {
-            ++nnz;
-        }
-        rowData[col] = value;
-    }
-
-    @Override
-    public void swap(@Nonnegative final int row1, @Nonnegative final int row2) {
-        checkRowIndex(row1, numRows);
-        checkRowIndex(row2, numRows);
-
-        double[] oldRow1 = data[row1];
-        data[row1] = data[row2];
-        data[row2] = oldRow1;
-    }
-
-    @Override
-    public void eachInRow(@Nonnegative final int row, @Nonnull final VectorProcedure procedure,
-            final boolean nullOutput) {
-        checkRowIndex(row, numRows);
-
-        final double[] rowData = data[row];
-        if (rowData == null) {
-            if (nullOutput) {
-                for (int j = 0; j < numColumns; j++) {
-                    procedure.apply(j, 0.d);
-                }
-            }
-            return;
-        }
-
-        int col = 0;
-        for (int len = rowData.length; col < len; col++) {
-            procedure.apply(col, rowData[col]);
-        }
-        if (nullOutput) {
-            for (; col < numColumns; col++) {
-                procedure.apply(col, 0.d);
-            }
-        }
-    }
-
-    @Override
-    public void eachNonZeroInRow(@Nonnegative final int row,
-            @Nonnull final VectorProcedure procedure) {
-        checkRowIndex(row, numRows);
-
-        final double[] rowData = data[row];
-        if (rowData == null) {
-            return;
-        }
-        for (int col = 0, len = rowData.length; col < len; col++) {
-            final double v = rowData[col];
-            if (v != 0.d) {
-                procedure.apply(col, v);
-            }
-        }
-    }
-
-    @Override
-    public void eachColumnIndexInRow(@Nonnegative final int row,
-            @Nonnull final VectorProcedure procedure) {
-        checkRowIndex(row, numRows);
-
-        final double[] rowData = data[row];
-        if (rowData == null) {
-            return;
-        }
-        for (int col = 0, len = rowData.length; col < len; col++) {
-            procedure.apply(col);
-        }
-    }
-
-    @Override
-    public void eachInColumn(@Nonnegative final int col, @Nonnull final VectorProcedure procedure,
-            final boolean nullOutput) {
-        checkColIndex(col, numColumns);
-
-        for (int row = 0; row < numRows; row++) {
-            final double[] rowData = data[row];
-            if (rowData != null && col < rowData.length) {
-                procedure.apply(row, rowData[col]);
-            } else {
-                if (nullOutput) {
-                    procedure.apply(row, 0.d);
-                }
-            }
-        }
-    }
-
-    @Override
-    public void eachNonZeroInColumn(@Nonnegative final int col,
-            @Nonnull final VectorProcedure procedure) {
-        checkColIndex(col, numColumns);
-
-        for (int row = 0; row < numRows; row++) {
-            final double[] rowData = data[row];
-            if (rowData == null) {
-                continue;
-            }
-            if (col < rowData.length) {
-                final double v = rowData[col];
-                if (v != 0.d) {
-                    procedure.apply(row, v);
-                }
-            }
-        }
-    }
-
-    @Override
-    public ColumnMajorDenseMatrix2d toColumnMajorMatrix() {
-        final double[][] colrow = new double[numColumns][numRows];
-        int nnz = 0;
-        for (int i = 0; i < data.length; i++) {
-            final double[] rowData = data[i];
-            if (rowData == null) {
-                continue;
-            }
-            for (int j = 0; j < rowData.length; j++) {
-                final double v = rowData[j];
-                if (v == 0.d) {
-                    continue;
-                }
-                colrow[j][i] = v;
-                nnz++;
-            }
-        }
-        for (int j = 0; j < colrow.length; j++) {
-            final double[] col = colrow[j];
-            final int last = numRows - 1;
-            int maxi = last;
-            for (; maxi >= 0; maxi--) {
-                if (col[maxi] != 0.d) {
-                    break;
-                }
-            }
-            if (maxi == last) {
-                continue;
-            } else if (maxi < 0) {
-                colrow[j] = null;
-                continue;
-            }
-            final double[] dstCol = new double[maxi + 1];
-            System.arraycopy(col, 0, dstCol, 0, dstCol.length);
-            colrow[j] = dstCol;
-        }
-
-        return new ColumnMajorDenseMatrix2d(colrow, numRows, nnz);
-    }
-
-    @Override
-    public RowMajorDenseMatrixBuilder builder() {
-        return new RowMajorDenseMatrixBuilder(numRows);
-    }
-
-    private static int nnz(@Nonnull final double[][] data) {
-        int count = 0;
-        for (int i = 0; i < data.length; i++) {
-            final double[] row = data[i];
-            if (row == null) {
-                continue;
-            }
-            for (int j = 0; j < row.length; j++) {
-                if (row[j] != 0.d) {
-                    ++count;
-                }
-            }
-        }
-        return count;
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/ints/AbstractIntMatrix.java b/core/src/main/java/hivemall/math/matrix/ints/AbstractIntMatrix.java
deleted file mode 100644
index eedd616..0000000
--- a/core/src/main/java/hivemall/math/matrix/ints/AbstractIntMatrix.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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 hivemall.math.matrix.ints;
-
-import hivemall.math.vector.VectorProcedure;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public abstract class AbstractIntMatrix implements IntMatrix {
-
-    protected int defaultValue;
-
-    public AbstractIntMatrix() {
-        this.defaultValue = 0;
-    }
-
-    @Override
-    public void setDefaultValue(int value) {
-        this.defaultValue = value;
-    }
-
-    @Override
-    public int[] row() {
-        int size = numRows();
-        return new int[size];
-    }
-
-    @Override
-    public final int get(@Nonnegative final int row, @Nonnegative final int col) {
-        return get(row, col, defaultValue);
-    }
-
-    @Override
-    public void incr(@Nonnegative final int row, @Nonnegative final int col) {
-        incr(row, col, 1);
-    }
-
-    protected static final void checkRowIndex(final int row, final int numRows) {
-        if (row < 0 || row >= numRows) {
-            throw new IndexOutOfBoundsException("Row index " + row + " out of bounds " + numRows);
-        }
-    }
-
-    protected static final void checkColIndex(final int col, final int numColumns) {
-        if (col < 0 || col >= numColumns) {
-            throw new IndexOutOfBoundsException(
-                "Col index " + col + " out of bounds " + numColumns);
-        }
-    }
-
-    protected static final void checkIndex(final int index) {
-        if (index < 0) {
-            throw new IllegalArgumentException("Invalid index: " + index);
-        }
-    }
-
-    protected static final void checkIndex(final int row, final int col) {
-        if (row < 0) {
-            throw new IllegalArgumentException("Invalid row index: " + row);
-        }
-        if (col < 0) {
-            throw new IllegalArgumentException("Invalid col index: " + col);
-        }
-    }
-
-    protected static final void checkIndex(final int row, final int col, final int numRows,
-            final int numColumns) {
-        if (row < 0 || row >= numRows) {
-            throw new IndexOutOfBoundsException("Row index " + row + " out of bounds " + numRows);
-        }
-        if (col < 0 || col >= numColumns) {
-            throw new IndexOutOfBoundsException(
-                "Col index " + col + " out of bounds " + numColumns);
-        }
-    }
-
-    protected static void rangeCheck(final int length, final int fromIndex, final int toIndex) {
-        if (fromIndex > toIndex) {
-            throw new IllegalArgumentException(
-                "fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")");
-        }
-        if (fromIndex < 0) {
-            throw new ArrayIndexOutOfBoundsException(fromIndex);
-        }
-        if (toIndex > length) {
-            throw new ArrayIndexOutOfBoundsException(toIndex);
-        }
-    }
-
-    @Override
-    public void eachInRow(final int row, @Nonnull final VectorProcedure procedure) {
-        eachInRow(row, procedure, true);
-    }
-
-    @Override
-    public void eachInColumn(final int col, @Nonnull final VectorProcedure procedure) {
-        eachInColumn(col, procedure, true);
-    }
-
-    @Override
-    public void eachNonNullInRow(final int row, @Nonnull final VectorProcedure procedure) {
-        eachInRow(row, procedure, false);
-    }
-
-    @Override
-    public void eachNonNullInColumn(final int col, @Nonnull final VectorProcedure procedure) {
-        eachInColumn(col, procedure, false);
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/ints/ColumnMajorDenseIntMatrix2d.java b/core/src/main/java/hivemall/math/matrix/ints/ColumnMajorDenseIntMatrix2d.java
deleted file mode 100644
index bd45481..0000000
--- a/core/src/main/java/hivemall/math/matrix/ints/ColumnMajorDenseIntMatrix2d.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * 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 hivemall.math.matrix.ints;
-
-import hivemall.math.vector.VectorProcedure;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public final class ColumnMajorDenseIntMatrix2d extends ColumnMajorIntMatrix {
-
-    @Nonnull
-    private final int[][] data; // col-row
-
-    @Nonnegative
-    private final int numRows;
-    @Nonnegative
-    private final int numColumns;
-
-    public ColumnMajorDenseIntMatrix2d(@Nonnull int[][] data, @Nonnegative int numRows) {
-        super();
-        this.data = data;
-        this.numRows = numRows;
-        this.numColumns = data.length;
-    }
-
-    @Override
-    public boolean isSparse() {
-        return false;
-    }
-
-    @Override
-    public boolean readOnly() {
-        return true;
-    }
-
-    @Override
-    public int numRows() {
-        return numRows;
-    }
-
-    @Override
-    public int numColumns() {
-        return numColumns;
-    }
-
-    @Override
-    public int[] getRow(final int index) {
-        checkRowIndex(index, numRows);
-
-        int[] row = new int[numColumns];
-        return getRow(index, row);
-    }
-
-    @Override
-    public int[] getRow(final int index, @Nonnull final int[] dst) {
-        checkRowIndex(index, numRows);
-
-        for (int j = 0; j < data.length; j++) {
-            final int[] col = data[j];
-            if (index < col.length) {
-                dst[j] = col[index];
-            }
-        }
-        return dst;
-    }
-
-    @Override
-    public int get(final int row, final int col, final int defaultValue) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final int[] colData = data[col];
-        if (row >= colData.length) {
-            return defaultValue;
-        }
-        return colData[row];
-    }
-
-    @Override
-    public int getAndSet(final int row, final int col, final int value) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final int[] colData = data[col];
-        checkRowIndex(row, colData.length);
-
-        final int old = colData[row];
-        colData[row] = value;
-        return old;
-    }
-
-    @Override
-    public void set(final int row, final int col, final int value) {
-        checkIndex(row, col, numRows, numColumns);
-        if (value == 0) {
-            return;
-        }
-
-        final int[] colData = data[col];
-        checkRowIndex(row, colData.length);
-        colData[row] = value;
-    }
-
-    @Override
-    public void incr(final int row, final int col, final int delta) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final int[] colData = data[col];
-        checkRowIndex(row, colData.length);
-
-        colData[row] += delta;
-    }
-
-    @Override
-    public void eachInColumn(final int col, @Nonnull final VectorProcedure procedure,
-            final boolean nullOutput) {
-        checkColIndex(col, numColumns);
-
-        final int[] colData = data[col];
-        if (colData == null) {
-            if (nullOutput) {
-                for (int i = 0; i < numRows; i++) {
-                    procedure.apply(i, defaultValue);
-                }
-            }
-            return;
-        }
-
-        int row = 0;
-        for (int len = colData.length; row < len; row++) {
-            procedure.apply(row, colData[row]);
-        }
-        if (nullOutput) {
-            for (; row < numRows; row++) {
-                procedure.apply(row, defaultValue);
-            }
-        }
-    }
-
-    @Override
-    public void eachNonZeroInColumn(final int col, @Nonnull final VectorProcedure procedure) {
-        checkColIndex(col, numColumns);
-
-        final int[] colData = data[col];
-        if (colData == null) {
-            return;
-        }
-        int row = 0;
-        for (int len = colData.length; row < len; row++) {
-            final int v = colData[row];
-            if (v != 0) {
-                procedure.apply(row, v);
-            }
-        }
-    }
-
-    @Override
-    public void eachNonNullInColumn(final int col, final int startRow, final int endRow,
-            @Nonnull final VectorProcedure procedure) {
-        checkColIndex(col, numColumns);
-        rangeCheck(numRows, startRow, endRow);
-
-        final int[] colData = data[col];
-        if (colData == null) {
-            return;
-        }
-
-        for (int row = startRow, end = Math.min(endRow, colData.length); row < end; row++) {
-            procedure.apply(row, colData[row]);
-        }
-    }
-
-    @Override
-    public void eachRow(@Nonnull final VectorProcedure procedure) {
-        for (int col = 0; col < data.length; col++) {
-            final int[] row = data[col];
-            if (row == null) {
-                continue;
-            }
-            procedure.apply(col, row);
-        }
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/ints/ColumnMajorIntMatrix.java b/core/src/main/java/hivemall/math/matrix/ints/ColumnMajorIntMatrix.java
deleted file mode 100644
index ff230a2..0000000
--- a/core/src/main/java/hivemall/math/matrix/ints/ColumnMajorIntMatrix.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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 hivemall.math.matrix.ints;
-
-import hivemall.math.vector.VectorProcedure;
-
-import javax.annotation.Nonnull;
-
-public abstract class ColumnMajorIntMatrix extends AbstractIntMatrix {
-
-    public ColumnMajorIntMatrix() {
-        super();
-    }
-
-    @Override
-    public void eachInRow(int row, VectorProcedure procedure, boolean nullOutput) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void eachNonZeroInRow(int row, VectorProcedure procedure) {
-        throw new UnsupportedOperationException();
-    }
-
-    public abstract void eachNonNullInColumn(final int col, final int startRow, final int endRow,
-            @Nonnull final VectorProcedure procedure);
-
-    public abstract void eachRow(@Nonnull final VectorProcedure procedure);
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/ints/DoKIntMatrix.java b/core/src/main/java/hivemall/math/matrix/ints/DoKIntMatrix.java
deleted file mode 100644
index 5feb423..0000000
--- a/core/src/main/java/hivemall/math/matrix/ints/DoKIntMatrix.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * 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 hivemall.math.matrix.ints;
-
-import hivemall.math.vector.VectorProcedure;
-import hivemall.utils.collections.maps.Long2IntOpenHashTable;
-import hivemall.utils.lang.Preconditions;
-import hivemall.utils.lang.Primitives;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-/**
- * Dictionary-of-Key Sparse Int Matrix.
- */
-public final class DoKIntMatrix extends AbstractIntMatrix {
-
-    @Nonnull
-    private final Long2IntOpenHashTable elements;
-    @Nonnegative
-    private int numRows;
-    @Nonnegative
-    private int numColumns;
-
-    public DoKIntMatrix() {
-        this(0, 0);
-    }
-
-    public DoKIntMatrix(@Nonnegative int numRows, @Nonnegative int numCols) {
-        this(numRows, numCols, 0.05f);
-    }
-
-    public DoKIntMatrix(@Nonnegative int numRows, @Nonnegative int numCols,
-            @Nonnegative float sparsity) {
-        Preconditions.checkArgument(sparsity >= 0.f && sparsity <= 1.f,
-            "Invalid Sparsity value: " + sparsity);
-        int initialCapacity = Math.max(16384, Math.round(numRows * numCols * sparsity));
-        this.elements = new Long2IntOpenHashTable(initialCapacity);
-        this.numRows = numRows;
-        this.numColumns = numCols;
-    }
-
-    private DoKIntMatrix(@Nonnull Long2IntOpenHashTable elements, @Nonnegative int numRows,
-            @Nonnegative int numColumns) {
-        this.elements = elements;
-        this.numRows = numRows;
-        this.numColumns = numColumns;
-    }
-
-    @Override
-    public boolean isSparse() {
-        return true;
-    }
-
-    @Override
-    public boolean readOnly() {
-        return false;
-    }
-
-    @Override
-    public int numRows() {
-        return numRows;
-    }
-
-    @Override
-    public int numColumns() {
-        return numColumns;
-    }
-
-    @Override
-    public int[] getRow(@Nonnegative final int index) {
-        int[] dst = row();
-        return getRow(index, dst);
-    }
-
-    @Override
-    public int[] getRow(@Nonnegative final int row, @Nonnull final int[] dst) {
-        checkRowIndex(row, numRows);
-
-        final int end = Math.min(dst.length, numColumns);
-        for (int col = 0; col < end; col++) {
-            long index = index(row, col);
-            int v = elements.get(index, defaultValue);
-            dst[col] = v;
-        }
-
-        return dst;
-    }
-
-    @Override
-    public int get(@Nonnegative final int row, @Nonnegative final int col, final int defaultValue) {
-        checkIndex(row, col, numRows, numColumns);
-
-        long index = index(row, col);
-        return elements.get(index, defaultValue);
-    }
-
-    @Override
-    public void set(@Nonnegative final int row, @Nonnegative final int col, final int value) {
-        checkIndex(row, col);
-
-        long index = index(row, col);
-        elements.put(index, value);
-        this.numRows = Math.max(numRows, row + 1);
-        this.numColumns = Math.max(numColumns, col + 1);
-    }
-
-    @Override
-    public int getAndSet(@Nonnegative final int row, @Nonnegative final int col, final int value) {
-        checkIndex(row, col);
-
-        long index = index(row, col);
-        int old = elements.put(index, value);
-        this.numRows = Math.max(numRows, row + 1);
-        this.numColumns = Math.max(numColumns, col + 1);
-        return old;
-    }
-
-    @Override
-    public void incr(@Nonnegative final int row, @Nonnegative final int col, final int delta) {
-        checkIndex(row, col);
-
-        long index = index(row, col);
-        elements.incr(index, delta);
-        this.numRows = Math.max(numRows, row + 1);
-        this.numColumns = Math.max(numColumns, col + 1);
-    }
-
-    @Override
-    public void eachInRow(@Nonnegative final int row, @Nonnull final VectorProcedure procedure,
-            final boolean nullOutput) {
-        checkRowIndex(row, numRows);
-
-        for (int col = 0; col < numColumns; col++) {
-            long i = index(row, col);
-            final int key = elements._findKey(i);
-            if (key < 0) {
-                if (nullOutput) {
-                    procedure.apply(col, defaultValue);
-                }
-            } else {
-                int v = elements._get(key);
-                procedure.apply(col, v);
-            }
-        }
-    }
-
-    @Override
-    public void eachNonZeroInRow(@Nonnegative final int row,
-            @Nonnull final VectorProcedure procedure) {
-        checkRowIndex(row, numRows);
-
-        for (int col = 0; col < numColumns; col++) {
-            long i = index(row, col);
-            final int v = elements.get(i, 0);
-            if (v != 0) {
-                procedure.apply(col, v);
-            }
-        }
-    }
-
-    @Override
-    public void eachInColumn(@Nonnegative final int col, @Nonnull final VectorProcedure procedure,
-            final boolean nullOutput) {
-        checkColIndex(col, numColumns);
-
-        for (int row = 0; row < numRows; row++) {
-            long i = index(row, col);
-            final int key = elements._findKey(i);
-            if (key < 0) {
-                if (nullOutput) {
-                    procedure.apply(row, defaultValue);
-                }
-            } else {
-                int v = elements._get(key);
-                procedure.apply(row, v);
-            }
-        }
-    }
-
-    @Override
-    public void eachNonZeroInColumn(@Nonnegative final int col,
-            @Nonnull final VectorProcedure procedure) {
-        checkColIndex(col, numColumns);
-
-        for (int row = 0; row < numRows; row++) {
-            long i = index(row, col);
-            final int v = elements.get(i, 0);
-            if (v != 0) {
-                procedure.apply(row, v);
-            }
-        }
-    }
-
-    @Nonnegative
-    private static long index(@Nonnegative final int row, @Nonnegative final int col) {
-        return Primitives.toLong(row, col);
-    }
-
-    @Nonnull
-    public static DoKIntMatrix build(@Nonnull final int[][] matrix, boolean rowMajorInput,
-            boolean nonZeroOnly) {
-        if (rowMajorInput) {
-            return buildFromRowMajorMatrix(matrix, nonZeroOnly);
-        } else {
-            return buildFromColumnMajorMatrix(matrix, nonZeroOnly);
-        }
-    }
-
-    @Nonnull
-    private static DoKIntMatrix buildFromRowMajorMatrix(@Nonnull final int[][] rowMajorMatrix,
-            boolean nonZeroOnly) {
-        final Long2IntOpenHashTable elements = new Long2IntOpenHashTable(rowMajorMatrix.length * 3);
-
-        int numRows = rowMajorMatrix.length, numColumns = 0;
-        for (int i = 0; i < rowMajorMatrix.length; i++) {
-            final int[] row = rowMajorMatrix[i];
-            if (row == null) {
-                continue;
-            }
-            numColumns = Math.max(numColumns, row.length);
-            for (int col = 0; col < row.length; col++) {
-                int value = row[col];
-                if (nonZeroOnly && value == 0) {
-                    continue;
-                }
-                long index = index(i, col);
-                elements.put(index, value);
-            }
-        }
-
-        return new DoKIntMatrix(elements, numRows, numColumns);
-    }
-
-    @Nonnull
-    private static DoKIntMatrix buildFromColumnMajorMatrix(@Nonnull final int[][] columnMajorMatrix,
-            boolean nonZeroOnly) {
-        final Long2IntOpenHashTable elements =
-                new Long2IntOpenHashTable(columnMajorMatrix.length * 3);
-
-        int numRows = 0, numColumns = columnMajorMatrix.length;
-        for (int j = 0; j < columnMajorMatrix.length; j++) {
-            final int[] col = columnMajorMatrix[j];
-            if (col == null) {
-                continue;
-            }
-            numRows = Math.max(numRows, col.length);
-            for (int row = 0; row < col.length; row++) {
-                int value = col[row];
-                if (nonZeroOnly && value == 0) {
-                    continue;
-                }
-                long index = index(row, j);
-                elements.put(index, value);
-            }
-        }
-
-        return new DoKIntMatrix(elements, numRows, numColumns);
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/ints/IntMatrix.java b/core/src/main/java/hivemall/math/matrix/ints/IntMatrix.java
deleted file mode 100644
index bcc954e..0000000
--- a/core/src/main/java/hivemall/math/matrix/ints/IntMatrix.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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 hivemall.math.matrix.ints;
-
-import hivemall.math.vector.VectorProcedure;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public interface IntMatrix {
-
-    public boolean isSparse();
-
-    public boolean readOnly();
-
-    public void setDefaultValue(int value);
-
-    @Nonnegative
-    public int numRows();
-
-    @Nonnegative
-    public int numColumns();
-
-    @Nonnull
-    public int[] row();
-
-    @Nonnull
-    public int[] getRow(@Nonnegative int index);
-
-    /**
-     * @return returns dst
-     */
-    @Nonnull
-    public int[] getRow(@Nonnegative int index, @Nonnull int[] dst);
-
-    /**
-     * @throws IndexOutOfBoundsException
-     */
-    public int get(@Nonnegative int row, @Nonnegative int col);
-
-    /**
-     * @throws IndexOutOfBoundsException
-     */
-    public int get(@Nonnegative int row, @Nonnegative int col, int defaultValue);
-
-    /**
-     * @throws IndexOutOfBoundsException
-     * @throws UnsupportedOperationException
-     */
-    public void set(@Nonnegative int row, @Nonnegative int col, int value);
-
-    /**
-     * @throws IndexOutOfBoundsException
-     * @throws UnsupportedOperationException
-     */
-    public int getAndSet(@Nonnegative int row, @Nonnegative int col, int value);
-
-    /**
-     * @throws IndexOutOfBoundsException
-     * @throws UnsupportedOperationException
-     */
-    public void incr(@Nonnegative int row, @Nonnegative int col);
-
-    /**
-     * @throws IndexOutOfBoundsException
-     * @throws UnsupportedOperationException
-     */
-    public void incr(@Nonnegative int row, @Nonnegative int col, int delta);
-
-    public void eachInRow(@Nonnegative int row, @Nonnull VectorProcedure procedure);
-
-    public void eachInRow(@Nonnegative int row, @Nonnull VectorProcedure procedure,
-            boolean nullOutput);
-
-    public void eachNonNullInRow(@Nonnegative int row, @Nonnull VectorProcedure procedure);
-
-    public void eachNonZeroInRow(@Nonnegative int row, @Nonnull VectorProcedure procedure);
-
-    public void eachInColumn(@Nonnegative int col, @Nonnull VectorProcedure procedure);
-
-    public void eachInColumn(@Nonnegative int col, @Nonnull VectorProcedure procedure,
-            boolean nullOutput);
-
-    public void eachNonNullInColumn(@Nonnegative int col, @Nonnull VectorProcedure procedure);
-
-    public void eachNonZeroInColumn(@Nonnegative int col, @Nonnull VectorProcedure procedure);
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/sparse/CSCMatrix.java b/core/src/main/java/hivemall/math/matrix/sparse/CSCMatrix.java
deleted file mode 100644
index 4ea4ad5..0000000
--- a/core/src/main/java/hivemall/math/matrix/sparse/CSCMatrix.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * 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 hivemall.math.matrix.sparse;
-
-import hivemall.math.matrix.ColumnMajorMatrix;
-import hivemall.math.matrix.builders.CSCMatrixBuilder;
-import hivemall.math.vector.Vector;
-import hivemall.math.vector.VectorProcedure;
-import hivemall.utils.lang.ArrayUtils;
-import hivemall.utils.lang.Preconditions;
-
-import java.util.Arrays;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-/**
- * Compressed Sparse Column matrix optimized for column major access.
- *
- * @link http://netlib.org/linalg/html_templates/node92.html#SECTION00931200000000000000
- */
-public final class CSCMatrix extends ColumnMajorMatrix {
-
-    @Nonnull
-    private final int[] columnPointers;
-    @Nonnull
-    private final int[] rowIndices;
-    @Nonnull
-    private final double[] values;
-
-    private final int numRows;
-    private final int numColumns;
-    private final int nnz;
-
-    public CSCMatrix(@Nonnull int[] columnPointers, @Nonnull int[] rowIndices,
-            @Nonnull double[] values, int numRows, int numColumns) {
-        super();
-        Preconditions.checkArgument(columnPointers.length >= 1,
-            "rowPointers must be greater than 0: " + columnPointers.length);
-        Preconditions.checkArgument(rowIndices.length == values.length, "#rowIndices ("
-                + rowIndices.length + ") must be equals to #values (" + values.length + ")");
-        this.columnPointers = columnPointers;
-        this.rowIndices = rowIndices;
-        this.values = values;
-        this.numRows = numRows;
-        this.numColumns = numColumns;
-        this.nnz = values.length;
-    }
-
-    @Override
-    public boolean isSparse() {
-        return true;
-    }
-
-    @Override
-    public boolean readOnly() {
-        return true;
-    }
-
-    @Override
-    public boolean swappable() {
-        return false;
-    }
-
-    @Override
-    public int nnz() {
-        return nnz;
-    }
-
-    @Override
-    public int numRows() {
-        return numRows;
-    }
-
-    @Override
-    public int numColumns() {
-        return numColumns;
-    }
-
-    @Override
-    public int numColumns(final int row) {
-        checkRowIndex(row, numRows);
-
-        return ArrayUtils.count(rowIndices, row);
-    }
-
-    @Override
-    public double[] getRow(final int index) {
-        checkRowIndex(index, numRows);
-
-        final double[] row = new double[numColumns];
-
-        final int numCols = columnPointers.length - 1;
-        for (int j = 0; j < numCols; j++) {
-            final int k = Arrays.binarySearch(rowIndices, columnPointers[j], columnPointers[j + 1],
-                index);
-            if (k >= 0) {
-                row[j] = values[k];
-            }
-        }
-
-        return row;
-    }
-
-    @Override
-    public double[] getRow(final int index, @Nonnull final double[] dst) {
-        checkRowIndex(index, numRows);
-
-        final int last = Math.min(dst.length, columnPointers.length - 1);
-        for (int j = 0; j < last; j++) {
-            final int k = Arrays.binarySearch(rowIndices, columnPointers[j], columnPointers[j + 1],
-                index);
-            if (k >= 0) {
-                dst[j] = values[k];
-            } else {
-                dst[j] = 0.d;
-            }
-        }
-        for (int j = last; j < dst.length; j++) {
-            dst[j] = 0.d;
-        }
-
-        return dst;
-    }
-
-    @Override
-    public void getRow(final int index, @Nonnull final Vector row) {
-        checkRowIndex(index, numRows);
-        row.clear();
-
-        for (int j = 0, last = columnPointers.length - 1; j < last; j++) {
-            final int k = Arrays.binarySearch(rowIndices, columnPointers[j], columnPointers[j + 1],
-                index);
-            if (k >= 0) {
-                double v = values[k];
-                row.set(j, v);
-            }
-        }
-    }
-
-    @Override
-    public double get(final int row, final int col, final double defaultValue) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final int index = getIndex(row, col);
-        if (index < 0) {
-            return defaultValue;
-        }
-        return values[index];
-    }
-
-    @Override
-    public double getAndSet(final int row, final int col, final double value) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final int index = getIndex(row, col);
-        if (index < 0) {
-            throw new UnsupportedOperationException(
-                "Cannot update value in row " + row + ", col " + col);
-        }
-
-        double old = values[index];
-        values[index] = value;
-        return old;
-    }
-
-    @Override
-    public void set(final int row, final int col, final double value) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final int index = getIndex(row, col);
-        if (index < 0) {
-            throw new UnsupportedOperationException(
-                "Cannot update value in row " + row + ", col " + col);
-        }
-        values[index] = value;
-    }
-
-    private int getIndex(@Nonnegative final int row, @Nonnegative final int col) {
-        int leftIn = columnPointers[col];
-        int rightEx = columnPointers[col + 1];
-        final int index = Arrays.binarySearch(rowIndices, leftIn, rightEx, row);
-        if (index >= 0 && index >= values.length) {
-            throw new IndexOutOfBoundsException(
-                "Value index " + index + " out of range " + values.length);
-        }
-        return index;
-    }
-
-    @Override
-    public void swap(final int row1, final int row2) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void eachInColumn(final int col, @Nonnull final VectorProcedure procedure,
-            final boolean nullOutput) {
-        checkColIndex(col, numColumns);
-
-        final int startIn = columnPointers[col];
-        final int endEx = columnPointers[col + 1];
-
-        if (nullOutput) {
-            for (int row = 0, i = startIn; row < numRows; row++) {
-                if (i < endEx && row == rowIndices[i]) {
-                    double v = values[i++];
-                    procedure.apply(row, v);
-                } else {
-                    procedure.apply(row, 0.d);
-                }
-            }
-        } else {
-            for (int j = startIn; j < endEx; j++) {
-                int row = rowIndices[j];
-                double v = values[j];
-                procedure.apply(row, v);
-            }
-        }
-    }
-
-    @Override
-    public void eachNonZeroInColumn(final int col, @Nonnull final VectorProcedure procedure) {
-        checkColIndex(col, numColumns);
-
-        final int startIn = columnPointers[col];
-        final int endEx = columnPointers[col + 1];
-        for (int j = startIn; j < endEx; j++) {
-            int row = rowIndices[j];
-            final double v = values[j];
-            if (v != 0.d) {
-                procedure.apply(row, v);
-            }
-        }
-    }
-
-    @Override
-    public CSRMatrix toRowMajorMatrix() {
-        final int[] rowPointers = new int[numRows + 1];
-        final int[] colIndices = new int[nnz];
-        final double[] csrValues = new double[nnz];
-
-        // compute nnz per for each row
-        for (int i = 0; i < rowIndices.length; i++) {
-            rowPointers[rowIndices[i]]++;
-        }
-        for (int i = 0, sum = 0; i < numRows; i++) {
-            int curr = rowPointers[i];
-            rowPointers[i] = sum;
-            sum += curr;
-        }
-        rowPointers[numRows] = nnz;
-
-        for (int j = 0; j < numColumns; j++) {
-            for (int i = columnPointers[j], last = columnPointers[j + 1]; i < last; i++) {
-                int col = rowIndices[i];
-                int dst = rowPointers[col];
-
-                colIndices[dst] = j;
-                csrValues[dst] = values[i];
-
-                rowPointers[col]++;
-            }
-        }
-
-        // shift column pointers
-        for (int i = 0, last = 0; i <= numRows; i++) {
-            int tmp = rowPointers[i];
-            rowPointers[i] = last;
-            last = tmp;
-        }
-
-        return new CSRMatrix(rowPointers, colIndices, csrValues, numColumns);
-    }
-
-    @Override
-    public CSCMatrixBuilder builder() {
-        return new CSCMatrixBuilder(nnz);
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/sparse/CSRMatrix.java b/core/src/main/java/hivemall/math/matrix/sparse/CSRMatrix.java
deleted file mode 100644
index 8a63c9c..0000000
--- a/core/src/main/java/hivemall/math/matrix/sparse/CSRMatrix.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * 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 hivemall.math.matrix.sparse;
-
-import hivemall.math.matrix.RowMajorMatrix;
-import hivemall.math.matrix.builders.CSRMatrixBuilder;
-import hivemall.math.vector.VectorProcedure;
-import hivemall.utils.lang.Preconditions;
-
-import java.util.Arrays;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-/**
- * Compressed Sparse Row Matrix optimized for row major access.
- *
- * @link http://netlib.org/linalg/html_templates/node91.html#SECTION00931100000000000000
- * @link http://www.cs.colostate.edu/~mcrob/toolbox/c++/sparseMatrix/sparse_matrix_compression.html
- */
-public final class CSRMatrix extends RowMajorMatrix {
-
-    @Nonnull
-    private final int[] rowPointers;
-    @Nonnull
-    private final int[] columnIndices;
-    @Nonnull
-    private final double[] values;
-
-    @Nonnegative
-    private final int numRows;
-    @Nonnegative
-    private final int numColumns;
-    @Nonnegative
-    private final int nnz;
-
-    public CSRMatrix(@Nonnull int[] rowPointers, @Nonnull int[] columnIndices,
-            @Nonnull double[] values, @Nonnegative int numColumns) {
-        super();
-        Preconditions.checkArgument(rowPointers.length >= 1,
-            "rowPointers must be greater than 0: " + rowPointers.length);
-        Preconditions.checkArgument(columnIndices.length == values.length, "#columnIndices ("
-                + columnIndices.length + ") must be equals to #values (" + values.length + ")");
-        this.rowPointers = rowPointers;
-        this.columnIndices = columnIndices;
-        this.values = values;
-        this.numRows = rowPointers.length - 1;
-        this.numColumns = numColumns;
-        this.nnz = values.length;
-    }
-
-    @Override
-    public boolean isSparse() {
-        return true;
-    }
-
-    @Override
-    public boolean readOnly() {
-        return true;
-    }
-
-    @Override
-    public boolean swappable() {
-        return false;
-    }
-
-    @Override
-    public int nnz() {
-        return nnz;
-    }
-
-    @Override
-    public int numRows() {
-        return numRows;
-    }
-
-    @Override
-    public int numColumns() {
-        return numColumns;
-    }
-
-    @Override
-    public int numColumns(@Nonnegative final int row) {
-        checkRowIndex(row, numRows);
-
-        int columns = rowPointers[row + 1] - rowPointers[row];
-        return columns;
-    }
-
-    @Override
-    public double[] getRow(@Nonnegative final int index) {
-        final double[] row = new double[numColumns];
-        eachNonZeroInRow(index, new VectorProcedure() {
-            public void apply(int col, double value) {
-                row[col] = value;
-            }
-        });
-        return row;
-    }
-
-    @Override
-    public double[] getRow(@Nonnegative final int index, @Nonnull final double[] dst) {
-        Arrays.fill(dst, 0.d);
-        eachNonZeroInRow(index, new VectorProcedure() {
-            public void apply(int col, double value) {
-                checkColIndex(col, numColumns);
-                dst[col] = value;
-            }
-        });
-        return dst;
-    }
-
-    @Override
-    public double get(@Nonnegative final int row, @Nonnegative final int col,
-            final double defaultValue) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final int index = getIndex(row, col);
-        if (index < 0) {
-            return defaultValue;
-        }
-        return values[index];
-    }
-
-    @Override
-    public double getAndSet(@Nonnegative final int row, @Nonnegative final int col,
-            final double value) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final int index = getIndex(row, col);
-        if (index < 0) {
-            throw new UnsupportedOperationException(
-                "Cannot update value in row " + row + ", col " + col);
-        }
-
-        double old = values[index];
-        values[index] = value;
-        return old;
-    }
-
-    @Override
-    public void set(@Nonnegative final int row, @Nonnegative final int col, final double value) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final int index = getIndex(row, col);
-        if (index < 0) {
-            throw new UnsupportedOperationException(
-                "Cannot update value in row " + row + ", col " + col);
-        }
-        values[index] = value;
-    }
-
-    private int getIndex(@Nonnegative final int row, @Nonnegative final int col) {
-        int leftIn = rowPointers[row];
-        int rightEx = rowPointers[row + 1];
-        final int index = Arrays.binarySearch(columnIndices, leftIn, rightEx, col);
-        if (index >= 0 && index >= values.length) {
-            throw new IndexOutOfBoundsException(
-                "Value index " + index + " out of range " + values.length);
-        }
-        return index;
-    }
-
-    @Override
-    public void swap(int row1, int row2) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void eachInRow(@Nonnegative final int row, @Nonnull final VectorProcedure procedure,
-            final boolean nullOutput) {
-        checkRowIndex(row, numRows);
-
-        final int startIn = rowPointers[row];
-        final int endEx = rowPointers[row + 1];
-
-        if (nullOutput) {
-            for (int col = 0, j = startIn; col < numColumns; col++) {
-                if (j < endEx && col == columnIndices[j]) {
-                    double v = values[j++];
-                    procedure.apply(col, v);
-                } else {
-                    procedure.apply(col, 0.d);
-                }
-            }
-        } else {
-            for (int i = startIn; i < endEx; i++) {
-                procedure.apply(columnIndices[i], values[i]);
-            }
-        }
-    }
-
-    @Override
-    public void eachNonZeroInRow(@Nonnegative final int row,
-            @Nonnull final VectorProcedure procedure) {
-        checkRowIndex(row, numRows);
-
-        final int startIn = rowPointers[row];
-        final int endEx = rowPointers[row + 1];
-        for (int i = startIn; i < endEx; i++) {
-            int col = columnIndices[i];
-            final double v = values[i];
-            if (v != 0.d) {
-                procedure.apply(col, v);
-            }
-        }
-    }
-
-    @Override
-    public void eachColumnIndexInRow(@Nonnegative final int row,
-            @Nonnull final VectorProcedure procedure) {
-        checkRowIndex(row, numRows);
-
-        final int startIn = rowPointers[row];
-        final int endEx = rowPointers[row + 1];
-
-        for (int i = startIn; i < endEx; i++) {
-            procedure.apply(columnIndices[i]);
-        }
-    }
-
-    @Nonnull
-    public CSCMatrix toColumnMajorMatrix() {
-        final int[] columnPointers = new int[numColumns + 1];
-        final int[] rowIndices = new int[nnz];
-        final double[] cscValues = new double[nnz];
-
-        // compute nnz per for each column
-        for (int j = 0; j < columnIndices.length; j++) {
-            columnPointers[columnIndices[j]]++;
-        }
-        for (int j = 0, sum = 0; j < numColumns; j++) {
-            int curr = columnPointers[j];
-            columnPointers[j] = sum;
-            sum += curr;
-        }
-        columnPointers[numColumns] = nnz;
-
-        for (int i = 0; i < numRows; i++) {
-            for (int j = rowPointers[i], last = rowPointers[i + 1]; j < last; j++) {
-                int col = columnIndices[j];
-                int dst = columnPointers[col];
-
-                rowIndices[dst] = i;
-                cscValues[dst] = values[j];
-
-                columnPointers[col]++;
-            }
-        }
-
-        // shift column pointers
-        for (int j = 0, last = 0; j <= numColumns; j++) {
-            int tmp = columnPointers[j];
-            columnPointers[j] = last;
-            last = tmp;
-        }
-
-        return new CSCMatrix(columnPointers, rowIndices, cscValues, numRows, numColumns);
-    }
-
-    @Override
-    public CSRMatrixBuilder builder() {
-        return new CSRMatrixBuilder(values.length);
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/sparse/DoKMatrix.java b/core/src/main/java/hivemall/math/matrix/sparse/DoKMatrix.java
deleted file mode 100644
index 30c107d..0000000
--- a/core/src/main/java/hivemall/math/matrix/sparse/DoKMatrix.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * 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 hivemall.math.matrix.sparse;
-
-import hivemall.annotations.Experimental;
-import hivemall.math.matrix.AbstractMatrix;
-import hivemall.math.matrix.ColumnMajorMatrix;
-import hivemall.math.matrix.MatrixUtils;
-import hivemall.math.matrix.RowMajorMatrix;
-import hivemall.math.matrix.builders.DoKMatrixBuilder;
-import hivemall.math.vector.Vector;
-import hivemall.math.vector.VectorProcedure;
-import hivemall.utils.collections.maps.Long2DoubleOpenHashTable;
-import hivemall.utils.collections.maps.Long2DoubleOpenHashTable.IMapIterator;
-import hivemall.utils.lang.Preconditions;
-import hivemall.utils.lang.Primitives;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-/**
- * Dictionary of Keys based sparse matrix.
- *
- * This is an efficient structure for constructing a sparse matrix incrementally.
- */
-@Experimental
-public final class DoKMatrix extends AbstractMatrix {
-
-    @Nonnull
-    private final Long2DoubleOpenHashTable elements;
-    @Nonnegative
-    private int numRows;
-    @Nonnegative
-    private int numColumns;
-
-    public DoKMatrix() {
-        this(0, 0);
-    }
-
-    public DoKMatrix(@Nonnegative int numRows, @Nonnegative int numCols) {
-        this(numRows, numCols, 0.05f);
-    }
-
-    public DoKMatrix(@Nonnegative int numRows, @Nonnegative int numCols,
-            @Nonnegative float sparsity) {
-        super();
-        Preconditions.checkArgument(sparsity >= 0.f && sparsity <= 1.f,
-            "Invalid Sparsity value: " + sparsity);
-        int initialCapacity = Math.max(16384, Math.round(numRows * numCols * sparsity));
-        this.elements = new Long2DoubleOpenHashTable(initialCapacity);
-        elements.defaultReturnValue(0.d);
-        this.numRows = numRows;
-        this.numColumns = numCols;
-    }
-
-    public DoKMatrix(@Nonnegative int initSize) {
-        super();
-        int initialCapacity = Math.max(initSize, 16384);
-        this.elements = new Long2DoubleOpenHashTable(initialCapacity);
-        elements.defaultReturnValue(0.d);
-        this.numRows = 0;
-        this.numColumns = 0;
-    }
-
-    @Override
-    public boolean isSparse() {
-        return true;
-    }
-
-    @Override
-    public boolean isRowMajorMatrix() {
-        return false;
-    }
-
-    @Override
-    public boolean isColumnMajorMatrix() {
-        return false;
-    }
-
-    @Override
-    public boolean readOnly() {
-        return false;
-    }
-
-    @Override
-    public boolean swappable() {
-        return true;
-    }
-
-    @Override
-    public int nnz() {
-        return elements.size();
-    }
-
-    @Override
-    public int numRows() {
-        return numRows;
-    }
-
-    @Override
-    public int numColumns() {
-        return numColumns;
-    }
-
-    @Override
-    public int numColumns(@Nonnegative final int row) {
-        int count = 0;
-        for (int j = 0; j < numColumns; j++) {
-            long index = index(row, j);
-            if (elements.containsKey(index)) {
-                count++;
-            }
-        }
-        return count;
-    }
-
-    @Override
-    public double[] getRow(@Nonnegative final int index) {
-        double[] dst = row();
-        return getRow(index, dst);
-    }
-
-    @Override
-    public double[] getRow(@Nonnegative final int row, @Nonnull final double[] dst) {
-        checkRowIndex(row, numRows);
-
-        final int end = Math.min(dst.length, numColumns);
-        for (int col = 0; col < end; col++) {
-            long k = index(row, col);
-            double v = elements.get(k);
-            dst[col] = v;
-        }
-
-        return dst;
-    }
-
-    @Override
-    public void getRow(@Nonnegative final int index, @Nonnull final Vector row) {
-        checkRowIndex(index, numRows);
-        row.clear();
-
-        for (int col = 0; col < numColumns; col++) {
-            long k = index(index, col);
-            final double v = elements.get(k, 0.d);
-            if (v != 0.d) {
-                row.set(col, v);
-            }
-        }
-    }
-
-    @Override
-    public double get(@Nonnegative final int row, @Nonnegative final int col,
-            final double defaultValue) {
-        long index = index(row, col);
-        return elements.get(index, defaultValue);
-    }
-
-    @Override
-    public void set(@Nonnegative final int row, @Nonnegative final int col, final double value) {
-        checkIndex(row, col);
-
-        long index = index(row, col);
-        elements.put(index, value);
-        this.numRows = Math.max(numRows, row + 1);
-        this.numColumns = Math.max(numColumns, col + 1);
-    }
-
-    @Override
-    public double getAndSet(@Nonnegative final int row, @Nonnegative final int col,
-            final double value) {
-        checkIndex(row, col);
-
-        long index = index(row, col);
-        double old = elements.put(index, value);
-        this.numRows = Math.max(numRows, row + 1);
-        this.numColumns = Math.max(numColumns, col + 1);
-        return old;
-    }
-
-    @Override
-    public void swap(@Nonnegative final int row1, @Nonnegative final int row2) {
-        checkRowIndex(row1, numRows);
-        checkRowIndex(row2, numRows);
-
-        for (int j = 0; j < numColumns; j++) {
-            final long i1 = index(row1, j);
-            final long i2 = index(row2, j);
-
-            final int k1 = elements._findKey(i1);
-            final int k2 = elements._findKey(i2);
-
-            if (k1 >= 0) {
-                if (k2 >= 0) {
-                    double v1 = elements._get(k1);
-                    double v2 = elements._set(k2, v1);
-                    elements._set(k1, v2);
-                } else {// k1>=0 and k2<0
-                    double v1 = elements._remove(k1);
-                    elements.put(i2, v1);
-                }
-            } else if (k2 >= 0) {// k2>=0 and k1 < 0
-                double v2 = elements._remove(k2);
-                elements.put(i1, v2);
-            } else {//k1<0 and k2<0
-                continue;
-            }
-        }
-    }
-
-    @Override
-    public void eachInRow(@Nonnegative final int row, @Nonnull final VectorProcedure procedure,
-            final boolean nullOutput) {
-        checkRowIndex(row, numRows);
-
-        for (int col = 0; col < numColumns; col++) {
-            long i = index(row, col);
-            final int key = elements._findKey(i);
-            if (key < 0) {
-                if (nullOutput) {
-                    procedure.apply(col, 0.d);
-                }
-            } else {
-                double v = elements._get(key);
-                procedure.apply(col, v);
-            }
-        }
-    }
-
-    @Override
-    public void eachNonZeroInRow(@Nonnegative final int row,
-            @Nonnull final VectorProcedure procedure) {
-        checkRowIndex(row, numRows);
-
-        for (int col = 0; col < numColumns; col++) {
-            long i = index(row, col);
-            final double v = elements.get(i, 0.d);
-            if (v != 0.d) {
-                procedure.apply(col, v);
-            }
-        }
-    }
-
-    @Override
-    public void eachColumnIndexInRow(int row, VectorProcedure procedure) {
-        checkRowIndex(row, numRows);
-
-        for (int col = 0; col < numColumns; col++) {
-            long i = index(row, col);
-            final int key = elements._findKey(i);
-            if (key != -1) {
-                procedure.apply(col);
-            }
-        }
-    }
-
-    @Override
-    public void eachInColumn(@Nonnegative final int col, @Nonnull final VectorProcedure procedure,
-            final boolean nullOutput) {
-        checkColIndex(col, numColumns);
-
-        for (int row = 0; row < numRows; row++) {
-            long i = index(row, col);
-            final int key = elements._findKey(i);
-            if (key < 0) {
-                if (nullOutput) {
-                    procedure.apply(row, 0.d);
-                }
-            } else {
-                double v = elements._get(key);
-                procedure.apply(row, v);
-            }
-        }
-    }
-
-    @Override
-    public void eachNonZeroInColumn(@Nonnegative final int col,
-            @Nonnull final VectorProcedure procedure) {
-        checkColIndex(col, numColumns);
-
-        for (int row = 0; row < numRows; row++) {
-            long i = index(row, col);
-            final double v = elements.get(i, 0.d);
-            if (v != 0.d) {
-                procedure.apply(row, v);
-            }
-        }
-    }
-
-    public void eachNonZeroCell(@Nonnull final VectorProcedure procedure) {
-        if (elements.size() == 0) {
-            return;
-        }
-        final IMapIterator itor = elements.entries();
-        while (itor.next() != -1) {
-            long k = itor.getKey();
-            int row = Primitives.getHigh(k);
-            int col = Primitives.getLow(k);
-            double value = itor.getValue();
-            procedure.apply(row, col, value);
-        }
-    }
-
-    @Override
-    public RowMajorMatrix toRowMajorMatrix() {
-        final int nnz = elements.size();
-        final int[] rows = new int[nnz];
-        final int[] cols = new int[nnz];
-        final double[] data = new double[nnz];
-
-        final IMapIterator itor = elements.entries();
-        for (int i = 0; i < nnz; i++) {
-            if (itor.next() == -1) {
-                throw new IllegalStateException("itor.next() returns -1 where i=" + i);
-            }
-            long k = itor.getKey();
-            rows[i] = Primitives.getHigh(k);
-            cols[i] = Primitives.getLow(k);
-            data[i] = itor.getValue();
-        }
-
-        return MatrixUtils.coo2csr(rows, cols, data, numRows, numColumns, true);
-    }
-
-    @Override
-    public ColumnMajorMatrix toColumnMajorMatrix() {
-        final int nnz = elements.size();
-        final int[] rows = new int[nnz];
-        final int[] cols = new int[nnz];
-        final double[] data = new double[nnz];
-
-        final IMapIterator itor = elements.entries();
-        for (int i = 0; i < nnz; i++) {
-            if (itor.next() == -1) {
-                throw new IllegalStateException("itor.next() returns -1 where i=" + i);
-            }
-            long k = itor.getKey();
-            rows[i] = Primitives.getHigh(k);
-            cols[i] = Primitives.getLow(k);
-            data[i] = itor.getValue();
-        }
-
-        return MatrixUtils.coo2csc(rows, cols, data, numRows, numColumns, true);
-    }
-
-    @Override
-    public DoKMatrixBuilder builder() {
-        return new DoKMatrixBuilder(elements.size());
-    }
-
-    @Nonnegative
-    private static long index(@Nonnegative final int row, @Nonnegative final int col) {
-        return Primitives.toLong(row, col);
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/sparse/floats/CSCFloatMatrix.java b/core/src/main/java/hivemall/math/matrix/sparse/floats/CSCFloatMatrix.java
deleted file mode 100644
index 14b5240..0000000
--- a/core/src/main/java/hivemall/math/matrix/sparse/floats/CSCFloatMatrix.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * 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 hivemall.math.matrix.sparse.floats;
-
-import hivemall.math.matrix.ColumnMajorFloatMatrix;
-import hivemall.math.matrix.builders.CSCMatrixBuilder;
-import hivemall.math.vector.Vector;
-import hivemall.math.vector.VectorProcedure;
-import hivemall.utils.lang.ArrayUtils;
-import hivemall.utils.lang.Preconditions;
-
-import java.util.Arrays;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-/**
- * Compressed Sparse Column matrix optimized for column major access.
- *
- * @link http://netlib.org/linalg/html_templates/node92.html#SECTION00931200000000000000
- */
-public final class CSCFloatMatrix extends ColumnMajorFloatMatrix {
-
-    @Nonnull
-    private final int[] columnPointers;
-    @Nonnull
-    private final int[] rowIndices;
-    @Nonnull
-    private final float[] values;
-
-    private final int numRows;
-    private final int numColumns;
-    private final int nnz;
-
-    public CSCFloatMatrix(@Nonnull int[] columnPointers, @Nonnull int[] rowIndices,
-            @Nonnull float[] values, int numRows, int numColumns) {
-        super();
-        Preconditions.checkArgument(columnPointers.length >= 1,
-            "rowPointers must be greater than 0: " + columnPointers.length);
-        Preconditions.checkArgument(rowIndices.length == values.length, "#rowIndices ("
-                + rowIndices.length + ") must be equals to #values (" + values.length + ")");
-        this.columnPointers = columnPointers;
-        this.rowIndices = rowIndices;
-        this.values = values;
-        this.numRows = numRows;
-        this.numColumns = numColumns;
-        this.nnz = values.length;
-    }
-
-    @Override
-    public boolean isSparse() {
-        return true;
-    }
-
-    @Override
-    public boolean readOnly() {
-        return true;
-    }
-
-    @Override
-    public boolean swappable() {
-        return false;
-    }
-
-    @Override
-    public int nnz() {
-        return nnz;
-    }
-
-    @Override
-    public int numRows() {
-        return numRows;
-    }
-
-    @Override
-    public int numColumns() {
-        return numColumns;
-    }
-
-    @Override
-    public int numColumns(final int row) {
-        checkRowIndex(row, numRows);
-
-        return ArrayUtils.count(rowIndices, row);
-    }
-
-    @Override
-    public double[] getRow(final int index) {
-        checkRowIndex(index, numRows);
-
-        final double[] row = new double[numColumns];
-
-        final int numCols = columnPointers.length - 1;
-        for (int j = 0; j < numCols; j++) {
-            final int k = Arrays.binarySearch(rowIndices, columnPointers[j], columnPointers[j + 1],
-                index);
-            if (k >= 0) {
-                row[j] = values[k];
-            }
-        }
-
-        return row;
-    }
-
-    @Override
-    public double[] getRow(final int index, @Nonnull final double[] dst) {
-        checkRowIndex(index, numRows);
-
-        final int last = Math.min(dst.length, columnPointers.length - 1);
-        for (int j = 0; j < last; j++) {
-            final int k = Arrays.binarySearch(rowIndices, columnPointers[j], columnPointers[j + 1],
-                index);
-            if (k >= 0) {
-                dst[j] = values[k];
-            } else {
-                dst[j] = 0.d;
-            }
-        }
-        for (int j = last; j < dst.length; j++) {
-            dst[j] = 0.d;
-        }
-
-        return dst;
-    }
-
-    @Override
-    public float[] getRow(final int index, @Nonnull final float[] dst) {
-        checkRowIndex(index, numRows);
-
-        final int last = Math.min(dst.length, columnPointers.length - 1);
-        for (int j = 0; j < last; j++) {
-            final int k = Arrays.binarySearch(rowIndices, columnPointers[j], columnPointers[j + 1],
-                index);
-            if (k >= 0) {
-                dst[j] = values[k];
-            } else {
-                dst[j] = 0.f;
-            }
-        }
-        for (int j = last; j < dst.length; j++) {
-            dst[j] = 0.f;
-        }
-
-        return dst;
-    }
-
-    @Override
-    public void getRow(final int index, @Nonnull final Vector row) {
-        checkRowIndex(index, numRows);
-        row.clear();
-
-        for (int j = 0, last = columnPointers.length - 1; j < last; j++) {
-            final int k = Arrays.binarySearch(rowIndices, columnPointers[j], columnPointers[j + 1],
-                index);
-            if (k >= 0) {
-                float v = values[k];
-                row.set(j, v);
-            }
-        }
-    }
-
-    @Override
-    public float get(final int row, final int col, final float defaultValue) {
-        checkIndex(row, col, numRows, numColumns);
-
-        int index = getIndex(row, col);
-        if (index < 0) {
-            return defaultValue;
-        }
-        return values[index];
-    }
-
-    @Override
-    public float getAndSet(final int row, final int col, final float value) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final int index = getIndex(row, col);
-        if (index < 0) {
-            throw new UnsupportedOperationException(
-                "Cannot update value in row " + row + ", col " + col);
-        }
-
-        float old = values[index];
-        values[index] = value;
-        return old;
-    }
-
-    @Override
-    public void set(final int row, final int col, final float value) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final int index = getIndex(row, col);
-        if (index < 0) {
-            throw new UnsupportedOperationException(
-                "Cannot update value in row " + row + ", col " + col);
-        }
-        values[index] = value;
-    }
-
-    private int getIndex(@Nonnegative final int row, @Nonnegative final int col) {
-        int leftIn = columnPointers[col];
-        int rightEx = columnPointers[col + 1];
-        final int index = Arrays.binarySearch(rowIndices, leftIn, rightEx, row);
-        if (index >= 0 && index >= values.length) {
-            throw new IndexOutOfBoundsException(
-                "Value index " + index + " out of range " + values.length);
-        }
-        return index;
-    }
-
-    @Override
-    public void swap(final int row1, final int row2) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void eachInColumn(final int col, @Nonnull final VectorProcedure procedure,
-            final boolean nullOutput) {
-        checkColIndex(col, numColumns);
-
-        final int startIn = columnPointers[col];
-        final int endEx = columnPointers[col + 1];
-
-        if (nullOutput) {
-            for (int row = 0, i = startIn; row < numRows; row++) {
-                if (i < endEx && row == rowIndices[i]) {
-                    float v = values[i++];
-                    procedure.apply(row, v);
-                } else {
-                    procedure.apply(row, 0.f);
-                }
-            }
-        } else {
-            for (int j = startIn; j < endEx; j++) {
-                int row = rowIndices[j];
-                float v = values[j];
-                procedure.apply(row, v);
-            }
-        }
-    }
-
-    @Override
-    public void eachNonZeroInColumn(final int col, @Nonnull final VectorProcedure procedure) {
-        checkColIndex(col, numColumns);
-
-        final int startIn = columnPointers[col];
-        final int endEx = columnPointers[col + 1];
-        for (int j = startIn; j < endEx; j++) {
-            int row = rowIndices[j];
-            final float v = values[j];
-            if (v != 0.f) {
-                procedure.apply(row, v);
-            }
-        }
-    }
-
-    @Override
-    public CSRFloatMatrix toRowMajorMatrix() {
-        final int[] rowPointers = new int[numRows + 1];
-        final int[] colIndices = new int[nnz];
-        final float[] csrValues = new float[nnz];
-
-        // compute nnz per for each row
-        for (int i = 0; i < rowIndices.length; i++) {
-            rowPointers[rowIndices[i]]++;
-        }
-        for (int i = 0, sum = 0; i < numRows; i++) {
-            int curr = rowPointers[i];
-            rowPointers[i] = sum;
-            sum += curr;
-        }
-        rowPointers[numRows] = nnz;
-
-        for (int j = 0; j < numColumns; j++) {
-            for (int i = columnPointers[j], last = columnPointers[j + 1]; i < last; i++) {
-                int col = rowIndices[i];
-                int dst = rowPointers[col];
-
-                colIndices[dst] = j;
-                csrValues[dst] = values[i];
-
-                rowPointers[col]++;
-            }
-        }
-
-        // shift column pointers
-        for (int i = 0, last = 0; i <= numRows; i++) {
-            int tmp = rowPointers[i];
-            rowPointers[i] = last;
-            last = tmp;
-        }
-
-        return new CSRFloatMatrix(rowPointers, colIndices, csrValues, numColumns);
-    }
-
-    @Override
-    public CSCMatrixBuilder builder() {
-        return new CSCMatrixBuilder(nnz);
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/sparse/floats/CSRFloatMatrix.java b/core/src/main/java/hivemall/math/matrix/sparse/floats/CSRFloatMatrix.java
deleted file mode 100644
index d20ed14..0000000
--- a/core/src/main/java/hivemall/math/matrix/sparse/floats/CSRFloatMatrix.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * 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 hivemall.math.matrix.sparse.floats;
-
-import hivemall.math.matrix.RowMajorFloatMatrix;
-import hivemall.math.matrix.builders.CSRMatrixBuilder;
-import hivemall.math.vector.VectorProcedure;
-import hivemall.utils.lang.Preconditions;
-
-import java.util.Arrays;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-/**
- * Compressed Sparse Row Matrix optimized for row major access.
- *
- * @link http://netlib.org/linalg/html_templates/node91.html#SECTION00931100000000000000
- * @link http://www.cs.colostate.edu/~mcrob/toolbox/c++/sparseMatrix/sparse_matrix_compression.html
- */
-public final class CSRFloatMatrix extends RowMajorFloatMatrix {
-
-    @Nonnull
-    private final int[] rowPointers;
-    @Nonnull
-    private final int[] columnIndices;
-    @Nonnull
-    private final float[] values;
-
-    @Nonnegative
-    private final int numRows;
-    @Nonnegative
-    private final int numColumns;
-    @Nonnegative
-    private final int nnz;
-
-    public CSRFloatMatrix(@Nonnull int[] rowPointers, @Nonnull int[] columnIndices,
-            @Nonnull float[] values, @Nonnegative int numColumns) {
-        super();
-        Preconditions.checkArgument(rowPointers.length >= 1,
-            "rowPointers must be greater than 0: " + rowPointers.length);
-        Preconditions.checkArgument(columnIndices.length == values.length, "#columnIndices ("
-                + columnIndices.length + ") must be equals to #values (" + values.length + ")");
-        this.rowPointers = rowPointers;
-        this.columnIndices = columnIndices;
-        this.values = values;
-        this.numRows = rowPointers.length - 1;
-        this.numColumns = numColumns;
-        this.nnz = values.length;
-    }
-
-    @Override
-    public boolean isSparse() {
-        return true;
-    }
-
-    @Override
-    public boolean readOnly() {
-        return true;
-    }
-
-    @Override
-    public boolean swappable() {
-        return false;
-    }
-
-    @Override
-    public int nnz() {
-        return nnz;
-    }
-
-    @Override
-    public int numRows() {
-        return numRows;
-    }
-
-    @Override
-    public int numColumns() {
-        return numColumns;
-    }
-
-    @Override
-    public int numColumns(@Nonnegative final int row) {
-        checkRowIndex(row, numRows);
-
-        int columns = rowPointers[row + 1] - rowPointers[row];
-        return columns;
-    }
-
-    @Override
-    public double[] getRow(@Nonnegative final int index) {
-        final double[] row = new double[numColumns];
-        eachNonZeroInRow(index, new VectorProcedure() {
-            public void apply(int col, float value) {
-                row[col] = value;
-            }
-        });
-        return row;
-    }
-
-    @Override
-    public double[] getRow(@Nonnegative final int index, @Nonnull final double[] dst) {
-        Arrays.fill(dst, 0.d);
-        eachNonZeroInRow(index, new VectorProcedure() {
-            public void apply(int col, float value) {
-                checkColIndex(col, numColumns);
-                dst[col] = value;
-            }
-        });
-        return dst;
-    }
-
-    @Override
-    public float[] getRow(@Nonnegative final int index, @Nonnull final float[] dst) {
-        Arrays.fill(dst, 0.f);
-        eachNonZeroInRow(index, new VectorProcedure() {
-            public void apply(int col, float value) {
-                checkColIndex(col, numColumns);
-                dst[col] = value;
-            }
-        });
-        return dst;
-    }
-
-    @Override
-    public float get(@Nonnegative final int row, @Nonnegative final int col,
-            final float defaultValue) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final int index = getIndex(row, col);
-        if (index < 0) {
-            return defaultValue;
-        }
-        return values[index];
-    }
-
-    @Override
-    public float getAndSet(@Nonnegative final int row, @Nonnegative final int col,
-            final float value) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final int index = getIndex(row, col);
-        if (index < 0) {
-            throw new UnsupportedOperationException(
-                "Cannot update value in row " + row + ", col " + col);
-        }
-
-        float old = values[index];
-        values[index] = value;
-        return old;
-    }
-
-    @Override
-    public void set(@Nonnegative final int row, @Nonnegative final int col, final float value) {
-        checkIndex(row, col, numRows, numColumns);
-
-        final int index = getIndex(row, col);
-        if (index < 0) {
-            throw new UnsupportedOperationException(
-                "Cannot update value in row " + row + ", col " + col);
-        }
-        values[index] = value;
-    }
-
-    private int getIndex(@Nonnegative final int row, @Nonnegative final int col) {
-        int leftIn = rowPointers[row];
-        int rightEx = rowPointers[row + 1];
-        final int index = Arrays.binarySearch(columnIndices, leftIn, rightEx, col);
-        if (index >= 0 && index >= values.length) {
-            throw new IndexOutOfBoundsException(
-                "Value index " + index + " out of range " + values.length);
-        }
-        return index;
-    }
-
-    @Override
-    public void swap(int row1, int row2) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void eachInRow(@Nonnegative final int row, @Nonnull final VectorProcedure procedure,
-            final boolean nullOutput) {
-        checkRowIndex(row, numRows);
-
-        final int startIn = rowPointers[row];
-        final int endEx = rowPointers[row + 1];
-
-        if (nullOutput) {
-            for (int col = 0, j = startIn; col < numColumns; col++) {
-                if (j < endEx && col == columnIndices[j]) {
-                    float v = values[j++];
-                    procedure.apply(col, v);
-                } else {
-                    procedure.apply(col, 0.f);
-                }
-            }
-        } else {
-            for (int i = startIn; i < endEx; i++) {
-                procedure.apply(columnIndices[i], values[i]);
-            }
-        }
-    }
-
-    @Override
-    public void eachNonZeroInRow(@Nonnegative final int row,
-            @Nonnull final VectorProcedure procedure) {
-        checkRowIndex(row, numRows);
-
-        final int startIn = rowPointers[row];
-        final int endEx = rowPointers[row + 1];
-        for (int i = startIn; i < endEx; i++) {
-            int col = columnIndices[i];
-            final float v = values[i];
-            if (v != 0.f) {
-                procedure.apply(col, v);
-            }
-        }
-    }
-
-    @Override
-    public void eachColumnIndexInRow(@Nonnegative final int row,
-            @Nonnull final VectorProcedure procedure) {
-        checkRowIndex(row, numRows);
-
-        final int startIn = rowPointers[row];
-        final int endEx = rowPointers[row + 1];
-
-        for (int i = startIn; i < endEx; i++) {
-            procedure.apply(columnIndices[i]);
-        }
-    }
-
-    @Nonnull
-    public CSCFloatMatrix toColumnMajorMatrix() {
-        final int[] columnPointers = new int[numColumns + 1];
-        final int[] rowIndices = new int[nnz];
-        final float[] cscValues = new float[nnz];
-
-        // compute nnz per for each column
-        for (int j = 0; j < columnIndices.length; j++) {
-            columnPointers[columnIndices[j]]++;
-        }
-        for (int j = 0, sum = 0; j < numColumns; j++) {
-            int curr = columnPointers[j];
-            columnPointers[j] = sum;
-            sum += curr;
-        }
-        columnPointers[numColumns] = nnz;
-
-        for (int i = 0; i < numRows; i++) {
-            for (int j = rowPointers[i], last = rowPointers[i + 1]; j < last; j++) {
-                int col = columnIndices[j];
-                int dst = columnPointers[col];
-
-                rowIndices[dst] = i;
-                cscValues[dst] = values[j];
-
-                columnPointers[col]++;
-            }
-        }
-
-        // shift column pointers
-        for (int j = 0, last = 0; j <= numColumns; j++) {
-            int tmp = columnPointers[j];
-            columnPointers[j] = last;
-            last = tmp;
-        }
-
-        return new CSCFloatMatrix(columnPointers, rowIndices, cscValues, numRows, numColumns);
-    }
-
-    @Override
-    public CSRMatrixBuilder builder() {
-        return new CSRMatrixBuilder(values.length);
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/matrix/sparse/floats/DoKFloatMatrix.java b/core/src/main/java/hivemall/math/matrix/sparse/floats/DoKFloatMatrix.java
deleted file mode 100644
index 9153566..0000000
--- a/core/src/main/java/hivemall/math/matrix/sparse/floats/DoKFloatMatrix.java
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * 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 hivemall.math.matrix.sparse.floats;
-
-import hivemall.annotations.Experimental;
-import hivemall.math.matrix.AbstractMatrix;
-import hivemall.math.matrix.FloatMatrix;
-import hivemall.math.matrix.MatrixUtils;
-import hivemall.math.matrix.builders.DoKMatrixBuilder;
-import hivemall.math.vector.Vector;
-import hivemall.math.vector.VectorProcedure;
-import hivemall.utils.collections.maps.Long2FloatOpenHashTable;
-import hivemall.utils.collections.maps.Long2FloatOpenHashTable.IMapIterator;
-import hivemall.utils.lang.Preconditions;
-import hivemall.utils.lang.Primitives;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-/**
- * Dictionary Of Keys based sparse matrix.
- *
- * This is an efficient structure for constructing a sparse matrix incrementally.
- */
-@Experimental
-public final class DoKFloatMatrix extends AbstractMatrix implements FloatMatrix {
-
-    @Nonnull
-    private final Long2FloatOpenHashTable elements;
-    @Nonnegative
-    private int numRows;
-    @Nonnegative
-    private int numColumns;
-
-    public DoKFloatMatrix() {
-        this(0, 0);
-    }
-
-    public DoKFloatMatrix(@Nonnegative int numRows, @Nonnegative int numCols) {
-        this(numRows, numCols, 0.05f);
-    }
-
-    public DoKFloatMatrix(@Nonnegative int numRows, @Nonnegative int numCols,
-            @Nonnegative float sparsity) {
-        super();
-        Preconditions.checkArgument(sparsity >= 0.f && sparsity <= 1.f,
-            "Invalid Sparsity value: " + sparsity);
-        int initialCapacity = Math.max(16384, Math.round(numRows * numCols * sparsity));
-        this.elements = new Long2FloatOpenHashTable(initialCapacity);
-        elements.defaultReturnValue(0.f);
-        this.numRows = numRows;
-        this.numColumns = numCols;
-    }
-
-    public DoKFloatMatrix(@Nonnegative int initSize) {
-        super();
-        int initialCapacity = Math.max(initSize, 16384);
-        this.elements = new Long2FloatOpenHashTable(initialCapacity);
-        elements.defaultReturnValue(0.f);
-        this.numRows = 0;
-        this.numColumns = 0;
-    }
-
-    @Override
-    public boolean isSparse() {
-        return true;
-    }
-
-    @Override
-    public boolean isRowMajorMatrix() {
-        return false;
-    }
-
-    @Override
-    public boolean isColumnMajorMatrix() {
-        return false;
-    }
-
-    @Override
-    public boolean readOnly() {
-        return false;
-    }
-
-    @Override
-    public boolean swappable() {
-        return true;
-    }
-
-    @Override
-    public int nnz() {
-        return elements.size();
-    }
-
-    @Override
-    public int numRows() {
-        return numRows;
-    }
-
-    @Override
-    public int numColumns() {
-        return numColumns;
-    }
-
-    @Override
-    public int numColumns(@Nonnegative final int row) {
-        int count = 0;
-        for (int j = 0; j < numColumns; j++) {
-            long index = index(row, j);
-            if (elements.containsKey(index)) {
-                count++;
-            }
-        }
-        return count;
-    }
-
-    @Override
-    public double[] getRow(@Nonnegative final int index) {
-        double[] dst = row();
-        return getRow(index, dst);
-    }
-
-    @Override
-    public double[] getRow(@Nonnegative final int row, @Nonnull final double[] dst) {
-        checkRowIndex(row, numRows);
-
-        final int end = Math.min(dst.length, numColumns);
-        for (int col = 0; col < end; col++) {
-            long k = index(row, col);
-            float v = elements.get(k);
-            dst[col] = v;
-        }
-
-        return dst;
-    }
-
-    @Override
-    public float[] getRow(@Nonnegative final int row, @Nonnull final float[] dst) {
-        checkRowIndex(row, numRows);
-
-        final int end = Math.min(dst.length, numColumns);
-        for (int col = 0; col < end; col++) {
-            long k = index(row, col);
-            float v = elements.get(k);
-            dst[col] = v;
-        }
-
-        return dst;
-    }
-
-    @Override
-    public void getRow(@Nonnegative final int index, @Nonnull final Vector row) {
-        checkRowIndex(index, numRows);
-        row.clear();
-
-        for (int col = 0; col < numColumns; col++) {
-            long k = index(index, col);
-            final float v = elements.get(k, 0.f);
-            if (v != 0.f) {
-                row.set(col, v);
-            }
-        }
-    }
-
-    @Override
-    public float get(@Nonnegative final int row, @Nonnegative final int col,
-            final float defaultValue) {
-        long index = index(row, col);
-        return elements.get(index, defaultValue);
-    }
-
-    @Override
-    public void set(@Nonnegative final int row, @Nonnegative final int col, final float value) {
-        checkIndex(row, col);
-
-        long index = index(row, col);
-        elements.put(index, value);
-        this.numRows = Math.max(numRows, row + 1);
-        this.numColumns = Math.max(numColumns, col + 1);
-    }
-
-    @Override
-    public float getAndSet(@Nonnegative final int row, @Nonnegative final int col,
-            final float value) {
-        checkIndex(row, col);
-
-        long index = index(row, col);
-        float old = elements.put(index, value);
-        this.numRows = Math.max(numRows, row + 1);
-        this.numColumns = Math.max(numColumns, col + 1);
-        return old;
-    }
-
-    @Override
-    public void swap(@Nonnegative final int row1, @Nonnegative final int row2) {
-        checkRowIndex(row1, numRows);
-        checkRowIndex(row2, numRows);
-
-        for (int j = 0; j < numColumns; j++) {
-            final long i1 = index(row1, j);
-            final long i2 = index(row2, j);
-
-            final int k1 = elements._findKey(i1);
-            final int k2 = elements._findKey(i2);
-
-            if (k1 >= 0) {
-                if (k2 >= 0) {
-                    float v1 = elements._get(k1);
-                    float v2 = elements._set(k2, v1);
-                    elements._set(k1, v2);
-                } else {// k1>=0 and k2<0
-                    float v1 = elements._remove(k1);
-                    elements.put(i2, v1);
-                }
-            } else if (k2 >= 0) {// k2>=0 and k1 < 0
-                float v2 = elements._remove(k2);
-                elements.put(i1, v2);
-            } else {//k1<0 and k2<0
-                continue;
-            }
-        }
-    }
-
-    @Override
-    public void eachInRow(@Nonnegative final int row, @Nonnull final VectorProcedure procedure,
-            final boolean nullOutput) {
-        checkRowIndex(row, numRows);
-
-        for (int col = 0; col < numColumns; col++) {
-            long i = index(row, col);
-            final int key = elements._findKey(i);
-            if (key < 0) {
-                if (nullOutput) {
-                    procedure.apply(col, 0.f);
-                }
-            } else {
-                float v = elements._get(key);
-                procedure.apply(col, v);
-            }
-        }
-    }
-
-    @Override
-    public void eachNonZeroInRow(@Nonnegative final int row,
-            @Nonnull final VectorProcedure procedure) {
-        checkRowIndex(row, numRows);
-
-        for (int col = 0; col < numColumns; col++) {
-            long i = index(row, col);
-            final float v = elements.get(i, 0.f);
-            if (v != 0.f) {
-                procedure.apply(col, v);
-            }
-        }
-    }
-
-    @Override
-    public void eachColumnIndexInRow(int row, VectorProcedure procedure) {
-        checkRowIndex(row, numRows);
-
-        for (int col = 0; col < numColumns; col++) {
-            long i = index(row, col);
-            final int key = elements._findKey(i);
-            if (key != -1) {
-                procedure.apply(col);
-            }
-        }
-    }
-
-    @Override
-    public void eachInColumn(@Nonnegative final int col, @Nonnull final VectorProcedure procedure,
-            final boolean nullOutput) {
-        checkColIndex(col, numColumns);
-
-        for (int row = 0; row < numRows; row++) {
-            long i = index(row, col);
-            final int key = elements._findKey(i);
-            if (key < 0) {
-                if (nullOutput) {
-                    procedure.apply(row, 0.f);
-                }
-            } else {
-                float v = elements._get(key);
-                procedure.apply(row, v);
-            }
-        }
-    }
-
-    @Override
-    public void eachNonZeroInColumn(@Nonnegative final int col,
-            @Nonnull final VectorProcedure procedure) {
-        checkColIndex(col, numColumns);
-
-        for (int row = 0; row < numRows; row++) {
-            long i = index(row, col);
-            final float v = elements.get(i, 0.f);
-            if (v != 0.f) {
-                procedure.apply(row, v);
-            }
-        }
-    }
-
-    @Override
-    public void eachNonZeroCell(@Nonnull final VectorProcedure procedure) {
-        if (elements.size() == 0) {
-            return;
-        }
-        final IMapIterator itor = elements.entries();
-        while (itor.next() != -1) {
-            long k = itor.getKey();
-            int row = Primitives.getHigh(k);
-            int col = Primitives.getLow(k);
-            float value = itor.getValue();
-            procedure.apply(row, col, value);
-        }
-    }
-
-    @Override
-    public CSRFloatMatrix toRowMajorMatrix() {
-        final int nnz = elements.size();
-        final int[] rows = new int[nnz];
-        final int[] cols = new int[nnz];
-        final float[] data = new float[nnz];
-
-        final IMapIterator itor = elements.entries();
-        for (int i = 0; i < nnz; i++) {
-            if (itor.next() == -1) {
-                throw new IllegalStateException("itor.next() returns -1 where i=" + i);
-            }
-            long k = itor.getKey();
-            rows[i] = Primitives.getHigh(k);
-            cols[i] = Primitives.getLow(k);
-            data[i] = itor.getValue();
-        }
-
-        return MatrixUtils.coo2csr(rows, cols, data, numRows, numColumns, true);
-    }
-
-    @Override
-    public CSCFloatMatrix toColumnMajorMatrix() {
-        final int nnz = elements.size();
-        final int[] rows = new int[nnz];
-        final int[] cols = new int[nnz];
-        final float[] data = new float[nnz];
-
-        final IMapIterator itor = elements.entries();
-        for (int i = 0; i < nnz; i++) {
-            if (itor.next() == -1) {
-                throw new IllegalStateException("itor.next() returns -1 where i=" + i);
-            }
-            long k = itor.getKey();
-            rows[i] = Primitives.getHigh(k);
-            cols[i] = Primitives.getLow(k);
-            data[i] = itor.getValue();
-        }
-
-        return MatrixUtils.coo2csc(rows, cols, data, numRows, numColumns, true);
-    }
-
-    @Override
-    public DoKMatrixBuilder builder() {
-        return new DoKMatrixBuilder(elements.size());
-    }
-
-    @Nonnegative
-    private static long index(@Nonnegative final int row, @Nonnegative final int col) {
-        return Primitives.toLong(row, col);
-    }
-
-    @Override
-    public double get(@Nonnegative final int row, @Nonnegative final int col,
-            final double defaultValue) {
-        return get(row, col, (float) defaultValue);
-    }
-
-    @Override
-    public void set(@Nonnegative final int row, @Nonnegative final int col, final double value) {
-        set(row, col, (float) value);
-    }
-
-    @Override
-    public double getAndSet(@Nonnegative final int row, @Nonnegative final int col,
-            final double value) {
-        return getAndSet(row, col, (float) value);
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/vector/AbstractVector.java b/core/src/main/java/hivemall/math/vector/AbstractVector.java
deleted file mode 100644
index 53f65b3..0000000
--- a/core/src/main/java/hivemall/math/vector/AbstractVector.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 hivemall.math.vector;
-
-import javax.annotation.Nonnegative;
-
-public abstract class AbstractVector implements Vector {
-
-    public AbstractVector() {}
-
-    @Override
-    public double get(@Nonnegative final int index) {
-        return get(index, 0.d);
-    }
-
-    @Override
-    public float get(@Nonnegative final int index, final float defaultValue) {
-        return (float) get(index, (double) defaultValue);
-    }
-
-    @Override
-    public void set(@Nonnegative final int index, final float value) {
-        set(index, (double) value);
-    }
-
-    @Override
-    public void decr(int index, double delta) {
-        incr(index, -delta);
-    }
-
-    protected static final void checkIndex(final int index) {
-        if (index < 0) {
-            throw new IndexOutOfBoundsException("Invalid index " + index);
-        }
-    }
-
-    protected static final void checkIndex(final int index, final int size) {
-        if (index < 0 || index >= size) {
-            throw new IndexOutOfBoundsException("Index " + index + " out of bounds " + size);
-        }
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/vector/DenseFloatVector.java b/core/src/main/java/hivemall/math/vector/DenseFloatVector.java
deleted file mode 100644
index 2bb8144..0000000
--- a/core/src/main/java/hivemall/math/vector/DenseFloatVector.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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 hivemall.math.vector;
-
-import java.util.Arrays;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public final class DenseFloatVector extends AbstractVector {
-
-    @Nonnull
-    private final float[] values;
-    private final int size;
-
-    public DenseFloatVector(@Nonnegative int size) {
-        super();
-        this.values = new float[size];
-        this.size = size;
-    }
-
-    public DenseFloatVector(@Nonnull float[] values) {
-        super();
-        this.values = values;
-        this.size = values.length;
-    }
-
-    @Override
-    public float get(@Nonnegative final int index, final float defaultValue) {
-        checkIndex(index);
-        if (index >= size) {
-            return defaultValue;
-        }
-
-        return values[index];
-    }
-
-    @Override
-    public double get(@Nonnegative final int index, final double defaultValue) {
-        checkIndex(index);
-        if (index >= size) {
-            return defaultValue;
-        }
-
-        return values[index];
-    }
-
-    @Override
-    public void set(@Nonnegative final int index, final float value) {
-        checkIndex(index, size);
-
-        values[index] = value;
-    }
-
-    @Override
-    public void set(@Nonnegative final int index, final double value) {
-        checkIndex(index, size);
-
-        values[index] = (float) value;
-    }
-
-    @Override
-    public void incr(@Nonnegative final int index, final double delta) {
-        checkIndex(index, size);
-
-        values[index] += delta;
-    }
-
-    @Override
-    public void each(@Nonnull final VectorProcedure procedure) {
-        for (int i = 0; i < values.length; i++) {
-            procedure.apply(i, values[i]);
-        }
-    }
-
-    @Override
-    public int size() {
-        return size;
-    }
-
-    @Override
-    public void clear() {
-        Arrays.fill(values, 0.f);
-    }
-
-    @Override
-    public double[] toArray() {
-        throw new UnsupportedOperationException();
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/vector/DenseVector.java b/core/src/main/java/hivemall/math/vector/DenseVector.java
deleted file mode 100644
index bd39af1..0000000
--- a/core/src/main/java/hivemall/math/vector/DenseVector.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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 hivemall.math.vector;
-
-import java.util.Arrays;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public final class DenseVector extends AbstractVector {
-
-    @Nonnull
-    private final double[] values;
-    private final int size;
-
-    public DenseVector(@Nonnegative int size) {
-        super();
-        this.values = new double[size];
-        this.size = size;
-    }
-
-    public DenseVector(@Nonnull double[] values) {
-        super();
-        this.values = values;
-        this.size = values.length;
-    }
-
-    @Override
-    public double get(@Nonnegative final int index, final double defaultValue) {
-        checkIndex(index);
-        if (index >= size) {
-            return defaultValue;
-        }
-
-        return values[index];
-    }
-
-    @Override
-    public void set(@Nonnegative final int index, final double value) {
-        checkIndex(index, size);
-
-        values[index] = value;
-    }
-
-    @Override
-    public void incr(@Nonnegative final int index, final double delta) {
-        checkIndex(index, size);
-
-        values[index] += delta;
-    }
-
-    @Override
-    public void each(@Nonnull final VectorProcedure procedure) {
-        for (int i = 0; i < values.length; i++) {
-            procedure.apply(i, values[i]);
-        }
-    }
-
-    @Override
-    public int size() {
-        return size;
-    }
-
-    @Override
-    public void clear() {
-        Arrays.fill(values, 0.d);
-    }
-
-    @Override
-    public double[] toArray() {
-        return values;
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/vector/SparseFloatVector.java b/core/src/main/java/hivemall/math/vector/SparseFloatVector.java
deleted file mode 100644
index 91391b5..0000000
--- a/core/src/main/java/hivemall/math/vector/SparseFloatVector.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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 hivemall.math.vector;
-
-import hivemall.utils.collections.arrays.SparseFloatArray;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public final class SparseFloatVector extends AbstractVector {
-
-    @Nonnull
-    private final SparseFloatArray values;
-
-    public SparseFloatVector() {
-        super();
-        this.values = new SparseFloatArray();
-    }
-
-    public SparseFloatVector(@Nonnull SparseFloatArray values) {
-        super();
-        this.values = values;
-    }
-
-    @Override
-    public float get(@Nonnegative final int index, final float defaultValue) {
-        return values.get(index, defaultValue);
-    }
-
-    @Override
-    public double get(@Nonnegative final int index, final double defaultValue) {
-        return values.get(index, (float) defaultValue);
-    }
-
-    @Override
-    public void set(@Nonnegative final int index, final float value) {
-        values.put(index, value);
-    }
-
-    @Override
-    public void set(@Nonnegative final int index, final double value) {
-        values.put(index, (float) value);
-    }
-
-    @Override
-    public void incr(@Nonnegative final int index, final double delta) {
-        values.increment(index, (float) delta);
-    }
-
-    @Override
-    public void each(@Nonnull final VectorProcedure procedure) {
-        values.each(procedure);
-    }
-
-    @Override
-    public int size() {
-        return values.size();
-    }
-
-    @Override
-    public void clear() {
-        values.clear();
-    }
-
-    @Override
-    public double[] toArray() {
-        throw new UnsupportedOperationException();
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/vector/SparseVector.java b/core/src/main/java/hivemall/math/vector/SparseVector.java
deleted file mode 100644
index 072b544..0000000
--- a/core/src/main/java/hivemall/math/vector/SparseVector.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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 hivemall.math.vector;
-
-import hivemall.utils.collections.arrays.SparseDoubleArray;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public final class SparseVector extends AbstractVector {
-
-    @Nonnull
-    private final SparseDoubleArray values;
-
-    public SparseVector() {
-        super();
-        this.values = new SparseDoubleArray();
-    }
-
-    public SparseVector(@Nonnull SparseDoubleArray values) {
-        super();
-        this.values = values;
-    }
-
-    @Override
-    public double get(@Nonnegative final int index, final double defaultValue) {
-        return values.get(index, defaultValue);
-    }
-
-    @Override
-    public void set(@Nonnegative final int index, final double value) {
-        values.put(index, value);
-    }
-
-    @Override
-    public void incr(@Nonnegative final int index, final double delta) {
-        values.increment(index, delta);
-    }
-
-    @Override
-    public void each(@Nonnull final VectorProcedure procedure) {
-        values.each(procedure);
-    }
-
-    @Override
-    public int size() {
-        return values.size();
-    }
-
-    @Override
-    public void clear() {
-        values.clear();
-    }
-
-    @Override
-    public double[] toArray() {
-        return values.toArray();
-    }
-
-}
diff --git a/core/src/main/java/hivemall/math/vector/Vector.java b/core/src/main/java/hivemall/math/vector/Vector.java
deleted file mode 100644
index a032e86..0000000
--- a/core/src/main/java/hivemall/math/vector/Vector.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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 hivemall.math.vector;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public interface Vector {
-
-    public double get(@Nonnegative int index);
-
-    public float get(@Nonnegative int index, float defaultValue);
-
-    public double get(@Nonnegative int index, double defaultValue);
-
-    /**
-     * @throws UnsupportedOperationException
-     */
-    public void set(@Nonnegative int index, double value);
-
-    /**
-     * @throws UnsupportedOperationException
-     */
-    public void set(@Nonnegative int index, float value);
-
-    public void incr(@Nonnegative int index, double delta);
-
-    public void decr(@Nonnegative int index, double delta);
-
-    public void each(@Nonnull VectorProcedure procedure);
-
-    public int size();
-
-    public void clear();
-
-    @Nonnull
-    public double[] toArray();
-
-}
diff --git a/core/src/main/java/hivemall/math/vector/VectorProcedure.java b/core/src/main/java/hivemall/math/vector/VectorProcedure.java
deleted file mode 100644
index 8ce473b..0000000
--- a/core/src/main/java/hivemall/math/vector/VectorProcedure.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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 hivemall.math.vector;
-
-import javax.annotation.Nonnegative;
-import javax.annotation.Nonnull;
-
-public abstract class VectorProcedure {
-
-    public VectorProcedure() {}
-
-    public void apply(@Nonnegative int i, @Nonnegative int j, float value) {
-        apply(i, j, (double) value);
-    }
-
-    public void apply(@Nonnegative int i, @Nonnegative int j, double value) {}
-
-    public void apply(@Nonnegative int i, float value) {
-        apply(i, (double) value);
-    }
-
-    public void apply(@Nonnegative int i, double value) {}
-
-    public void apply(@Nonnegative int i, int value) {}
-
-    public void apply(@Nonnegative int i) {}
-
-    public void apply(@Nonnegative int i, @Nonnull int[] values) {}
-
-}
diff --git a/core/src/main/java/hivemall/recommend/SlimUDTF.java b/core/src/main/java/hivemall/recommend/SlimUDTF.java
index a047e6f..a43b931 100644
--- a/core/src/main/java/hivemall/recommend/SlimUDTF.java
+++ b/core/src/main/java/hivemall/recommend/SlimUDTF.java
@@ -21,9 +21,9 @@ package hivemall.recommend;
 import hivemall.UDTFWithOptions;
 import hivemall.annotations.VisibleForTesting;
 import hivemall.common.ConversionState;
-import hivemall.math.matrix.FloatMatrix;
-import hivemall.math.matrix.sparse.floats.DoKFloatMatrix;
-import hivemall.math.vector.VectorProcedure;
+import matrix4j.matrix.FloatMatrix;
+import matrix4j.matrix.sparse.floats.DoKFloatMatrix;
+import matrix4j.vector.VectorProcedure;
 import hivemall.utils.collections.Fastutil;
 import hivemall.utils.hadoop.HiveUtils;
 import hivemall.utils.io.FileUtils;
diff --git a/core/src/main/java/hivemall/smile/classification/DecisionTree.java b/core/src/main/java/hivemall/smile/classification/DecisionTree.java
index 2d89e55..65f8f2e 100644
--- a/core/src/main/java/hivemall/smile/classification/DecisionTree.java
+++ b/core/src/main/java/hivemall/smile/classification/DecisionTree.java
@@ -27,11 +27,11 @@ import static hivemall.smile.utils.SmileExtUtils.resolveFeatureName;
 import static hivemall.smile.utils.SmileExtUtils.resolveName;
 
 import hivemall.annotations.VisibleForTesting;
-import hivemall.math.matrix.Matrix;
-import hivemall.math.vector.DenseVector;
-import hivemall.math.vector.SparseVector;
-import hivemall.math.vector.Vector;
-import hivemall.math.vector.VectorProcedure;
+import matrix4j.matrix.Matrix;
+import matrix4j.vector.DenseVector;
+import matrix4j.vector.SparseVector;
+import matrix4j.vector.Vector;
+import matrix4j.vector.VectorProcedure;
 import hivemall.smile.utils.SmileExtUtils;
 import hivemall.smile.utils.VariableOrder;
 import hivemall.utils.collections.arrays.SparseIntArray;
diff --git a/core/src/main/java/hivemall/smile/classification/GradientTreeBoostingClassifierUDTF.java b/core/src/main/java/hivemall/smile/classification/GradientTreeBoostingClassifierUDTF.java
index ad3f178..7b1a036 100644
--- a/core/src/main/java/hivemall/smile/classification/GradientTreeBoostingClassifierUDTF.java
+++ b/core/src/main/java/hivemall/smile/classification/GradientTreeBoostingClassifierUDTF.java
@@ -19,14 +19,14 @@
 package hivemall.smile.classification;
 
 import hivemall.UDTFWithOptions;
-import hivemall.math.matrix.Matrix;
-import hivemall.math.matrix.builders.CSRMatrixBuilder;
-import hivemall.math.matrix.builders.MatrixBuilder;
-import hivemall.math.matrix.builders.RowMajorDenseMatrixBuilder;
-import hivemall.math.vector.DenseVector;
-import hivemall.math.vector.SparseVector;
-import hivemall.math.vector.Vector;
-import hivemall.math.vector.VectorProcedure;
+import matrix4j.matrix.Matrix;
+import matrix4j.matrix.builders.CSRMatrixBuilder;
+import matrix4j.matrix.builders.MatrixBuilder;
+import matrix4j.matrix.builders.RowMajorDenseMatrixBuilder;
+import matrix4j.vector.DenseVector;
+import matrix4j.vector.SparseVector;
+import matrix4j.vector.Vector;
+import matrix4j.vector.VectorProcedure;
 import hivemall.smile.regression.RegressionTree;
 import hivemall.smile.utils.SmileExtUtils;
 import hivemall.utils.codec.Base91;
diff --git a/core/src/main/java/hivemall/smile/classification/RandomForestClassifierUDTF.java b/core/src/main/java/hivemall/smile/classification/RandomForestClassifierUDTF.java
index c9b00df..4fe08df 100644
--- a/core/src/main/java/hivemall/smile/classification/RandomForestClassifierUDTF.java
+++ b/core/src/main/java/hivemall/smile/classification/RandomForestClassifierUDTF.java
@@ -19,15 +19,15 @@
 package hivemall.smile.classification;
 
 import hivemall.UDTFWithOptions;
-import hivemall.math.matrix.Matrix;
-import hivemall.math.matrix.MatrixUtils;
-import hivemall.math.matrix.builders.CSRMatrixBuilder;
-import hivemall.math.matrix.builders.MatrixBuilder;
-import hivemall.math.matrix.builders.RowMajorDenseMatrixBuilder;
-import hivemall.math.matrix.ints.DoKIntMatrix;
-import hivemall.math.matrix.ints.IntMatrix;
-import hivemall.math.vector.Vector;
-import hivemall.math.vector.VectorProcedure;
+import matrix4j.matrix.Matrix;
+import matrix4j.matrix.MatrixUtils;
+import matrix4j.matrix.builders.CSRMatrixBuilder;
+import matrix4j.matrix.builders.MatrixBuilder;
+import matrix4j.matrix.builders.RowMajorDenseMatrixBuilder;
+import matrix4j.matrix.ints.DoKIntMatrix;
+import matrix4j.matrix.ints.IntMatrix;
+import matrix4j.vector.Vector;
+import matrix4j.vector.VectorProcedure;
 import hivemall.smile.classification.DecisionTree.SplitRule;
 import hivemall.smile.utils.SmileExtUtils;
 import hivemall.smile.utils.SmileTaskExecutor;
diff --git a/core/src/main/java/hivemall/smile/regression/RandomForestRegressionUDTF.java b/core/src/main/java/hivemall/smile/regression/RandomForestRegressionUDTF.java
index 6b3b1a2..75af989 100644
--- a/core/src/main/java/hivemall/smile/regression/RandomForestRegressionUDTF.java
+++ b/core/src/main/java/hivemall/smile/regression/RandomForestRegressionUDTF.java
@@ -19,12 +19,12 @@
 package hivemall.smile.regression;
 
 import hivemall.UDTFWithOptions;
-import hivemall.math.matrix.Matrix;
-import hivemall.math.matrix.builders.CSRMatrixBuilder;
-import hivemall.math.matrix.builders.MatrixBuilder;
-import hivemall.math.matrix.builders.RowMajorDenseMatrixBuilder;
-import hivemall.math.vector.Vector;
-import hivemall.math.vector.VectorProcedure;
+import matrix4j.matrix.Matrix;
+import matrix4j.matrix.builders.CSRMatrixBuilder;
+import matrix4j.matrix.builders.MatrixBuilder;
+import matrix4j.matrix.builders.RowMajorDenseMatrixBuilder;
+import matrix4j.vector.Vector;
+import matrix4j.vector.VectorProcedure;
 import hivemall.smile.utils.SmileExtUtils;
 import hivemall.smile.utils.SmileTaskExecutor;
 import hivemall.utils.codec.Base91;
diff --git a/core/src/main/java/hivemall/smile/regression/RegressionTree.java b/core/src/main/java/hivemall/smile/regression/RegressionTree.java
index a22ea68..00f521c 100755
--- a/core/src/main/java/hivemall/smile/regression/RegressionTree.java
+++ b/core/src/main/java/hivemall/smile/regression/RegressionTree.java
@@ -26,11 +26,11 @@ import static hivemall.smile.utils.SmileExtUtils.NUMERIC;
 import static hivemall.smile.utils.SmileExtUtils.resolveFeatureName;
 
 import hivemall.annotations.VisibleForTesting;
-import hivemall.math.matrix.Matrix;
-import hivemall.math.vector.DenseVector;
-import hivemall.math.vector.SparseVector;
-import hivemall.math.vector.Vector;
-import hivemall.math.vector.VectorProcedure;
+import matrix4j.matrix.Matrix;
+import matrix4j.vector.DenseVector;
+import matrix4j.vector.SparseVector;
+import matrix4j.vector.Vector;
+import matrix4j.vector.VectorProcedure;
 import hivemall.smile.classification.PredictionHandler;
 import hivemall.smile.utils.SmileExtUtils;
 import hivemall.smile.utils.VariableOrder;
diff --git a/core/src/main/java/hivemall/smile/tools/DecisionPathUDF.java b/core/src/main/java/hivemall/smile/tools/DecisionPathUDF.java
index 11a05da..fe1dc18 100644
--- a/core/src/main/java/hivemall/smile/tools/DecisionPathUDF.java
+++ b/core/src/main/java/hivemall/smile/tools/DecisionPathUDF.java
@@ -19,9 +19,9 @@
 package hivemall.smile.tools;
 
 import hivemall.UDFWithOptions;
-import hivemall.math.vector.DenseVector;
-import hivemall.math.vector.SparseVector;
-import hivemall.math.vector.Vector;
+import matrix4j.vector.DenseVector;
+import matrix4j.vector.SparseVector;
+import matrix4j.vector.Vector;
 import hivemall.smile.classification.DecisionTree;
 import hivemall.smile.classification.PredictionHandler;
 import hivemall.smile.regression.RegressionTree;
diff --git a/core/src/main/java/hivemall/smile/tools/TreePredictUDF.java b/core/src/main/java/hivemall/smile/tools/TreePredictUDF.java
index 262a28d..08360f1 100644
--- a/core/src/main/java/hivemall/smile/tools/TreePredictUDF.java
+++ b/core/src/main/java/hivemall/smile/tools/TreePredictUDF.java
@@ -19,9 +19,9 @@
 package hivemall.smile.tools;
 
 import hivemall.UDFWithOptions;
-import hivemall.math.vector.DenseVector;
-import hivemall.math.vector.SparseVector;
-import hivemall.math.vector.Vector;
+import matrix4j.vector.DenseVector;
+import matrix4j.vector.SparseVector;
+import matrix4j.vector.Vector;
 import hivemall.smile.classification.DecisionTree;
 import hivemall.smile.classification.PredictionHandler;
 import hivemall.smile.regression.RegressionTree;
diff --git a/core/src/main/java/hivemall/smile/utils/SmileExtUtils.java b/core/src/main/java/hivemall/smile/utils/SmileExtUtils.java
index 6d1a514..b41f288 100644
--- a/core/src/main/java/hivemall/smile/utils/SmileExtUtils.java
+++ b/core/src/main/java/hivemall/smile/utils/SmileExtUtils.java
@@ -19,10 +19,10 @@
 package hivemall.smile.utils;
 
 import hivemall.annotations.VisibleForTesting;
-import hivemall.math.matrix.ColumnMajorMatrix;
-import hivemall.math.matrix.Matrix;
-import hivemall.math.matrix.MatrixUtils;
-import hivemall.math.vector.VectorProcedure;
+import matrix4j.matrix.ColumnMajorMatrix;
+import matrix4j.matrix.Matrix;
+import matrix4j.matrix.MatrixUtils;
+import matrix4j.vector.VectorProcedure;
 import hivemall.smile.classification.DecisionTree.SplitRule;
 import hivemall.utils.collections.arrays.SparseIntArray;
 import hivemall.utils.collections.lists.DoubleArrayList;
diff --git a/core/src/main/java/hivemall/utils/collections/arrays/SparseDoubleArray.java b/core/src/main/java/hivemall/utils/collections/arrays/SparseDoubleArray.java
index ac41951..5ec0b7d 100644
--- a/core/src/main/java/hivemall/utils/collections/arrays/SparseDoubleArray.java
+++ b/core/src/main/java/hivemall/utils/collections/arrays/SparseDoubleArray.java
@@ -18,7 +18,7 @@
  */
 package hivemall.utils.collections.arrays;
 
-import hivemall.math.vector.VectorProcedure;
+import matrix4j.vector.VectorProcedure;
 import hivemall.utils.lang.ArrayUtils;
 import hivemall.utils.lang.Preconditions;
 
diff --git a/core/src/main/java/hivemall/utils/collections/arrays/SparseFloatArray.java b/core/src/main/java/hivemall/utils/collections/arrays/SparseFloatArray.java
index 4b38c7d..96d742d 100644
--- a/core/src/main/java/hivemall/utils/collections/arrays/SparseFloatArray.java
+++ b/core/src/main/java/hivemall/utils/collections/arrays/SparseFloatArray.java
@@ -18,7 +18,7 @@
  */
 package hivemall.utils.collections.arrays;
 
-import hivemall.math.vector.VectorProcedure;
+import matrix4j.vector.VectorProcedure;
 import hivemall.utils.lang.ArrayUtils;
 import hivemall.utils.lang.Preconditions;
 
diff --git a/core/src/test/java/hivemall/math/matrix/MatrixBuilderTest.java b/core/src/test/java/hivemall/math/matrix/MatrixBuilderTest.java
deleted file mode 100644
index 0cf65c0..0000000
--- a/core/src/test/java/hivemall/math/matrix/MatrixBuilderTest.java
+++ /dev/null
@@ -1,664 +0,0 @@
-/*
- * 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 hivemall.math.matrix;
-
-import hivemall.math.matrix.builders.CSCMatrixBuilder;
-import hivemall.math.matrix.builders.CSRMatrixBuilder;
-import hivemall.math.matrix.builders.ColumnMajorDenseMatrixBuilder;
-import hivemall.math.matrix.builders.DoKMatrixBuilder;
-import hivemall.math.matrix.builders.RowMajorDenseMatrixBuilder;
-import hivemall.math.matrix.dense.ColumnMajorDenseMatrix2d;
-import hivemall.math.matrix.dense.RowMajorDenseMatrix2d;
-import hivemall.math.matrix.sparse.CSCMatrix;
-import hivemall.math.matrix.sparse.CSRMatrix;
-import hivemall.math.matrix.sparse.DoKMatrix;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class MatrixBuilderTest {
-
-    @Test
-    public void testReadOnlyCSRMatrix() {
-        Matrix matrix = csrMatrix();
-        Assert.assertEquals(6, matrix.numRows());
-        Assert.assertEquals(6, matrix.numColumns());
-        Assert.assertEquals(4, matrix.numColumns(0));
-        Assert.assertEquals(2, matrix.numColumns(1));
-        Assert.assertEquals(4, matrix.numColumns(2));
-        Assert.assertEquals(2, matrix.numColumns(3));
-        Assert.assertEquals(1, matrix.numColumns(4));
-        Assert.assertEquals(1, matrix.numColumns(5));
-
-        Assert.assertEquals(11d, matrix.get(0, 0), 0.d);
-        Assert.assertEquals(12d, matrix.get(0, 1), 0.d);
-        Assert.assertEquals(13d, matrix.get(0, 2), 0.d);
-        Assert.assertEquals(14d, matrix.get(0, 3), 0.d);
-        Assert.assertEquals(22d, matrix.get(1, 1), 0.d);
-        Assert.assertEquals(23d, matrix.get(1, 2), 0.d);
-        Assert.assertEquals(33d, matrix.get(2, 2), 0.d);
-        Assert.assertEquals(34d, matrix.get(2, 3), 0.d);
-        Assert.assertEquals(35d, matrix.get(2, 4), 0.d);
-        Assert.assertEquals(36d, matrix.get(2, 5), 0.d);
-        Assert.assertEquals(44d, matrix.get(3, 3), 0.d);
-        Assert.assertEquals(45d, matrix.get(3, 4), 0.d);
-        Assert.assertEquals(56d, matrix.get(4, 5), 0.d);
-        Assert.assertEquals(66d, matrix.get(5, 5), 0.d);
-
-        Assert.assertEquals(0.d, matrix.get(5, 4), 0.d);
-        Assert.assertEquals(-1.d, matrix.get(5, 4, -1.d), 0.d);
-
-        Assert.assertEquals(Double.NaN, matrix.get(5, 4, Double.NaN), 0.d);
-    }
-
-    @Test
-    public void testReadOnlyCSRMatrixFromLibSVM() {
-        Matrix matrix = csrMatrixFromLibSVM();
-        Assert.assertEquals(6, matrix.numRows());
-        Assert.assertEquals(6, matrix.numColumns());
-        Assert.assertEquals(4, matrix.numColumns(0));
-        Assert.assertEquals(2, matrix.numColumns(1));
-        Assert.assertEquals(4, matrix.numColumns(2));
-        Assert.assertEquals(2, matrix.numColumns(3));
-        Assert.assertEquals(1, matrix.numColumns(4));
-        Assert.assertEquals(1, matrix.numColumns(5));
-
-        Assert.assertEquals(11d, matrix.get(0, 0), 0.d);
-        Assert.assertEquals(12d, matrix.get(0, 1), 0.d);
-        Assert.assertEquals(13d, matrix.get(0, 2), 0.d);
-        Assert.assertEquals(14d, matrix.get(0, 3), 0.d);
-        Assert.assertEquals(22d, matrix.get(1, 1), 0.d);
-        Assert.assertEquals(23d, matrix.get(1, 2), 0.d);
-        Assert.assertEquals(33d, matrix.get(2, 2), 0.d);
-        Assert.assertEquals(34d, matrix.get(2, 3), 0.d);
-        Assert.assertEquals(35d, matrix.get(2, 4), 0.d);
-        Assert.assertEquals(36d, matrix.get(2, 5), 0.d);
-        Assert.assertEquals(44d, matrix.get(3, 3), 0.d);
-        Assert.assertEquals(45d, matrix.get(3, 4), 0.d);
-        Assert.assertEquals(56d, matrix.get(4, 5), 0.d);
-        Assert.assertEquals(66d, matrix.get(5, 5), 0.d);
-
-        Assert.assertEquals(0.d, matrix.get(5, 4), 0.d);
-        Assert.assertEquals(-1.d, matrix.get(5, 4, -1.d), 0.d);
-
-        Assert.assertEquals(Double.NaN, matrix.get(5, 4, Double.NaN), 0.d);
-    }
-
-    @Test
-    public void testReadOnlyCSRMatrixNoRow() {
-        CSRMatrixBuilder builder = new CSRMatrixBuilder(1024);
-        Matrix matrix = builder.buildMatrix();
-        Assert.assertEquals(0, matrix.numRows());
-        Assert.assertEquals(0, matrix.numColumns());
-    }
-
-    @Test(expected = IndexOutOfBoundsException.class)
-    public void testReadOnlyCSRMatrixGetFail1() {
-        Matrix matrix = csrMatrix();
-        matrix.get(7, 5);
-    }
-
-    @Test(expected = IndexOutOfBoundsException.class)
-    public void testReadOnlyCSRMatrixGetFail2() {
-        Matrix matrix = csrMatrix();
-        matrix.get(6, 7);
-    }
-
-    @Test
-    public void testCSCMatrixFromLibSVM() {
-        CSCMatrix matrix = cscMatrixFromLibSVM();
-        Assert.assertEquals(6, matrix.numRows());
-        Assert.assertEquals(6, matrix.numColumns());
-        Assert.assertEquals(4, matrix.numColumns(0));
-        Assert.assertEquals(2, matrix.numColumns(1));
-        Assert.assertEquals(4, matrix.numColumns(2));
-        Assert.assertEquals(2, matrix.numColumns(3));
-        Assert.assertEquals(1, matrix.numColumns(4));
-        Assert.assertEquals(1, matrix.numColumns(5));
-
-        Assert.assertEquals(11d, matrix.get(0, 0), 0.d);
-        Assert.assertEquals(12d, matrix.get(0, 1), 0.d);
-        Assert.assertEquals(13d, matrix.get(0, 2), 0.d);
-        Assert.assertEquals(14d, matrix.get(0, 3), 0.d);
-        Assert.assertEquals(22d, matrix.get(1, 1), 0.d);
-        Assert.assertEquals(23d, matrix.get(1, 2), 0.d);
-        Assert.assertEquals(33d, matrix.get(2, 2), 0.d);
-        Assert.assertEquals(34d, matrix.get(2, 3), 0.d);
-        Assert.assertEquals(35d, matrix.get(2, 4), 0.d);
-        Assert.assertEquals(36d, matrix.get(2, 5), 0.d);
-        Assert.assertEquals(44d, matrix.get(3, 3), 0.d);
-        Assert.assertEquals(45d, matrix.get(3, 4), 0.d);
-        Assert.assertEquals(56d, matrix.get(4, 5), 0.d);
-        Assert.assertEquals(66d, matrix.get(5, 5), 0.d);
-
-        Assert.assertEquals(0.d, matrix.get(5, 4), 0.d);
-        Assert.assertEquals(-1.d, matrix.get(5, 4, -1.d), 0.d);
-
-        Assert.assertEquals(Double.NaN, matrix.get(5, 4, Double.NaN), 0.d);
-    }
-
-    @Test
-    public void testCSC2CSR() {
-        CSCMatrix csc = cscMatrixFromLibSVM();
-        RowMajorMatrix csr = csc.toRowMajorMatrix();
-        Assert.assertEquals(csc.toString(), csr.toString());
-
-        Assert.assertTrue(csr instanceof CSRMatrix);
-        Assert.assertEquals(6, csr.numRows());
-        Assert.assertEquals(6, csr.numColumns());
-        Assert.assertEquals(4, csr.numColumns(0));
-        Assert.assertEquals(2, csr.numColumns(1));
-        Assert.assertEquals(4, csr.numColumns(2));
-        Assert.assertEquals(2, csr.numColumns(3));
-        Assert.assertEquals(1, csr.numColumns(4));
-        Assert.assertEquals(1, csr.numColumns(5));
-
-        Assert.assertEquals(11d, csr.get(0, 0), 0.d);
-        Assert.assertEquals(12d, csr.get(0, 1), 0.d);
-        Assert.assertEquals(13d, csr.get(0, 2), 0.d);
-        Assert.assertEquals(14d, csr.get(0, 3), 0.d);
-        Assert.assertEquals(22d, csr.get(1, 1), 0.d);
-        Assert.assertEquals(23d, csr.get(1, 2), 0.d);
-        Assert.assertEquals(33d, csr.get(2, 2), 0.d);
-        Assert.assertEquals(34d, csr.get(2, 3), 0.d);
-        Assert.assertEquals(35d, csr.get(2, 4), 0.d);
-        Assert.assertEquals(36d, csr.get(2, 5), 0.d);
-        Assert.assertEquals(44d, csr.get(3, 3), 0.d);
-        Assert.assertEquals(45d, csr.get(3, 4), 0.d);
-        Assert.assertEquals(56d, csr.get(4, 5), 0.d);
-        Assert.assertEquals(66d, csr.get(5, 5), 0.d);
-
-        Assert.assertEquals(0.d, csr.get(5, 4), 0.d);
-        Assert.assertEquals(-1.d, csr.get(5, 4, -1.d), 0.d);
-
-        Assert.assertEquals(Double.NaN, csr.get(5, 4, Double.NaN), 0.d);
-    }
-
-    @Test
-    public void testCSC2CSR2CSR() {
-        CSCMatrix csc = cscMatrixFromLibSVM();
-        CSCMatrix csc2 = csc.toRowMajorMatrix().toColumnMajorMatrix();
-        Assert.assertEquals(csc.nnz(), csc2.nnz());
-        Assert.assertEquals(6, csc2.numRows());
-        Assert.assertEquals(6, csc2.numColumns());
-        Assert.assertEquals(4, csc2.numColumns(0));
-        Assert.assertEquals(2, csc2.numColumns(1));
-        Assert.assertEquals(4, csc2.numColumns(2));
-        Assert.assertEquals(2, csc2.numColumns(3));
-        Assert.assertEquals(1, csc2.numColumns(4));
-        Assert.assertEquals(1, csc2.numColumns(5));
-
-        Assert.assertEquals(11d, csc2.get(0, 0), 0.d);
-        Assert.assertEquals(12d, csc2.get(0, 1), 0.d);
-        Assert.assertEquals(13d, csc2.get(0, 2), 0.d);
-        Assert.assertEquals(14d, csc2.get(0, 3), 0.d);
-        Assert.assertEquals(22d, csc2.get(1, 1), 0.d);
-        Assert.assertEquals(23d, csc2.get(1, 2), 0.d);
-        Assert.assertEquals(33d, csc2.get(2, 2), 0.d);
-        Assert.assertEquals(34d, csc2.get(2, 3), 0.d);
-        Assert.assertEquals(35d, csc2.get(2, 4), 0.d);
-        Assert.assertEquals(36d, csc2.get(2, 5), 0.d);
-        Assert.assertEquals(44d, csc2.get(3, 3), 0.d);
-        Assert.assertEquals(45d, csc2.get(3, 4), 0.d);
-        Assert.assertEquals(56d, csc2.get(4, 5), 0.d);
-        Assert.assertEquals(66d, csc2.get(5, 5), 0.d);
-
-        Assert.assertEquals(0.d, csc2.get(5, 4), 0.d);
-        Assert.assertEquals(-1.d, csc2.get(5, 4, -1.d), 0.d);
-
-        Assert.assertEquals(Double.NaN, csc2.get(5, 4, Double.NaN), 0.d);
-    }
-
-    @Test
-    public void testDoKMatrixFromLibSVM() {
-        Matrix matrix = dokMatrixFromLibSVM();
-        Assert.assertEquals(6, matrix.numRows());
-        Assert.assertEquals(6, matrix.numColumns());
-        Assert.assertEquals(4, matrix.numColumns(0));
-        Assert.assertEquals(2, matrix.numColumns(1));
-        Assert.assertEquals(4, matrix.numColumns(2));
-        Assert.assertEquals(2, matrix.numColumns(3));
-        Assert.assertEquals(1, matrix.numColumns(4));
-        Assert.assertEquals(1, matrix.numColumns(5));
-
-        Assert.assertEquals(11d, matrix.get(0, 0), 0.d);
-        Assert.assertEquals(12d, matrix.get(0, 1), 0.d);
-        Assert.assertEquals(13d, matrix.get(0, 2), 0.d);
-        Assert.assertEquals(14d, matrix.get(0, 3), 0.d);
-        Assert.assertEquals(22d, matrix.get(1, 1), 0.d);
-        Assert.assertEquals(23d, matrix.get(1, 2), 0.d);
-        Assert.assertEquals(33d, matrix.get(2, 2), 0.d);
-        Assert.assertEquals(34d, matrix.get(2, 3), 0.d);
-        Assert.assertEquals(35d, matrix.get(2, 4), 0.d);
-        Assert.assertEquals(36d, matrix.get(2, 5), 0.d);
-        Assert.assertEquals(44d, matrix.get(3, 3), 0.d);
-        Assert.assertEquals(45d, matrix.get(3, 4), 0.d);
-        Assert.assertEquals(56d, matrix.get(4, 5), 0.d);
-        Assert.assertEquals(66d, matrix.get(5, 5), 0.d);
-
-        Assert.assertEquals(0.d, matrix.get(5, 4), 0.d);
-        Assert.assertEquals(-1.d, matrix.get(5, 4, -1.d), 0.d);
-
-        Assert.assertEquals(Double.NaN, matrix.get(5, 4, Double.NaN), 0.d);
-    }
-
-    @Test
-    public void testReadOnlyDenseMatrix2d() {
-        Matrix matrix = rowMajorDenseMatrix();
-        Assert.assertEquals(6, matrix.numRows());
-        Assert.assertEquals(6, matrix.numColumns());
-        Assert.assertEquals(4, matrix.numColumns(0));
-        Assert.assertEquals(3, matrix.numColumns(1));
-        Assert.assertEquals(6, matrix.numColumns(2));
-        Assert.assertEquals(5, matrix.numColumns(3));
-        Assert.assertEquals(6, matrix.numColumns(4));
-        Assert.assertEquals(6, matrix.numColumns(5));
-
-        Assert.assertEquals(11d, matrix.get(0, 0), 0.d);
-        Assert.assertEquals(12d, matrix.get(0, 1), 0.d);
-        Assert.assertEquals(13d, matrix.get(0, 2), 0.d);
-        Assert.assertEquals(14d, matrix.get(0, 3), 0.d);
-        Assert.assertEquals(22d, matrix.get(1, 1), 0.d);
-        Assert.assertEquals(23d, matrix.get(1, 2), 0.d);
-        Assert.assertEquals(33d, matrix.get(2, 2), 0.d);
-        Assert.assertEquals(34d, matrix.get(2, 3), 0.d);
-        Assert.assertEquals(35d, matrix.get(2, 4), 0.d);
-        Assert.assertEquals(36d, matrix.get(2, 5), 0.d);
-        Assert.assertEquals(44d, matrix.get(3, 3), 0.d);
-        Assert.assertEquals(45d, matrix.get(3, 4), 0.d);
-        Assert.assertEquals(56d, matrix.get(4, 5), 0.d);
-        Assert.assertEquals(66d, matrix.get(5, 5), 0.d);
-
-        Assert.assertEquals(0.d, matrix.get(5, 4), 0.d);
-
-        Assert.assertEquals(0.d, matrix.get(1, 0), 0.d);
-        Assert.assertEquals(0.d, matrix.get(1, 3), 0.d);
-        Assert.assertEquals(0.d, matrix.get(1, 0), 0.d);
-    }
-
-    @Test
-    public void testReadOnlyDenseMatrix2dSparseInput() {
-        Matrix matrix = denseMatrixSparseInput();
-        Assert.assertEquals(7, matrix.numRows());
-        Assert.assertEquals(7, matrix.numColumns());
-        Assert.assertEquals(4, matrix.numColumns(0));
-        Assert.assertEquals(3, matrix.numColumns(1));
-        Assert.assertEquals(6, matrix.numColumns(2));
-        Assert.assertEquals(5, matrix.numColumns(3));
-        Assert.assertEquals(6, matrix.numColumns(4));
-        Assert.assertEquals(6, matrix.numColumns(5));
-        Assert.assertEquals(2, matrix.numColumns(6));
-
-        Assert.assertEquals(11d, matrix.get(0, 0), 0.d);
-        Assert.assertEquals(12d, matrix.get(0, 1), 0.d);
-        Assert.assertEquals(13d, matrix.get(0, 2), 0.d);
-        Assert.assertEquals(14d, matrix.get(0, 3), 0.d);
-        Assert.assertEquals(22d, matrix.get(1, 1), 0.d);
-        Assert.assertEquals(23d, matrix.get(1, 2), 0.d);
-        Assert.assertEquals(33d, matrix.get(2, 2), 0.d);
-        Assert.assertEquals(34d, matrix.get(2, 3), 0.d);
-        Assert.assertEquals(35d, matrix.get(2, 4), 0.d);
-        Assert.assertEquals(36d, matrix.get(2, 5), 0.d);
-        Assert.assertEquals(44d, matrix.get(3, 3), 0.d);
-        Assert.assertEquals(45d, matrix.get(3, 4), 0.d);
-        Assert.assertEquals(56d, matrix.get(4, 5), 0.d);
-        Assert.assertEquals(66d, matrix.get(5, 5), 0.d);
-        Assert.assertEquals(77d, matrix.get(6, 1), 0.d);
-
-        Assert.assertEquals(0.d, matrix.get(5, 4), 0.d);
-        Assert.assertEquals(0.d, matrix.get(1, 0), 0.d);
-        Assert.assertEquals(0.d, matrix.get(1, 3), 0.d);
-        Assert.assertEquals(0.d, matrix.get(1, 0), 0.d);
-        Assert.assertEquals(0.d, matrix.get(6, 6), 0.d);
-    }
-
-    @Test(expected = IndexOutOfBoundsException.class)
-    public void testReadOnlyDenseMatrix2dSparseColOutOfBounds() {
-        Matrix matrix = denseMatrixSparseInput();
-        Assert.assertEquals(7, matrix.numRows());
-        Assert.assertEquals(7, matrix.numColumns());
-        matrix.get(6, 7);
-    }
-
-    @Test(expected = IndexOutOfBoundsException.class)
-    public void testReadOnlyDenseMatrix2dSparseRowOutOfBounds() {
-        Matrix matrix = denseMatrixSparseInput();
-        Assert.assertEquals(7, matrix.numRows());
-        Assert.assertEquals(7, matrix.numColumns());
-        matrix.get(7, 6);
-    }
-
-    @Test
-    public void testReadOnlyDenseMatrix2dFromLibSVM() {
-        Matrix matrix = denseMatrixFromLibSVM();
-        Assert.assertEquals(6, matrix.numRows());
-        Assert.assertEquals(6, matrix.numColumns());
-        Assert.assertEquals(4, matrix.numColumns(0));
-        Assert.assertEquals(3, matrix.numColumns(1));
-        Assert.assertEquals(6, matrix.numColumns(2));
-        Assert.assertEquals(5, matrix.numColumns(3));
-        Assert.assertEquals(6, matrix.numColumns(4));
-        Assert.assertEquals(6, matrix.numColumns(5));
-
-        Assert.assertEquals(11d, matrix.get(0, 0), 0.d);
-        Assert.assertEquals(12d, matrix.get(0, 1), 0.d);
-        Assert.assertEquals(13d, matrix.get(0, 2), 0.d);
-        Assert.assertEquals(14d, matrix.get(0, 3), 0.d);
-        Assert.assertEquals(22d, matrix.get(1, 1), 0.d);
-        Assert.assertEquals(23d, matrix.get(1, 2), 0.d);
-        Assert.assertEquals(33d, matrix.get(2, 2), 0.d);
-        Assert.assertEquals(34d, matrix.get(2, 3), 0.d);
-        Assert.assertEquals(35d, matrix.get(2, 4), 0.d);
-        Assert.assertEquals(36d, matrix.get(2, 5), 0.d);
-        Assert.assertEquals(44d, matrix.get(3, 3), 0.d);
-        Assert.assertEquals(45d, matrix.get(3, 4), 0.d);
-        Assert.assertEquals(56d, matrix.get(4, 5), 0.d);
-        Assert.assertEquals(66d, matrix.get(5, 5), 0.d);
-
-        Assert.assertEquals(0.d, matrix.get(5, 4), 0.d);
-
-        Assert.assertEquals(0.d, matrix.get(1, 0), 0.d);
-        Assert.assertEquals(0.d, matrix.get(1, 3), 0.d);
-        Assert.assertEquals(0.d, matrix.get(1, 0), 0.d);
-    }
-
-    @Test
-    public void testReadOnlyDenseMatrix2dNoRow() {
-        Matrix matrix = new RowMajorDenseMatrixBuilder(1024).buildMatrix();
-        Assert.assertEquals(0, matrix.numRows());
-        Assert.assertEquals(0, matrix.numColumns());
-    }
-
-    @Test(expected = IndexOutOfBoundsException.class)
-    public void testReadOnlyDenseMatrix2dFailOutOfBound1() {
-        Matrix matrix = rowMajorDenseMatrix();
-        matrix.get(7, 5);
-    }
-
-    @Test(expected = IndexOutOfBoundsException.class)
-    public void testReadOnlyDenseMatrix2dFailOutOfBound2() {
-        Matrix matrix = rowMajorDenseMatrix();
-        matrix.get(6, 7);
-    }
-
-    @Test
-    public void testColumnMajorDenseMatrix2d() {
-        ColumnMajorDenseMatrix2d colMatrix = columnMajorDenseMatrix();
-
-        Assert.assertEquals(6, colMatrix.numRows());
-        Assert.assertEquals(6, colMatrix.numColumns());
-        Assert.assertEquals(4, colMatrix.numColumns(0));
-        Assert.assertEquals(2, colMatrix.numColumns(1));
-        Assert.assertEquals(4, colMatrix.numColumns(2));
-        Assert.assertEquals(2, colMatrix.numColumns(3));
-        Assert.assertEquals(1, colMatrix.numColumns(4));
-        Assert.assertEquals(1, colMatrix.numColumns(5));
-
-        Assert.assertEquals(11d, colMatrix.get(0, 0), 0.d);
-        Assert.assertEquals(12d, colMatrix.get(0, 1), 0.d);
-        Assert.assertEquals(13d, colMatrix.get(0, 2), 0.d);
-        Assert.assertEquals(14d, colMatrix.get(0, 3), 0.d);
-        Assert.assertEquals(22d, colMatrix.get(1, 1), 0.d);
-        Assert.assertEquals(23d, colMatrix.get(1, 2), 0.d);
-        Assert.assertEquals(33d, colMatrix.get(2, 2), 0.d);
-        Assert.assertEquals(34d, colMatrix.get(2, 3), 0.d);
-        Assert.assertEquals(35d, colMatrix.get(2, 4), 0.d);
-        Assert.assertEquals(36d, colMatrix.get(2, 5), 0.d);
-        Assert.assertEquals(44d, colMatrix.get(3, 3), 0.d);
-        Assert.assertEquals(45d, colMatrix.get(3, 4), 0.d);
-        Assert.assertEquals(56d, colMatrix.get(4, 5), 0.d);
-        Assert.assertEquals(66d, colMatrix.get(5, 5), 0.d);
-
-        Assert.assertEquals(0.d, colMatrix.get(5, 4), 0.d);
-
-        Assert.assertEquals(0.d, colMatrix.get(1, 0), 0.d);
-        Assert.assertEquals(0.d, colMatrix.get(1, 3), 0.d);
-        Assert.assertEquals(0.d, colMatrix.get(1, 0), 0.d);
-    }
-
-    @Test
-    public void testDenseMatrixColumnMajor2RowMajor() {
-        ColumnMajorDenseMatrix2d colMatrix = columnMajorDenseMatrix();
-        RowMajorDenseMatrix2d rowMatrix = colMatrix.toRowMajorMatrix();
-        Assert.assertEquals(colMatrix.toString(), rowMatrix.toString());
-
-        Assert.assertEquals(6, rowMatrix.numRows());
-        Assert.assertEquals(6, rowMatrix.numColumns());
-        Assert.assertEquals(4, rowMatrix.numColumns(0));
-        Assert.assertEquals(3, rowMatrix.numColumns(1));
-        Assert.assertEquals(6, rowMatrix.numColumns(2));
-        Assert.assertEquals(5, rowMatrix.numColumns(3));
-        Assert.assertEquals(6, rowMatrix.numColumns(4));
-        Assert.assertEquals(6, rowMatrix.numColumns(5));
-
-        Assert.assertEquals(11d, rowMatrix.get(0, 0), 0.d);
-        Assert.assertEquals(12d, rowMatrix.get(0, 1), 0.d);
-        Assert.assertEquals(13d, rowMatrix.get(0, 2), 0.d);
-        Assert.assertEquals(14d, rowMatrix.get(0, 3), 0.d);
-        Assert.assertEquals(22d, rowMatrix.get(1, 1), 0.d);
-        Assert.assertEquals(23d, rowMatrix.get(1, 2), 0.d);
-        Assert.assertEquals(33d, rowMatrix.get(2, 2), 0.d);
-        Assert.assertEquals(34d, rowMatrix.get(2, 3), 0.d);
-        Assert.assertEquals(35d, rowMatrix.get(2, 4), 0.d);
-        Assert.assertEquals(36d, rowMatrix.get(2, 5), 0.d);
-        Assert.assertEquals(44d, rowMatrix.get(3, 3), 0.d);
-        Assert.assertEquals(45d, rowMatrix.get(3, 4), 0.d);
-        Assert.assertEquals(56d, rowMatrix.get(4, 5), 0.d);
-        Assert.assertEquals(66d, rowMatrix.get(5, 5), 0.d);
-
-        Assert.assertEquals(0.d, rowMatrix.get(5, 4), 0.d);
-
-        Assert.assertEquals(0.d, rowMatrix.get(1, 0), 0.d);
-        Assert.assertEquals(0.d, rowMatrix.get(1, 3), 0.d);
-        Assert.assertEquals(0.d, rowMatrix.get(1, 0), 0.d);
-
-        // convert back to column major matrix
-
-        colMatrix = rowMatrix.toColumnMajorMatrix();
-
-        Assert.assertEquals(6, colMatrix.numRows());
-        Assert.assertEquals(6, colMatrix.numColumns());
-        Assert.assertEquals(4, colMatrix.numColumns(0));
-        Assert.assertEquals(2, colMatrix.numColumns(1));
-        Assert.assertEquals(4, colMatrix.numColumns(2));
-        Assert.assertEquals(2, colMatrix.numColumns(3));
-        Assert.assertEquals(1, colMatrix.numColumns(4));
-        Assert.assertEquals(1, colMatrix.numColumns(5));
-
-        Assert.assertEquals(11d, colMatrix.get(0, 0), 0.d);
-        Assert.assertEquals(12d, colMatrix.get(0, 1), 0.d);
-        Assert.assertEquals(13d, colMatrix.get(0, 2), 0.d);
-        Assert.assertEquals(14d, colMatrix.get(0, 3), 0.d);
-        Assert.assertEquals(22d, colMatrix.get(1, 1), 0.d);
-        Assert.assertEquals(23d, colMatrix.get(1, 2), 0.d);
-        Assert.assertEquals(33d, colMatrix.get(2, 2), 0.d);
-        Assert.assertEquals(34d, colMatrix.get(2, 3), 0.d);
-        Assert.assertEquals(35d, colMatrix.get(2, 4), 0.d);
-        Assert.assertEquals(36d, colMatrix.get(2, 5), 0.d);
-        Assert.assertEquals(44d, colMatrix.get(3, 3), 0.d);
-        Assert.assertEquals(45d, colMatrix.get(3, 4), 0.d);
-        Assert.assertEquals(56d, colMatrix.get(4, 5), 0.d);
-        Assert.assertEquals(66d, colMatrix.get(5, 5), 0.d);
-
-        Assert.assertEquals(0.d, colMatrix.get(5, 4), 0.d);
-
-        Assert.assertEquals(0.d, colMatrix.get(1, 0), 0.d);
-        Assert.assertEquals(0.d, colMatrix.get(1, 3), 0.d);
-        Assert.assertEquals(0.d, colMatrix.get(1, 0), 0.d);
-    }
-
-    @Test
-    public void testCSRMatrixNullRow() {
-        CSRMatrixBuilder builder = new CSRMatrixBuilder(1024);
-        builder.nextColumn(0, 11).nextColumn(1, 12).nextColumn(2, 13).nextColumn(3, 14).nextRow();
-        builder.nextColumn(1, 22).nextColumn(2, 23).nextRow();
-        builder.nextRow();
-        builder.nextColumn(3, 66).nextRow();
-        Matrix matrix = builder.buildMatrix();
-        Assert.assertEquals(4, matrix.numRows());
-    }
-
-    private static CSRMatrix csrMatrix() {
-        /*
-        11  12  13  14  0   0
-        0   22  23  0   0   0
-        0   0   33  34  35  36
-        0   0   0   44  45  0
-        0   0   0   0   0   56
-        0   0   0   0   0   66
-        */
-        CSRMatrixBuilder builder = new CSRMatrixBuilder(1024);
-        builder.nextColumn(0, 11).nextColumn(1, 12).nextColumn(2, 13).nextColumn(3, 14).nextRow();
-        builder.nextColumn(1, 22).nextColumn(2, 23).nextRow();
-        builder.nextColumn(2, 33).nextColumn(3, 34).nextColumn(4, 35).nextColumn(5, 36).nextRow();
-        builder.nextColumn(3, 44).nextColumn(4, 45).nextRow();
-        builder.nextColumn(5, 56).nextRow();
-        builder.nextColumn(5, 66).nextRow();
-        return builder.buildMatrix();
-    }
-
-    private static CSRMatrix csrMatrixFromLibSVM() {
-        /*
-        11  12  13  14  0   0
-        0   22  23  0   0   0
-        0   0   33  34  35  36
-        0   0   0   44  45  0
-        0   0   0   0   0   56
-        0   0   0   0   0   66
-        */
-        CSRMatrixBuilder builder = new CSRMatrixBuilder(1024);
-        builder.nextRow(new String[] {"0:11", "1:12", "2:13", "3:14"});
-        builder.nextRow(new String[] {"1:22", "2:23"});
-        builder.nextRow(new String[] {"2:33", "3:34", "4:35", "5:36"});
-        builder.nextRow(new String[] {"3:44", "4:45"});
-        builder.nextRow(new String[] {"5:56"});
-        builder.nextRow(new String[] {"5:66"});
-        return builder.buildMatrix();
-    }
-
-    private static CSCMatrix cscMatrixFromLibSVM() {
-        /*
-        11  12  13  14  0   0
-        0   22  23  0   0   0
-        0   0   33  34  35  36
-        0   0   0   44  45  0
-        0   0   0   0   0   56
-        0   0   0   0   0   66
-        */
-        CSCMatrixBuilder builder = new CSCMatrixBuilder(1024);
-        builder.nextRow(new String[] {"0:11", "1:12", "2:13", "3:14"});
-        builder.nextRow(new String[] {"1:22", "2:23"});
-        builder.nextRow(new String[] {"2:33", "3:34", "4:35", "5:36"});
-        builder.nextRow(new String[] {"3:44", "4:45"});
-        builder.nextRow(new String[] {"5:56"});
-        builder.nextRow(new String[] {"5:66"});
-        return builder.buildMatrix();
-    }
-
-
-    private static DoKMatrix dokMatrixFromLibSVM() {
-        /*
-        11  12  13  14  0   0
-        0   22  23  0   0   0
-        0   0   33  34  35  36
-        0   0   0   44  45  0
-        0   0   0   0   0   56
-        0   0   0   0   0   66
-        */
-        DoKMatrixBuilder builder = new DoKMatrixBuilder(1024);
-        builder.nextRow(new String[] {"0:11", "1:12", "2:13", "3:14"});
-        builder.nextRow(new String[] {"1:22", "2:23"});
-        builder.nextRow(new String[] {"2:33", "3:34", "4:35", "5:36"});
-        builder.nextRow(new String[] {"3:44", "4:45"});
-        builder.nextRow(new String[] {"5:56"});
-        builder.nextRow(new String[] {"5:66"});
-        return builder.buildMatrix();
-    }
-
-    private static RowMajorDenseMatrix2d rowMajorDenseMatrix() {
-        /*
-        11  12  13  14  0   0
-        0   22  23  0   0   0
-        0   0   33  34  35  36
-        0   0   0   44  45  0
-        0   0   0   0   0   56
-        0   0   0   0   0   66
-        */
-        RowMajorDenseMatrixBuilder builder = new RowMajorDenseMatrixBuilder(1024);
-        builder.nextRow(new double[] {11, 12, 13, 14});
-        builder.nextRow(new double[] {0, 22, 23});
-        builder.nextRow(new double[] {0, 0, 33, 34, 35, 36});
-        builder.nextRow(new double[] {0, 0, 0, 44, 45});
-        builder.nextRow(new double[] {0, 0, 0, 0, 0, 56});
-        builder.nextRow(new double[] {0, 0, 0, 0, 0, 66});
-        return builder.buildMatrix();
-    }
-
-    private static ColumnMajorDenseMatrix2d columnMajorDenseMatrix() {
-        /*
-        11  12  13  14  0   0
-        0   22  23  0   0   0
-        0   0   33  34  35  36
-        0   0   0   44  45  0
-        0   0   0   0   0   56
-        0   0   0   0   0   66
-        */
-        ColumnMajorDenseMatrixBuilder builder = new ColumnMajorDenseMatrixBuilder(1024);
-        builder.nextRow(new double[] {11, 12, 13, 14});
-        builder.nextRow(new double[] {0, 22, 23});
-        builder.nextRow(new double[] {0, 0, 33, 34, 35, 36});
-        builder.nextRow(new double[] {0, 0, 0, 44, 45});
-        builder.nextRow(new double[] {0, 0, 0, 0, 0, 56});
-        builder.nextRow(new double[] {0, 0, 0, 0, 0, 66});
-        return builder.buildMatrix();
-    }
-
-    private static RowMajorDenseMatrix2d denseMatrixSparseInput() {
-        /*
-        11  12  13  14  0   0   0
-        0   22  23  0   0   0   0
-        0   0   33  34  35  36  0
-        0   0   0   44  45  0   0
-        0   0   0   0   0   56  0
-        0   0   0   0   0   66  0
-        0   77  0   0   0   0   0
-        */
-        RowMajorDenseMatrixBuilder builder = new RowMajorDenseMatrixBuilder(1024);
-        builder.nextColumn(0, 11).nextColumn(1, 12).nextColumn(2, 13).nextColumn(3, 14).nextRow();
-        builder.nextColumn(1, 22).nextColumn(2, 23).nextRow();
-        builder.nextColumn(2, 33).nextColumn(3, 34).nextColumn(4, 35).nextColumn(5, 36).nextRow();
-        builder.nextColumn(3, 44).nextColumn(4, 45).nextRow();
-        builder.nextColumn(5, 56).nextRow();
-        builder.nextColumn(5, 66).nextRow();
-        builder.nextColumn(1, 77).nextColumn(6, 0).nextRow();
-        return builder.buildMatrix();
-    }
-
-    private static RowMajorDenseMatrix2d denseMatrixFromLibSVM() {
-        RowMajorDenseMatrixBuilder builder = new RowMajorDenseMatrixBuilder(1024);
-        builder.nextRow(new String[] {"0:11", "1:12", "2:13", "3:14"});
-        builder.nextRow(new String[] {"1:22", "2:23"});
-        builder.nextRow(new String[] {"2:33", "3:34", "4:35", "5:36"});
-        builder.nextRow(new String[] {"3:44", "4:45"});
-        builder.nextRow(new String[] {"5:56"});
-        builder.nextRow(new String[] {"5:66"});
-        return builder.buildMatrix();
-    }
-
-}
diff --git a/core/src/test/java/hivemall/math/matrix/MatrixUtilsTest.java b/core/src/test/java/hivemall/math/matrix/MatrixUtilsTest.java
deleted file mode 100644
index 409bc65..0000000
--- a/core/src/test/java/hivemall/math/matrix/MatrixUtilsTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * 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 hivemall.math.matrix;
-
-import hivemall.math.matrix.sparse.CSCMatrix;
-import hivemall.math.matrix.sparse.CSRMatrix;
-import hivemall.utils.lang.ArrayUtils;
-
-import java.util.Random;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class MatrixUtilsTest {
-
-    @Test
-    public void testCoo2csr() {
-        // 10  0  0  0 -2  0
-        // 3  9  0  0  0  3
-        // 0  7  8  7  0  0
-        // 3  0  8  7  5  0
-        // 0  8  0  9  9 13
-        // 0  4  0  0  2 -1 
-        double[] row1 = new double[] {10, 0, 0, 0, -2, 0};
-        double[] row2 = new double[] {3, 9, 0, 0, 0, 3};
-        double[] row3 = new double[] {0, 7, 8, 7, 0, 0};
-        double[] row4 = new double[] {3, 0, 8, 7, 5, 0};
-        double[] row5 = new double[] {0, 8, 0, 9, 9, 13};
-        double[] row6 = new double[] {0, 4, 0, 0, 2, -1};
-        double[][] matrix = new double[][] {row1, row2, row3, row4, row5, row6};
-
-        int[] rows = new int[] {0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5};
-        int[] cols = new int[] {0, 4, 0, 1, 5, 1, 2, 3, 0, 2, 3, 4, 1, 3, 4, 5, 1, 4, 5};
-        double[] data = new double[] {10, -2, 3, 9, 3, 7, 8, 7, 3, 8, 7, 5, 8, 9, 9, 13, 4, 2, -1};
-
-        CSRMatrix matrix1 = MatrixUtils.coo2csr(rows, cols, data, 6, 6, false);
-        Assert.assertEquals(data.length, matrix1.nnz());
-
-        final Random rnd = new Random(43L);
-        for (int i = data.length; i > 1; i--) {
-            int to = rnd.nextInt(i);
-            int from = i - 1;
-            ArrayUtils.swap(rows, from, to);
-            ArrayUtils.swap(cols, from, to);
-            ArrayUtils.swap(data, from, to);
-        }
-
-        CSRMatrix matrix2 = MatrixUtils.coo2csr(rows, cols, data, 6, 6, true);
-        Assert.assertEquals(data.length, matrix2.nnz());
-
-        double[] dst1 = matrix1.row();
-        Assert.assertEquals(6, matrix1.numRows());
-        for (int row = 0; row < matrix1.numRows(); row++) {
-            matrix1.getRow(row, dst1);
-            Assert.assertArrayEquals(matrix[row], dst1, 1E-7d);
-        }
-
-        double[] dst2 = matrix2.row();
-        Assert.assertEquals(6, matrix2.numRows());
-        for (int row = 0; row < matrix2.numRows(); row++) {
-            matrix2.getRow(row, dst2);
-            Assert.assertArrayEquals(matrix[row], dst2, 1E-7d);
-        }
-    }
-
-    @Test
-    public void testCoo2csc() {
-        // 10  0  0  0 -2  0
-        // 3  9  0  0  0  3
-        // 0  7  8  7  0  0
-        // 3  0  8  7  5  0
-        // 0  8  0  9  9 13
-        // 0  4  0  0  2 -1 
-        double[] row1 = new double[] {10, 0, 0, 0, -2, 0};
-        double[] row2 = new double[] {3, 9, 0, 0, 0, 3};
-        double[] row3 = new double[] {0, 7, 8, 7, 0, 0};
-        double[] row4 = new double[] {3, 0, 8, 7, 5, 0};
-        double[] row5 = new double[] {0, 8, 0, 9, 9, 13};
-        double[] row6 = new double[] {0, 4, 0, 0, 2, -1};
-        double[][] matrix = new double[][] {row1, row2, row3, row4, row5, row6};
-
-        int[] rows = new int[] {0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5};
-        int[] cols = new int[] {0, 4, 0, 1, 5, 1, 2, 3, 0, 2, 3, 4, 1, 3, 4, 5, 1, 4, 5};
-        double[] data = new double[] {10, -2, 3, 9, 3, 7, 8, 7, 3, 8, 7, 5, 8, 9, 9, 13, 4, 2, -1};
-
-        CSCMatrix matrix1 = MatrixUtils.coo2csc(rows, cols, data, 6, 6, false);
-        Assert.assertEquals(data.length, matrix1.nnz());
-
-        final Random rnd = new Random(43L);
-        for (int i = data.length; i > 1; i--) {
-            int to = rnd.nextInt(i);
-            int from = i - 1;
-            ArrayUtils.swap(rows, from, to);
-            ArrayUtils.swap(cols, from, to);
-            ArrayUtils.swap(data, from, to);
-        }
-
-        CSCMatrix matrix2 = MatrixUtils.coo2csc(rows, cols, data, 6, 6, true);
-        Assert.assertEquals(data.length, matrix2.nnz());
-
-        double[] dst1 = matrix1.row();
-        Assert.assertEquals(6, matrix1.numRows());
-        for (int row = 0; row < matrix1.numRows(); row++) {
-            matrix1.getRow(row, dst1);
-            Assert.assertArrayEquals(matrix[row], dst1, 1E-7d);
-        }
-
-        double[] dst2 = matrix2.row();
-        Assert.assertEquals(6, matrix2.numRows());
-        for (int row = 0; row < matrix2.numRows(); row++) {
-            matrix2.getRow(row, dst2);
-            Assert.assertArrayEquals(matrix[row], dst2, 1E-7d);
-        }
-    }
-
-}
diff --git a/core/src/test/java/hivemall/math/matrix/ints/IntMatrixTest.java b/core/src/test/java/hivemall/math/matrix/ints/IntMatrixTest.java
deleted file mode 100644
index f6a52fe..0000000
--- a/core/src/test/java/hivemall/math/matrix/ints/IntMatrixTest.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * 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 hivemall.math.matrix.ints;
-
-import hivemall.math.matrix.ints.ColumnMajorDenseIntMatrix2d;
-import hivemall.math.matrix.ints.DoKIntMatrix;
-import hivemall.math.vector.VectorProcedure;
-import hivemall.utils.lang.mutable.MutableInt;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class IntMatrixTest {
-
-    @Test
-    public void testDoKMatrixRowMajor() {
-        DoKIntMatrix matrix = DoKIntMatrix.build(rowMajorData(), true, true);
-
-        Assert.assertEquals(6, matrix.numRows());
-        Assert.assertEquals(6, matrix.numColumns());
-
-        Assert.assertEquals(11, matrix.get(0, 0));
-        Assert.assertEquals(12, matrix.get(0, 1));
-        Assert.assertEquals(13, matrix.get(0, 2));
-        Assert.assertEquals(14, matrix.get(0, 3));
-        Assert.assertEquals(22, matrix.get(1, 1));
-        Assert.assertEquals(23, matrix.get(1, 2));
-        Assert.assertEquals(33, matrix.get(2, 2));
-        Assert.assertEquals(34, matrix.get(2, 3));
-        Assert.assertEquals(35, matrix.get(2, 4));
-        Assert.assertEquals(36, matrix.get(2, 5));
-        Assert.assertEquals(44, matrix.get(3, 3));
-        Assert.assertEquals(45, matrix.get(3, 4));
-        Assert.assertEquals(56, matrix.get(4, 5));
-        Assert.assertEquals(66, matrix.get(5, 5));
-
-        Assert.assertEquals(0, matrix.get(5, 4));
-        Assert.assertEquals(0, matrix.get(1, 0));
-        Assert.assertEquals(0, matrix.get(1, 3));
-        Assert.assertEquals(-1, matrix.get(1, 0, -1));
-    }
-
-    @Test
-    public void testDoKMatrixColumnMajor() {
-        DoKIntMatrix matrix = DoKIntMatrix.build(columnMajorData(), false, true);
-
-        Assert.assertEquals(6, matrix.numRows());
-        Assert.assertEquals(6, matrix.numColumns());
-
-        Assert.assertEquals(11, matrix.get(0, 0));
-        Assert.assertEquals(12, matrix.get(0, 1));
-        Assert.assertEquals(13, matrix.get(0, 2));
-        Assert.assertEquals(14, matrix.get(0, 3));
-        Assert.assertEquals(22, matrix.get(1, 1));
-        Assert.assertEquals(23, matrix.get(1, 2));
-        Assert.assertEquals(33, matrix.get(2, 2));
-        Assert.assertEquals(34, matrix.get(2, 3));
-        Assert.assertEquals(35, matrix.get(2, 4));
-        Assert.assertEquals(36, matrix.get(2, 5));
-        Assert.assertEquals(44, matrix.get(3, 3));
-        Assert.assertEquals(45, matrix.get(3, 4));
-        Assert.assertEquals(56, matrix.get(4, 5));
-        Assert.assertEquals(66, matrix.get(5, 5));
-
-        Assert.assertEquals(0, matrix.get(5, 4));
-        Assert.assertEquals(0, matrix.get(1, 0));
-        Assert.assertEquals(0, matrix.get(1, 3));
-        Assert.assertEquals(-1, matrix.get(1, 0, -1));
-    }
-
-    @Test
-    public void testDoKMatrixColumnMajorNonZeroOnlyFalse() {
-        DoKIntMatrix matrix = DoKIntMatrix.build(columnMajorData(), false, false);
-
-        Assert.assertEquals(6, matrix.numRows());
-        Assert.assertEquals(6, matrix.numColumns());
-
-        Assert.assertEquals(0, matrix.get(5, 4));
-        Assert.assertEquals(0, matrix.get(1, 0));
-        Assert.assertEquals(0, matrix.get(1, 3));
-        Assert.assertEquals(0, matrix.get(1, 3, -1));
-        Assert.assertEquals(-1, matrix.get(1, 0, -1));
-
-        matrix.setDefaultValue(-1);
-        Assert.assertEquals(-1, matrix.get(5, 4));
-        Assert.assertEquals(-1, matrix.get(1, 0));
-        Assert.assertEquals(0, matrix.get(1, 3));
-        Assert.assertEquals(0, matrix.get(1, 0, 0));
-    }
-
-    @Test
-    public void testColumnMajorDenseMatrix() {
-        ColumnMajorDenseIntMatrix2d matrix = new ColumnMajorDenseIntMatrix2d(columnMajorData(), 6);
-        Assert.assertEquals(6, matrix.numRows());
-        Assert.assertEquals(6, matrix.numColumns());
-
-        Assert.assertEquals(11, matrix.get(0, 0));
-        Assert.assertEquals(12, matrix.get(0, 1));
-        Assert.assertEquals(13, matrix.get(0, 2));
-        Assert.assertEquals(14, matrix.get(0, 3));
-        Assert.assertEquals(22, matrix.get(1, 1));
-        Assert.assertEquals(23, matrix.get(1, 2));
-        Assert.assertEquals(33, matrix.get(2, 2));
-        Assert.assertEquals(34, matrix.get(2, 3));
-        Assert.assertEquals(35, matrix.get(2, 4));
-        Assert.assertEquals(36, matrix.get(2, 5));
-        Assert.assertEquals(44, matrix.get(3, 3));
-        Assert.assertEquals(45, matrix.get(3, 4));
-        Assert.assertEquals(56, matrix.get(4, 5));
-        Assert.assertEquals(66, matrix.get(5, 5));
-
-        Assert.assertEquals(0, matrix.get(5, 4));
-        Assert.assertEquals(0, matrix.get(1, 0));
-        Assert.assertEquals(0, matrix.get(1, 3));
-        Assert.assertEquals(-1, matrix.get(1, 0, -1));
-    }
-
-    @Test
-    public void testColumnMajorDenseMatrixEachColumn() {
-        ColumnMajorDenseIntMatrix2d matrix = new ColumnMajorDenseIntMatrix2d(columnMajorData(), 6);
-        matrix.setDefaultValue(-1);
-
-        final MutableInt count = new MutableInt(0);
-        for (int j = 0; j < 6; j++) {
-            matrix.eachInColumn(j, new VectorProcedure() {
-                @Override
-                public void apply(int i, int value) {
-                    count.addValue(1);
-                }
-            }, false);
-        }
-        Assert.assertEquals(1 + 2 + 3 + 4 + 4 + 6, count.getValue());
-
-        count.setValue(0);
-        for (int j = 0; j < 6; j++) {
-            matrix.eachInColumn(j, new VectorProcedure() {
-                @Override
-                public void apply(int i, int value) {
-                    count.addValue(1);
-                }
-            }, true);
-        }
-        Assert.assertEquals(6 * 6, count.getValue());
-
-        count.setValue(0);
-        for (int j = 0; j < 6; j++) {
-            matrix.eachNonZeroInColumn(j, new VectorProcedure() {
-                @Override
-                public void apply(int i, int value) {
-                    count.addValue(1);
-                }
-            });
-        }
-        Assert.assertEquals(1 + 2 + 3 + 3 + 2 + 3, count.getValue());
-
-        // change default value to zero
-        matrix.setDefaultValue(0);
-
-        count.setValue(0);
-        for (int j = 0; j < 6; j++) {
-            matrix.eachInColumn(j, new VectorProcedure() {
-                @Override
-                public void apply(int i, int value) {
-                    count.addValue(1);
-                }
-            }, false);
-        }
-        Assert.assertEquals(1 + 2 + 3 + 4 + 4 + 6, count.getValue());
-
-        count.setValue(0);
-        for (int j = 0; j < 6; j++) {
-            matrix.eachInColumn(j, new VectorProcedure() {
-                @Override
-                public void apply(int i, int value) {
-                    count.addValue(1);
-                }
-            }, true);
-        }
-        Assert.assertEquals(6 * 6, count.getValue());
-
-        count.setValue(0);
-        for (int j = 0; j < 6; j++) {
-            matrix.eachNonZeroInColumn(j, new VectorProcedure() {
-                @Override
-                public void apply(int i, int value) {
-                    count.addValue(1);
-                }
-            });
-        }
-        Assert.assertEquals(1 + 2 + 3 + 3 + 2 + 3, count.getValue());
-    }
-
-    @Test
-    public void testDoKMatrixColumnMajorNonZeroOnlyFalseEachColumn() {
-        DoKIntMatrix matrix = DoKIntMatrix.build(columnMajorData(), false, false);
-        matrix.setDefaultValue(-1);
-
-        final MutableInt count = new MutableInt(0);
-        for (int j = 0; j < 6; j++) {
-            matrix.eachInColumn(j, new VectorProcedure() {
-                @Override
-                public void apply(int i, int value) {
-                    count.addValue(1);
-                }
-            }, false);
-        }
-        Assert.assertEquals(1 + 2 + 3 + 4 + 4 + 6, count.getValue());
-
-        count.setValue(0);
-        for (int j = 0; j < 6; j++) {
-            matrix.eachInColumn(j, new VectorProcedure() {
-                @Override
-                public void apply(int i, int value) {
-                    count.addValue(1);
-                }
-            }, true);
-        }
-        Assert.assertEquals(6 * 6, count.getValue());
-
-        count.setValue(0);
-        for (int j = 0; j < 6; j++) {
-            matrix.eachNonZeroInColumn(j, new VectorProcedure() {
-                @Override
-                public void apply(int i, int value) {
-                    count.addValue(1);
-                }
-            });
-        }
-        Assert.assertEquals(1 + 2 + 3 + 3 + 2 + 3, count.getValue());
-
-        // change default value to zero
-        matrix.setDefaultValue(0);
-
-        count.setValue(0);
-        for (int j = 0; j < 6; j++) {
-            matrix.eachInColumn(j, new VectorProcedure() {
-                @Override
-                public void apply(int i, int value) {
-                    count.addValue(1);
-                }
-            }, false);
-        }
-        Assert.assertEquals(1 + 2 + 3 + 4 + 4 + 6, count.getValue());
-
-        count.setValue(0);
-        for (int j = 0; j < 6; j++) {
-            matrix.eachInColumn(j, new VectorProcedure() {
-                @Override
-                public void apply(int i, int value) {
-                    count.addValue(1);
-                }
-            }, true);
-        }
-        Assert.assertEquals(6 * 6, count.getValue());
-
-        count.setValue(0);
-        for (int j = 0; j < 6; j++) {
-            matrix.eachNonZeroInColumn(j, new VectorProcedure() {
-                @Override
-                public void apply(int i, int value) {
-                    count.addValue(1);
-                }
-            });
-        }
-        Assert.assertEquals(1 + 2 + 3 + 3 + 2 + 3, count.getValue());
-    }
-
-    @Test
-    public void testDoKMatrixRowMajorNonZeroOnlyFalseEachColumn() {
-        DoKIntMatrix matrix = DoKIntMatrix.build(rowMajorData(), true, false);
-        matrix.setDefaultValue(-1);
-
-        final MutableInt count = new MutableInt(0);
-        for (int i = 0; i < 6; i++) {
-            matrix.eachInRow(i, new VectorProcedure() {
-                @Override
-                public void apply(int i, int value) {
-                    count.addValue(1);
-                }
-            }, false);
-        }
-        Assert.assertEquals(4 + 3 + 6 + 5 + 6 + 6, count.getValue());
-
-        count.setValue(0);
-        for (int i = 0; i < 6; i++) {
-            matrix.eachInRow(i, new VectorProcedure() {
-                @Override
-                public void apply(int i, int value) {
-                    count.addValue(1);
-                }
-            }, true);
-        }
-        Assert.assertEquals(6 * 6, count.getValue());
-
-        count.setValue(0);
-        for (int i = 0; i < 6; i++) {
-            matrix.eachNonZeroInRow(i, new VectorProcedure() {
-                @Override
-                public void apply(int i, int value) {
-                    count.addValue(1);
-                }
-            });
-        }
-        Assert.assertEquals(4 + 2 + 4 + 2 + 1 + 1, count.getValue());
-    }
-
-    private static int[][] rowMajorData() {
-        /*
-        11  12  13  14  0   0
-        0   22  23  0   0   0
-        0   0   33  34  35  36
-        0   0   0   44  45  0
-        0   0   0   0   0   56
-        0   0   0   0   0   66
-        */
-        int[][] data = new int[6][];
-        data[0] = new int[] {11, 12, 13, 14};
-        data[1] = new int[] {0, 22, 23};
-        data[2] = new int[] {0, 0, 33, 34, 35, 36};
-        data[3] = new int[] {0, 0, 0, 44, 45};
-        data[4] = new int[] {0, 0, 0, 0, 0, 56};
-        data[5] = new int[] {0, 0, 0, 0, 0, 66};
-        return data;
-    }
-
-    private static int[][] columnMajorData() {
-        /*
-        11  12  13  14  0   0
-        0   22  23  0   0   0
-        0   0   33  34  35  36
-        0   0   0   44  45  0
-        0   0   0   0   0   56
-        0   0   0   0   0   66
-        */
-        int[][] data = new int[6][];
-        data[0] = new int[] {11};
-        data[1] = new int[] {12, 22};
-        data[2] = new int[] {13, 23, 33};
-        data[3] = new int[] {14, 0, 34, 44};
-        data[4] = new int[] {0, 0, 35, 45};
-        data[5] = new int[] {0, 0, 36, 0, 56, 66};
-        return data;
-    }
-
-}
diff --git a/core/src/test/java/hivemall/math/matrix/sparse/DoKMatrixTest.java b/core/src/test/java/hivemall/math/matrix/sparse/DoKMatrixTest.java
deleted file mode 100644
index 0ae0a8c..0000000
--- a/core/src/test/java/hivemall/math/matrix/sparse/DoKMatrixTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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 hivemall.math.matrix.sparse;
-
-import hivemall.math.vector.VectorProcedure;
-import hivemall.utils.lang.Primitives;
-
-import java.util.HashSet;
-import java.util.Random;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class DoKMatrixTest {
-
-    @Test
-    public void testGetSet() {
-        DoKMatrix matrix = new DoKMatrix();
-        Random rnd = new Random(43);
-
-        for (int i = 0; i < 1000; i++) {
-            int row = Math.abs(rnd.nextInt());
-            int col = Math.abs(rnd.nextInt());
-            double v = rnd.nextDouble();
-            matrix.set(row, col, v);
-            Assert.assertEquals(v, matrix.get(row, col), 0.00001d);
-        }
-    }
-
-    @Test
-    public void testNumRowsNumCols() {
-        DoKMatrix matrix = new DoKMatrix();
-        Random rnd = new Random(43);
-        HashSet<Long> bitset = new HashSet<>(100000);
-
-        int numRows = -1, numCols = -1;
-        for (int i = 0; i < 100000; i++) {
-            int row = Math.abs(rnd.nextInt());
-            int col = Math.abs(rnd.nextInt());
-            numRows = Math.max(row + 1, numRows);
-            numCols = Math.max(col + 1, numCols);
-            double v = rnd.nextDouble();
-            if (v >= 0.8) {
-                v = 0.d;
-            }
-            matrix.getAndSet(row, col, v);
-            bitset.add(Primitives.toLong(row, col));
-            Assert.assertEquals(v, matrix.get(row, col), 0.00001d);
-        }
-
-        Assert.assertEquals(numRows, matrix.numRows());
-        Assert.assertEquals(numCols, matrix.numColumns());
-        Assert.assertEquals(bitset.size(), matrix.nnz());
-    }
-
-    @Test
-    public void testEmpty() {
-        DoKMatrix matrix = new DoKMatrix();
-        matrix.eachNonZeroCell(new VectorProcedure() {
-            @Override
-            public void apply(int i, int j, double value) {
-                Assert.fail("should not be called");
-            }
-        });
-    }
-
-}
diff --git a/core/src/test/java/hivemall/math/matrix/sparse/floats/DoKFloatMatrixTest.java b/core/src/test/java/hivemall/math/matrix/sparse/floats/DoKFloatMatrixTest.java
deleted file mode 100644
index 8c64462..0000000
--- a/core/src/test/java/hivemall/math/matrix/sparse/floats/DoKFloatMatrixTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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 hivemall.math.matrix.sparse.floats;
-
-import hivemall.math.matrix.sparse.floats.DoKFloatMatrix;
-
-import java.util.Random;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class DoKFloatMatrixTest {
-
-    @Test
-    public void testGetSet() {
-        DoKFloatMatrix matrix = new DoKFloatMatrix();
-        Random rnd = new Random(43);
-
-        for (int i = 0; i < 1000; i++) {
-            int row = Math.abs(rnd.nextInt());
-            int col = Math.abs(rnd.nextInt());
-            float v = rnd.nextFloat();
-            matrix.set(row, col, v);
-            Assert.assertEquals(v, matrix.get(row, col), 0.00001f);
-        }
-    }
-
-    @Test
-    public void testToRowMajorMatrix() {
-        DoKFloatMatrix matrix = new DoKFloatMatrix();
-        Random rnd = new Random(43);
-
-        for (int i = 0; i < 10; i++) {
-            int row = Math.abs(rnd.nextInt(100));
-            int col = Math.abs(rnd.nextInt(100));
-            float v = rnd.nextFloat();
-            matrix.set(row, col, v);
-        }
-
-        CSRFloatMatrix csr = matrix.toRowMajorMatrix();
-        Assert.assertEquals(10, csr.nnz());
-    }
-
-}
diff --git a/core/src/test/java/hivemall/smile/classification/DecisionTreeTest.java b/core/src/test/java/hivemall/smile/classification/DecisionTreeTest.java
index 130c0b3..e0b2cad 100644
--- a/core/src/test/java/hivemall/smile/classification/DecisionTreeTest.java
+++ b/core/src/test/java/hivemall/smile/classification/DecisionTreeTest.java
@@ -20,10 +20,10 @@ package hivemall.smile.classification;
 
 import static org.junit.Assert.assertEquals;
 
-import hivemall.math.matrix.Matrix;
-import hivemall.math.matrix.builders.CSRMatrixBuilder;
-import hivemall.math.matrix.dense.RowMajorDenseMatrix2d;
-import hivemall.math.vector.DenseVector;
+import matrix4j.matrix.Matrix;
+import matrix4j.matrix.builders.CSRMatrixBuilder;
+import matrix4j.matrix.dense.RowMajorDenseMatrix2d;
+import matrix4j.vector.DenseVector;
 import hivemall.smile.classification.DecisionTree.Node;
 import hivemall.smile.classification.DecisionTree.SplitRule;
 import hivemall.smile.tools.TreeExportUDF.Evaluator;
diff --git a/core/src/test/java/hivemall/smile/regression/RegressionTreeTest.java b/core/src/test/java/hivemall/smile/regression/RegressionTreeTest.java
index f7bbb46..fa1811d 100644
--- a/core/src/test/java/hivemall/smile/regression/RegressionTreeTest.java
+++ b/core/src/test/java/hivemall/smile/regression/RegressionTreeTest.java
@@ -18,9 +18,9 @@
  */
 package hivemall.smile.regression;
 
-import hivemall.math.matrix.Matrix;
-import hivemall.math.matrix.builders.CSRMatrixBuilder;
-import hivemall.math.matrix.dense.RowMajorDenseMatrix2d;
+import matrix4j.matrix.Matrix;
+import matrix4j.matrix.builders.CSRMatrixBuilder;
+import matrix4j.matrix.dense.RowMajorDenseMatrix2d;
 import hivemall.smile.tools.TreeExportUDF.Evaluator;
 import hivemall.smile.tools.TreeExportUDF.OutputType;
 import hivemall.utils.codec.Base91;
diff --git a/core/src/test/java/hivemall/smile/tools/TreePredictUDFTest.java b/core/src/test/java/hivemall/smile/tools/TreePredictUDFTest.java
index 8ccdc03..92670db 100644
--- a/core/src/test/java/hivemall/smile/tools/TreePredictUDFTest.java
+++ b/core/src/test/java/hivemall/smile/tools/TreePredictUDFTest.java
@@ -19,7 +19,7 @@
 package hivemall.smile.tools;
 
 import hivemall.TestUtils;
-import hivemall.math.matrix.dense.RowMajorDenseMatrix2d;
+import matrix4j.matrix.dense.RowMajorDenseMatrix2d;
 import hivemall.smile.classification.DecisionTree;
 import hivemall.smile.regression.RegressionTree;
 import hivemall.smile.utils.SmileExtUtils;
diff --git a/core/src/test/java/hivemall/smile/tools/TreePredictUDFv1Test.java b/core/src/test/java/hivemall/smile/tools/TreePredictUDFv1Test.java
index a9a0f26..e6b9501 100644
--- a/core/src/test/java/hivemall/smile/tools/TreePredictUDFv1Test.java
+++ b/core/src/test/java/hivemall/smile/tools/TreePredictUDFv1Test.java
@@ -21,7 +21,7 @@ package hivemall.smile.tools;
 import static org.junit.Assert.assertEquals;
 
 import hivemall.TestUtils;
-import hivemall.math.matrix.dense.RowMajorDenseMatrix2d;
+import matrix4j.matrix.dense.RowMajorDenseMatrix2d;
 import hivemall.smile.classification.DecisionTree;
 import hivemall.smile.regression.RegressionTree;
 import hivemall.smile.tools.TreePredictUDFv1.DtNodeV1;
diff --git a/dist/pom.xml b/dist/pom.xml
index 4040bdc..b544bee 100644
--- a/dist/pom.xml
+++ b/dist/pom.xml
@@ -106,6 +106,7 @@
 								<includes>
 									<!-- hivemall-core -->
 									<include>org.apache.hivemall:hivemall-core</include>
+									<include>io.github.myui:matrix4j</include>
 									<include>io.netty:netty-all</include>
 									<include>com.github.haifengl:smile-core</include>
 									<include>com.github.haifengl:smile-math</include>