mahout-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrice Seyed <>
Subject divide a vector (sum) by a double, error
Date Mon, 16 Jun 2014 16:01:20 GMT
Hi all,

I have attempted to write a method centroid() that

1) sums a HashSet of org.apache.mahout.math.Vector (vectors that are
DenseVector), and
2) (org.apache.mahout.math.Vector.divide) divides the summed vector by
its size, as a double.

I get an error:

Exception in thread "main" java.lang.IncompatibleClassChangeError:
class org.apache.mahout.math.function.Functions$1 has interface
org.apache.mahout.math.function.DoubleFunction as super class

I've tried this with a set of DenseVector and
SequentialAccessSparseVector with the same result.

Any help appreciated, the actual method is below.
I noticed a class Centroid in the mahout distribution, but seems to
cover a different sense of centroid than that I'm implementing here.


public Vector centroid (HashSet<Vector> vectors){

Iterator<Vector> it = vectors.iterator();

Vector sum =;


Vector aVector =;

sum =;



Integer totalVectors = vectors.size();

double dlTotalVectors = totalVectors.doubleValue();

return sum.divide(dlTotalVectors);


View raw message