Package org.apache.mahout.matrix

Examples of org.apache.mahout.matrix.Vector.cardinality()


  public double distance(Vector p1, Vector p2) {
    double result = 0;

    Vector res = p2.minus(p1);
    if (weights == null) {
      for (int i = 0; i < res.cardinality(); i++) {
        result += Math.abs(res.get(i));
      }
    }
    else {
      for (int i = 0; i < res.cardinality(); i++) {
View Full Code Here


      for (int i = 0; i < res.cardinality(); i++) {
        result += Math.abs(res.get(i));
      }
    }
    else {
      for (int i = 0; i < res.cardinality(); i++) {
        result += Math.abs(res.get(i) * weights.get(i)); // todo this is where the weights goes, right?
      }
    }

    return result;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.