Skip to content

Commit

Permalink
Copy data only when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
funes committed May 6, 2014
1 parent b85806c commit 64e7198
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ object Vectors {
new DenseVector(v.toArray) // Can't use underlying array directly, so make a new one
}
case v: BSV[Double] =>
new SparseVector(v.length, v.index.slice(0, v.used), v.data.slice(0, v.used))
if (v.index.length == v.used) {
new SparseVector(v.length, v.index, v.data)
}
else {
new SparseVector(v.length, v.index.slice(0, v.used), v.data.slice(0, v.used))
}
case v: BV[_] =>
sys.error("Unsupported Breeze vector type: " + v.getClass.getName)
}
Expand Down

0 comments on commit 64e7198

Please sign in to comment.