Skip to content
Snippets Groups Projects
Commit c1716118 authored by Joseph K. Bradley's avatar Joseph K. Bradley Committed by Xiangrui Meng
Browse files

[SPARK-5660][MLLIB] Make Matrix apply public

This is #4447 with `override`.

Closes #4447

Author: Joseph K. Bradley <joseph@databricks.com>
Author: Xiangrui Meng <meng@databricks.com>

Closes #4462 from mengxr/SPARK-5660 and squashes the following commits:

f82c8d6 [Xiangrui Meng] add override to matrix.apply
91cedde [Joseph K. Bradley] made matrix apply public
parent a052ed42
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,7 @@ sealed trait Matrix extends Serializable { ...@@ -50,7 +50,7 @@ sealed trait Matrix extends Serializable {
private[mllib] def toBreeze: BM[Double] private[mllib] def toBreeze: BM[Double]
/** Gets the (i, j)-th element. */ /** Gets the (i, j)-th element. */
private[mllib] def apply(i: Int, j: Int): Double def apply(i: Int, j: Int): Double
/** Return the index for the (i, j)-th element in the backing array. */ /** Return the index for the (i, j)-th element in the backing array. */
private[mllib] def index(i: Int, j: Int): Int private[mllib] def index(i: Int, j: Int): Int
...@@ -163,7 +163,7 @@ class DenseMatrix( ...@@ -163,7 +163,7 @@ class DenseMatrix(
private[mllib] def apply(i: Int): Double = values(i) private[mllib] def apply(i: Int): Double = values(i)
private[mllib] def apply(i: Int, j: Int): Double = values(index(i, j)) override def apply(i: Int, j: Int): Double = values(index(i, j))
private[mllib] def index(i: Int, j: Int): Int = { private[mllib] def index(i: Int, j: Int): Int = {
if (!isTransposed) i + numRows * j else j + numCols * i if (!isTransposed) i + numRows * j else j + numCols * i
...@@ -398,7 +398,7 @@ class SparseMatrix( ...@@ -398,7 +398,7 @@ class SparseMatrix(
} }
} }
private[mllib] def apply(i: Int, j: Int): Double = { override def apply(i: Int, j: Int): Double = {
val ind = index(i, j) val ind = index(i, j)
if (ind < 0) 0.0 else values(ind) if (ind < 0) 0.0 else values(ind)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment