[
https://issues.apache.org/jira/browse/MAHOUT-34?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12588185#action_12588185
]
Samee Zahur commented on MAHOUT-34:
-----------------------------------
{quote}
I'm also thinking we should perhaps re-use the Element instance in
iterator.next?
{quote}
Yes, this is specially true when we go through the codes of DenseVector. But
the case I came up was this:
{code}
Element sum;
boolean first=true;
for(Element e : vec) {
if(first) {
sum=e;
first=false;
}else sum.set(e.get()+sum.get());
}
{code}
In the 'else' part above, if we reuse elements, both sum and e are actually
referring to the same object, and if vector size is more than 2, sum will
always just hold 2*lastelement rather than the intended value. These kind of
errors might be harder to detect in more complicated cases.
> Iterator interface for Vectors
> ------------------------------
>
> Key: MAHOUT-34
> URL: https://issues.apache.org/jira/browse/MAHOUT-34
> Project: Mahout
> Issue Type: New Feature
> Reporter: Samee Zahur
> Assignee: Karl Wettin
> Attachments: VectorIterator.3.patch.bz2,
> VectorIterator.patch.2.tar.bz2, VectorIterator.patch.tar.bz2
>
>
> Implemented an Iterator interface for the Vector classes. Was necessary for
> porting from Float[] used in some parts of the code.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.