mahout-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhao zhendong <zhaozhend...@gmail.com>
Subject [Qestion] SequentialAccessSparseVector.dot(Vector)
Date Fri, 11 Jun 2010 09:01:26 GMT
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).


-- 
-------------------------------------------------------------

Zhen-Dong Zhao (Maxim)

<><<><><><><><><><>><><><><><>>>>>>

Department of Computer Science
School of Computing
National University of Singapore

>>>>>>><><><><><><><><<><>><><<<<<<

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message