Skip to content

Commit

Permalink
fix test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxr committed Apr 2, 2014
1 parent a85262a commit 0d1491c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,18 @@ class RowRDDMatrix(
val V = Matrices.dense(n, sk, util.Arrays.copyOfRange(u.data, 0, n * sk))

if (computeU) {
val N = new BDM[Double](sk, n, util.Arrays.copyOfRange(v.data, 0, sk * n))
// N = Vk * Sk^{-1}
val N = new BDM[Double](n, sk, util.Arrays.copyOfRange(u.data, 0, n * sk))
var i = 0
var j = 0
while (i < sk) {
j = 0
val sigma = sigmas(i)
while (j < n) {
while (j < sk) {
i = 0
val sigma = sigmas(j)
while (i < n) {
N(i, j) /= sigma
j += 1
i += 1
}
i += 1
j += 1
}
val U = this.multiply(Matrices.fromBreeze(N))
SingularValueDecomposition(U, s, V)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import org.apache.spark.mllib.linalg.Vectors

class CoordinateRDDMatrixSuite extends FunSuite with LocalSparkContext {

val m = 4
val m = 5
val n = 4
var mat: CoordinateRDDMatrix = _

Expand All @@ -46,8 +46,8 @@ class CoordinateRDDMatrixSuite extends FunSuite with LocalSparkContext {
}

test("size") {
assert(mat.numRows() === 4)
assert(mat.numCols() === 5)
assert(mat.numRows() === m)
assert(mat.numCols() === n)
}

test("toIndexedRowRDDMatrix") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class RowRDDMatrixSuite extends FunSuite with LocalSparkContext {
val brzV = svd.V.toBreeze.asInstanceOf[BDM[Double]]
val rows = U.rows.collect()
val brzUt = new BDM[Double](n, m, rows.flatMap(r => r.toArray))
assert(closeToZero(brzUt.t * brzDiag(brzSigma) * brzV.t - A))
val UsVt = brzUt.t * brzDiag(brzSigma) * brzV.t
assert(closeToZero(UsVt - A))
val VtV: BDM[Double] = brzV.t * brzV
assert(closeToZero(VtV - BDM.eye[Double](n)))
val UtU = U.computeGramianMatrix().toBreeze.asInstanceOf[BDM[Double]]
Expand Down

0 comments on commit 0d1491c

Please sign in to comment.