@@ -115,7 +115,7 @@ sealed trait Matrix extends Serializable {
115115 *
116116 * @param numRows number of rows
117117 * @param numCols number of columns
118- * @param values matrix entries in column major
118+ * @param values matrix entries in column major if not transposed or in row major otherwise
119119 * @param isTransposed whether the matrix is transposed. If true, `values` stores the matrix in
120120 * row major.
121121 */
@@ -187,7 +187,7 @@ class DenseMatrix(
187187 this
188188 }
189189
190- override def transpose : Matrix = new DenseMatrix (numCols, numRows, values, ! isTransposed)
190+ override def transpose : DenseMatrix = new DenseMatrix (numCols, numRows, values, ! isTransposed)
191191
192192 private [spark] override def foreachActive (f : (Int , Int , Double ) => Unit ): Unit = {
193193 if (! isTransposed) {
@@ -217,9 +217,11 @@ class DenseMatrix(
217217 }
218218 }
219219
220- /** Generate a `SparseMatrix` from the given `DenseMatrix`. The new matrix will have isTransposed
221- * set to false. */
222- def toSparse (): SparseMatrix = {
220+ /**
221+ * Generate a `SparseMatrix` from the given `DenseMatrix`. The new matrix will have isTransposed
222+ * set to false.
223+ */
224+ def toSparse : SparseMatrix = {
223225 val spVals : MArrayBuilder [Double ] = new MArrayBuilder .ofDouble
224226 val colPtrs : Array [Int ] = new Array [Int ](numCols + 1 )
225227 val rowIndices : MArrayBuilder [Int ] = new MArrayBuilder .ofInt
@@ -282,7 +284,7 @@ object DenseMatrix {
282284 }
283285
284286 /**
285- * Generate a `DenseMatrix` consisting of i.i.d. uniform random numbers.
287+ * Generate a `DenseMatrix` consisting of ` i.i.d.` uniform random numbers.
286288 * @param numRows number of rows of the matrix
287289 * @param numCols number of columns of the matrix
288290 * @param rng a random number generator
@@ -293,7 +295,7 @@ object DenseMatrix {
293295 }
294296
295297 /**
296- * Generate a `DenseMatrix` consisting of i.i.d. gaussian random numbers.
298+ * Generate a `DenseMatrix` consisting of ` i.i.d.` gaussian random numbers.
297299 * @param numRows number of rows of the matrix
298300 * @param numCols number of columns of the matrix
299301 * @param rng a random number generator
@@ -336,10 +338,10 @@ object DenseMatrix {
336338 *
337339 * @param numRows number of rows
338340 * @param numCols number of columns
339- * @param colPtrs the index corresponding to the start of a new column
340- * @param rowIndices the row index of the entry. They must be in strictly increasing order for each
341- * column
342- * @param values non-zero matrix entries in column major
341+ * @param colPtrs the index corresponding to the start of a new column (if not transposed)
342+ * @param rowIndices the row index of the entry (if not transposed) . They must be in strictly
343+ * increasing order for each column
344+ * @param values nonzero matrix entries in column major (if not transposed)
343345 * @param isTransposed whether the matrix is transposed. If true, the matrix can be considered
344346 * Compressed Sparse Row (CSR) format, where `colPtrs` behaves as rowPtrs,
345347 * and `rowIndices` behave as colIndices, and `values` are stored in row major.
@@ -434,7 +436,7 @@ class SparseMatrix(
434436 this
435437 }
436438
437- override def transpose : Matrix =
439+ override def transpose : SparseMatrix =
438440 new SparseMatrix (numCols, numRows, colPtrs, rowIndices, values, ! isTransposed)
439441
440442 private [spark] override def foreachActive (f : (Int , Int , Double ) => Unit ): Unit = {
@@ -464,9 +466,11 @@ class SparseMatrix(
464466 }
465467 }
466468
467- /** Generate a `DenseMatrix` from the given `SparseMatrix`. The new matrix will have isTransposed
468- * set to false. */
469- def toDense (): DenseMatrix = {
469+ /**
470+ * Generate a `DenseMatrix` from the given `SparseMatrix`. The new matrix will have isTransposed
471+ * set to false.
472+ */
473+ def toDense : DenseMatrix = {
470474 new DenseMatrix (numRows, numCols, toArray)
471475 }
472476}
@@ -593,7 +597,7 @@ object SparseMatrix {
593597 }
594598
595599 /**
596- * Generate a `SparseMatrix` consisting of i.i.d. uniform random numbers. The number of non-zero
600+ * Generate a `SparseMatrix` consisting of ` i.i.d` . uniform random numbers. The number of non-zero
597601 * elements equal the ceiling of `numRows` x `numCols` x `density`
598602 *
599603 * @param numRows number of rows of the matrix
@@ -608,7 +612,7 @@ object SparseMatrix {
608612 }
609613
610614 /**
611- * Generate a `SparseMatrix` consisting of i.i.d. gaussian random numbers.
615+ * Generate a `SparseMatrix` consisting of ` i.i.d` . gaussian random numbers.
612616 * @param numRows number of rows of the matrix
613617 * @param numCols number of columns of the matrix
614618 * @param density the desired density for the matrix
@@ -626,7 +630,7 @@ object SparseMatrix {
626630 * @return Square `SparseMatrix` with size `values.length` x `values.length` and non-zero
627631 * `values` on the diagonal
628632 */
629- def diag (vector : Vector ): SparseMatrix = {
633+ def spdiag (vector : Vector ): SparseMatrix = {
630634 val n = vector.size
631635 vector match {
632636 case sVec : SparseVector =>
@@ -722,7 +726,7 @@ object Matrices {
722726 def speye (n : Int ): Matrix = SparseMatrix .speye(n)
723727
724728 /**
725- * Generate a `DenseMatrix` consisting of i.i.d. uniform random numbers.
729+ * Generate a `DenseMatrix` consisting of ` i.i.d.` uniform random numbers.
726730 * @param numRows number of rows of the matrix
727731 * @param numCols number of columns of the matrix
728732 * @param rng a random number generator
@@ -732,7 +736,7 @@ object Matrices {
732736 DenseMatrix .rand(numRows, numCols, rng)
733737
734738 /**
735- * Generate a `SparseMatrix` consisting of i.i.d. gaussian random numbers.
739+ * Generate a `SparseMatrix` consisting of ` i.i.d.` gaussian random numbers.
736740 * @param numRows number of rows of the matrix
737741 * @param numCols number of columns of the matrix
738742 * @param density the desired density for the matrix
@@ -743,7 +747,7 @@ object Matrices {
743747 SparseMatrix .sprand(numRows, numCols, density, rng)
744748
745749 /**
746- * Generate a `DenseMatrix` consisting of i.i.d. gaussian random numbers.
750+ * Generate a `DenseMatrix` consisting of ` i.i.d.` gaussian random numbers.
747751 * @param numRows number of rows of the matrix
748752 * @param numCols number of columns of the matrix
749753 * @param rng a random number generator
@@ -753,7 +757,7 @@ object Matrices {
753757 DenseMatrix .randn(numRows, numCols, rng)
754758
755759 /**
756- * Generate a `SparseMatrix` consisting of i.i.d. gaussian random numbers.
760+ * Generate a `SparseMatrix` consisting of ` i.i.d.` gaussian random numbers.
757761 * @param numRows number of rows of the matrix
758762 * @param numCols number of columns of the matrix
759763 * @param density the desired density for the matrix
0 commit comments