Examples of assign()


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

  private static List<Vector> getPoints(double[][] raw) {
    List<Vector> points = new ArrayList<Vector>();
    int i = 0;
    for (double[] fr : raw) {
      Vector vec = new RandomAccessSparseVector(String.valueOf(i++), fr.length);
      vec.assign(fr);
      points.add(vec);
    }
    return points;
  }
 
View Full Code Here

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

  private static List<VectorWritable> getPoints(double[][] raw) {
    List<VectorWritable> points = new ArrayList<VectorWritable>();
    int i = 0;
    for (double[] fr : raw) {
      Vector vec = new RandomAccessSparseVector(String.valueOf(i++), fr.length);
      vec.assign(fr);
      points.add(new VectorWritable(vec));
    }
    return points;
  }
 
View Full Code Here

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

   * @return
   */
  @Override
  protected Vector getInitialVector(VectorIterable corpus) {
    Vector initialVector = new DenseVector(corpus.numCols());
    initialVector.assign(1/Math.sqrt(corpus.numCols()));
    return initialVector;
  }

  @Override
  public int run(String[] strings) throws Exception {
View Full Code Here

Examples of org.apache.mahout.math.matrix.DoubleMatrix1D.assign()

    }

    DoubleMatrix1D b = x.like();
    DoubleMatrix1D y = x.like();
    if (isUnitTriangular) {
      y.assign(1);
    } else {
      for (int i = 0; i < size; i++) {
        y.setQuick(i, A.getQuick(i, i));
      }
    }
View Full Code Here

Examples of org.apache.mahout.math.matrix.DoubleMatrix2D.assign()

    if (p == 0) {
      return DoubleFactory2D.dense.identity(A.rows());
    }
    DoubleMatrix2D T = A.like(); // temporary
    if (p == 1) {
      return T.assign(A);
    // safes one auxiliary matrix allocation
    if (p == 2) {
      blas.dgemm(false, false, 1, A, A, 0, T); // mult(A,A); // safes one auxiliary matrix allocation
      return T;
    }
View Full Code Here

Examples of org.apache.mahout.math.matrix.impl.DenseDoubleMatrix1D.assign()

        // so we need to calculate the centroid here once again based
        // on the cluster's documents.
        final DoubleMatrix1D centroid = new DenseDoubleMatrix1D(termDocumentMatrix.rows());
        for (IntCursor d : documents)
        {
            centroid.assign(termDocumentMatrix.viewColumn(d.value), Functions.PLUS);
        }

        final List<String> labels = Lists.newArrayListWithCapacity(labelCount);

        final int [] order = IndirectSort.mergesort(0, centroid.size(),
View Full Code Here

Examples of org.apache.mahout.math.matrix.impl.DenseDoubleMatrix2D.assign()

    @Test
    public void testMaxSparseness()
    {
        final DoubleMatrix2D sparse = new DenseDoubleMatrix2D(2, 2);
        sparse.assign(3);
        assertThat(MatrixUtils.computeSparseness(sparse)).isEqualTo(1);
    }

    @Test
    public void frobeniusNorm()
View Full Code Here

Examples of org.apache.mahout.matrix.DenseVector.assign()

      pi.set(k, p);
      if (max < p)
        max = p;
    }
    // normalize the probabilities by largest observed value
    pi.assign(new TimesFunction(), 1.0 / max);
    return pi;
  }

}
View Full Code Here

Examples of org.apache.mahout.matrix.SparseVector.assign()

  private static List<Vector> getPoints(double[][] raw) {
    List<Vector> points = new ArrayList<Vector>();
    for (double[] fr : raw) {
      Vector vec = new SparseVector(fr.length);
      vec.assign(fr);
      points.add(vec);
    }
    return points;
  }
View Full Code Here

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

      pi.set(k, p);
      if (max < p)
        max = p;
    }
    // normalize the probabilities by largest observed value
    pi.assign(new TimesFunction(), 1.0 / max);
    return pi;
  }

}
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.