Sequential access vector has a bug in dot
-----------------------------------------

                 Key: MAHOUT-413
                 URL: https://issues.apache.org/jira/browse/MAHOUT-413
             Project: Mahout
          Issue Type: Bug
            Reporter: Ted Dunning


Zhao wrote:

{quote}

Hi,

One strange thing, SequentialAccessSparseVector.dot() seems does NOT work
correctly. When I change the Vector w = new
RandomAccessSparseVector(Integer.MAX_VALUE, 12); Then the code works well.

I check the source code of SequentialAccessSparseVector.dot(), it checks the
index of two Vectors(if both of them are instance of
SequentialAccessSparseVector), once they mis-match, it will return 0.0.

*Why do we need such constrain?
*
In this case, what's the best way to get dot product between two mis-matched
SequentialAccessSparseVector instances?

Code:
 Vector w = new SequentialAccessSparseVector(Integer.MAX_VALUE, 12);
 w.set(1, 0.4);
 w.set(2, 0.4);
 w.set(3, -0.666666667);

 Vector v = new SequentialAccessSparseVector(Integer.MAX_VALUE, 12);
 v.set(3, 1);
 System.out.println(datastore.getFeatureRow(2).dot(w));

 The result is 0.0 (should be -0.666666667).
{quote}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to