Description
1, foreach: there are a lot of places that we need to traversal all the elements, current we impl like this:
var i = 0; while (i < vec.size) { val v = vec(i); ...; i += 1 }
This method is for both convenience and performace:
For a SparseVector, the total complexity is O(size * log(nnz)), since an apply call has log(nnz) complexity due to usage of binary search;
However, this can be optimized by operations of cursors.
2, foreachNonZero: the usage of foreachActive is mostly binded with filter value!=0, like
vec.foreachActive { case (i, v) => if (v != 0.0) { ... } }
Here we can add this method for convenience.
3, iterator/activeIterator/nonZeroIterator: add those three iterators, so that we can futuremore add/change some impls based on those iterators for both ml and mllib sides, to avoid vector conversions.
For example, I want to optimize PCA by using ml.stat.Summarizer instead of
Statistics.colStats/mllib.MultivariateStatisticalSummary, to avoid computation of unused variables.
After having these iterators, I can do it without vector conversions.
Attachments
Issue Links
- links to