Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class IndexedRowMatrix(
val indexedRows = indices.zip(svd.U.rows).map { case (i, v) =>
IndexedRow(i, v)
}
new IndexedRowMatrix(indexedRows, nRows, nCols)
new IndexedRowMatrix(indexedRows, nRows, svd.U.numCols().toInt)
} else {
null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ class IndexedRowMatrixSuite extends SparkFunSuite with MLlibTestSparkContext {
assert(closeToZero(U * brzDiag(s) * V.t - localA))
}

test("validate matrix sizes of svd") {
val k = 2
val A = new IndexedRowMatrix(indexedRows)
val svd = A.computeSVD(k, computeU = true)
assert(svd.U.numRows() === m)
assert(svd.U.numCols() === k)
assert(svd.s.size === k)
assert(svd.V.numRows === n)
assert(svd.V.numCols === k)
}

test("validate k in svd") {
val A = new IndexedRowMatrix(indexedRows)
intercept[IllegalArgumentException] {
Expand Down