Package org.apache.mahout.math

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


      Vector nextVector = isSymmetric ? corpus.times(currentVector) : corpus.timesSquared(currentVector);
      log.info("{} passes through the corpus so far...", i);
      if(state.getScaleFactor() <= 0) {
        state.setScaleFactor(calculateScaleFactor(nextVector));
      }
      nextVector.assign(new Scale(1.0 / state.getScaleFactor()));
      if(previousVector != null) {
        nextVector.assign(previousVector, new PlusMult(-beta));
      }
      // now orthogonalize
      double alpha = currentVector.dot(nextVector);
View Full Code Here


      if(state.getScaleFactor() <= 0) {
        state.setScaleFactor(calculateScaleFactor(nextVector));
      }
      nextVector.assign(new Scale(1.0 / state.getScaleFactor()));
      if(previousVector != null) {
        nextVector.assign(previousVector, new PlusMult(-beta));
      }
      // now orthogonalize
      double alpha = currentVector.dot(nextVector);
      nextVector.assign(currentVector, new PlusMult(-alpha));
      endTime(TimingSection.ITERATE);
View Full Code Here

      if(previousVector != null) {
        nextVector.assign(previousVector, new PlusMult(-beta));
      }
      // now orthogonalize
      double alpha = currentVector.dot(nextVector);
      nextVector.assign(currentVector, new PlusMult(-alpha));
      endTime(TimingSection.ITERATE);
      startTime(TimingSection.ORTHOGANLIZE);
      orthoganalizeAgainstAllButLast(nextVector, state);
      endTime(TimingSection.ORTHOGANLIZE);
      // and normalize
View Full Code Here

      if (outOfRange(beta) || outOfRange(alpha)) {
        log.warn("Lanczos parameters out of range: alpha = {}, beta = {}.  Bailing out early!",
            alpha, beta);
        break;
      }
      nextVector.assign(new Scale(1 / beta));
      state.setBasisVector(i, nextVector);
      previousVector = currentVector;
      currentVector = nextVector;
      // save the projections and norms!
      triDiag.set(i - 1, i - 1, alpha);
View Full Code Here

      int i = 0;
      Vector pdfs = new DenseVector(models.size());
      for (Cluster model : models) {
        pdfs.set(i++, model.pdf(new VectorWritable(instance)));
      }
      return pdfs.assign(new TimesFunction(), 1.0 / pdfs.zSum());
    }
  }
 
  @Override
  public double classifyScalar(Vector instance) {
View Full Code Here

    double docTotal = wordCounts.zSum();
    int docLength = wordCounts.size(); // cardinality of document vectors
   
    // initialize variational approximation to p(z|doc)
    Vector gamma = new DenseVector(state.getNumTopics());
    gamma.assign(state.getTopicSmoothing() + docTotal / state.getNumTopics());
    Vector nextGamma = new DenseVector(state.getNumTopics());
    createPhiMatrix(docLength);
   
    Vector digammaGamma = digammaGamma(gamma);
   
View Full Code Here

    return phi;
  }
 
  private static Vector digamma(Vector v) {
    Vector digammaGamma = new DenseVector(v.size());
    digammaGamma.assign(v, new DoubleDoubleFunction() {
      @Override
      public double apply(double unused, double g) {
        return digamma(g);
      }
    });
View Full Code Here

      int rowIndex = r.get();

      Vector row = v.get();
      row = row.normalize(1);
      if (stayingProbability != 1.0) {
        row.assign(Functions.MULT, stayingProbability);
      }

      Iterator<Vector.Element> it = row.iterateNonZero();
      while (it.hasNext()) {
        Vector.Element e = it.next();
View Full Code Here

    PartialRowEmitter btEmitter = new PartialRowEmitter() {
      @Override
      public void emitRow(int rowNum, Vector row) {
        Vector btRow = btRows.get(rowNum);
        if (btRow != null) {
          btRow.assign(row, Functions.PLUS);
        }
        btRows.put(rowNum, btRow == null ? new DenseVector(row) : btRow);
      }
    };
View Full Code Here

      @Override
      public void emitRow(int rowNum, Vector row) {
        Vector bbtRow = bbt.get(rowNum);
        if (bbtRow != null) {
          bbtRow.assign(row, Functions.PLUS);
        }
        bbt.put(rowNum, bbtRow == null ? new DenseVector(row) : bbtRow);
      }
    };
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.