Package org.apache.mahout.math

Examples of org.apache.mahout.math.Vector.clone()


      if (r.nextBoolean() || numRows == nonNullRows) {
        m.assignRow(numRows == nonNullRows ? i : c, v);
      } else {
        Vector other = m.getRow(r.nextInt(numRows));
        if (other != null && other.getLengthSquared() > 0) {
          m.assignRow(c, other.clone());
        }
      }
      //n += m.getRow(c).getLengthSquared();
    }
    return m;
View Full Code Here


        int itemIDIndex = usedItemsIterator.next().index();
        numberOfSimilarItemsUsed.setQuick(itemIDIndex, numberOfSimilarItemsUsed.getQuick(itemIDIndex) + 1);
      }

      numerators = numerators == null
          ? prefValue == BOOLEAN_PREF_VALUE ? simColumn.clone() : simColumn.times(prefValue)
          : numerators.plus(prefValue == BOOLEAN_PREF_VALUE ? simColumn : simColumn.times(prefValue));

      simColumn.assign(ABSOLUTE_VALUES);
      denominators = denominators == null ? simColumn : denominators.plus(simColumn);
    }
View Full Code Here

  @Override
  public void observe(VectorWritable x) {
    s0++;
    Vector v = x.get();
    if (s1 == null) {
      s1 = v.clone();
    } else {
      s1 = s1.plus(v);
    }
    if (s2 == null) {
      s2 = v.times(v);
View Full Code Here

  @Override
  public void observe(VectorWritable v) {
    Vector x = v.get();
    s0++;
    if (s1 == null) {
      s1 = x.clone();
    } else {
      s1 = s1.plus(x);
    }
    if (s2 == null) {
      s2 = x.times(x);
View Full Code Here

    Canopy cluster = new Canopy(new DenseVector(new double[] {0, 0}), 19,
        measure);
    clusters.add(cluster);
    List<VectorWritable> points = Lists.newArrayList();
    Vector delta = new DenseVector(new double[] { 0, Double.MIN_NORMAL });
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    representativePoints.put(cluster.getId(), points);
View Full Code Here

        measure);
    clusters.add(cluster);
    List<VectorWritable> points = Lists.newArrayList();
    Vector delta = new DenseVector(new double[] { 0, Double.MIN_NORMAL });
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    representativePoints.put(cluster.getId(), points);
    CDbwEvaluator evaluator = new CDbwEvaluator(representativePoints, clusters,
View Full Code Here

    clusters.add(cluster);
    List<VectorWritable> points = Lists.newArrayList();
    Vector delta = new DenseVector(new double[] { 0, Double.MIN_NORMAL });
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    representativePoints.put(cluster.getId(), points);
    CDbwEvaluator evaluator = new CDbwEvaluator(representativePoints, clusters,
        measure);
View Full Code Here

    List<VectorWritable> points = Lists.newArrayList();
    Vector delta = new DenseVector(new double[] { 0, Double.MIN_NORMAL });
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    representativePoints.put(cluster.getId(), points);
    CDbwEvaluator evaluator = new CDbwEvaluator(representativePoints, clusters,
        measure);
    assertEquals("inter cluster density", 0.0, evaluator.interClusterDensity(),
View Full Code Here

    Vector delta = new DenseVector(new double[] { 0, Double.MIN_NORMAL });
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    points.add(new VectorWritable(delta.clone()));
    representativePoints.put(cluster.getId(), points);
    CDbwEvaluator evaluator = new CDbwEvaluator(representativePoints, clusters,
        measure);
    assertEquals("inter cluster density", 0.0, evaluator.interClusterDensity(),
        EPSILON);
View Full Code Here

  public boolean shiftToMean(MeanShiftCanopy canopy) {
    Vector centroid = canopy.computeCentroid();
    canopy.setConverged(measure.distance(centroid, canopy.getCenter()) < convergenceDelta);
    canopy.setCenter(centroid);
    canopy.setNumPoints(1);
    canopy.setPointTotal(centroid.clone());
    return canopy.isConverged();
  }
 
  /**
   * Return if the point is covered by this canopy
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.