To leave breadcrumbs: you decided that it is better to use Breeze library instead of DoubleMatrix since it has Sparse vector support. http://www.scalanlp.org/api/breeze/index.html#breeze.linalg.package