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 @@ -454,10 +454,13 @@ class SparseMatrix @Since("2.0.0") (

require(values.length == rowIndices.length, "The number of row indices and values don't match! " +
s"values.length: ${values.length}, rowIndices.length: ${rowIndices.length}")
// The Or statement is for the case when the matrix is transposed
require(colPtrs.length == numCols + 1 || colPtrs.length == numRows + 1, "The length of the " +
"column indices should be the number of columns + 1. Currently, colPointers.length: " +
s"${colPtrs.length}, numCols: $numCols")
if (isTransposed) {
require(colPtrs.length == numRows + 1,
s"Expecting ${numRows + 1} colPtrs when numRows = $numRows but got ${colPtrs.length}")
} else {
require(colPtrs.length == numCols + 1,
s"Expecting ${numCols + 1} colPtrs when numCols = $numCols but got ${colPtrs.length}")
}
require(values.length == colPtrs.last, "The last value of colPtrs must equal the number of " +
s"elements. values.length: ${values.length}, colPtrs.last: ${colPtrs.last}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,13 @@ class SparseMatrix @Since("1.3.0") (

require(values.length == rowIndices.length, "The number of row indices and values don't match! " +
s"values.length: ${values.length}, rowIndices.length: ${rowIndices.length}")
// The Or statement is for the case when the matrix is transposed
require(colPtrs.length == numCols + 1 || colPtrs.length == numRows + 1, "The length of the " +
"column indices should be the number of columns + 1. Currently, colPointers.length: " +
s"${colPtrs.length}, numCols: $numCols")
if (isTransposed) {
require(colPtrs.length == numRows + 1,
s"Expecting ${numRows + 1} colPtrs when numRows = $numRows but got ${colPtrs.length}")
} else {
require(colPtrs.length == numCols + 1,
s"Expecting ${numCols + 1} colPtrs when numCols = $numCols but got ${colPtrs.length}")
}
require(values.length == colPtrs.last, "The last value of colPtrs must equal the number of " +
s"elements. values.length: ${values.length}, colPtrs.last: ${colPtrs.last}")

Expand Down