[
https://issues.apache.org/jira/browse/MAHOUT-1895?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15768549#comment-15768549
]
ASF GitHub Bot commented on MAHOUT-1895:
----------------------------------------
Github user dlyubimov commented on the issue:
https://github.com/apache/mahout/pull/262
> "While dense and sparse vectors may be created from
`TraversableOnce[Double]` such as `Array[Double]` and `TraversableOnce[(Int,
AnyVal)]` such as `Map[Int,Double]` respectively"
This is, iirc, is not quite true.
only dense vectors can be created from arrays, sparse vectors are
explicitly disallowed (or not supported, depends on your take).
So i have a few problems with this.
(1) similarly, if we want to create vector 2 array transformation, it
probably should only be allowed for dense vectors only, otherwise it invites
misuses.
(2) even when i do need an array out of dense vector, i usually use it
without copying (shallowly). In some implementations, it is adding array()
method which returns shallow backing array, if any, similarly to
ByteBuffer.array(); and in some implementations I am using a reflection to
access the private attribute (which is admittedly is a hack). The former is
preferred.
Either way, the gist of this point is that one quite more often needs a
backing array rather than a copy of such. This implementation forces copy-only
approach. Note that ByteBuffer doesn't have copying implementation (.toArray())
and only has backing array access (array()) for perhaps the same reasons.
Inviting misuse and inefficiency.
(3) Assuming (1) and (2) are overcome, this implementation is still
suboptimal for sparse implemetnations.
> Add convenience methods for converting Vectors to Scala types
> -------------------------------------------------------------
>
> Key: MAHOUT-1895
> URL: https://issues.apache.org/jira/browse/MAHOUT-1895
> Project: Mahout
> Issue Type: Bug
> Affects Versions: 0.12.2
> Reporter: Trevor Grant
> Assignee: Trevor Grant
> Priority: Minor
> Fix For: 0.13.0
>
>
> While dense and sparse vectors may be created from `TraversableOnce[Double]`
> such as `Array[Double]` and `TraversableOnce[(Int, AnyVal)]` such as
> `Map[Int,Double]` respectively. Converting back into this format is somewhat
> tedious. We should add convenience methods to take care of this.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)