Package org.apache.mahout.math

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


        plusMult.setMultiplicator(-xii);
        bCol.assign(sq, plusMult);
      }

      for (int i = 0; i < k; i++) {
        vRow.setQuick(i, bCol.dot(uHat.viewColumn(i)) / sValues.getQuick(i));
      }
      context.write(key, vRowWritable);
    }

    @Override
View Full Code Here


    for (int c = 0; c < n; c++) {
      Vector col = mx.viewColumn(c);
      for (int c1 = 0; c1 < c; c1++) {
        Vector viewC1 = mx.viewColumn(c1);
        col.assign(col.minus(viewC1.times(viewC1.dot(col))));

      }
      final double norm2 = col.norm(2);
      col.assign(new DoubleFunction() {
        @Override
View Full Code Here

    w.addToVector("and", v3);
    w.addToVector("more", v3);
    assertEquals(0, v3.minus(v2).norm(1), 0);

    // moreover, the locations set in the unweighted case should be the same as in the weighted case
    assertEquals(v3.zSum(), v3.dot(v1), 0);
  }

  @Test
  public void testAsString() {
    Locale.setDefault(Locale.ENGLISH);
View Full Code Here

      v.assign(gen);
      long hash = HashedVector.computeHash64(v, projection);
      final int bitDot = Long.bitCount(qhash ^ hash);
      count[bitDot]++;
      if (count[bitDot] < 200) {
        System.out.printf("%d, %.3f\n", bitDot, v.dot(query) / Math.sqrt(v.getLengthSquared() * query.getLengthSquared()));
      }
    }
    for (int i = 0; i < 65; ++i) {
      System.out.printf("%d, %d\n", i, count[i]);
    }
View Full Code Here

    for (Vector.Element element : data.all()) {
      element.set(gen.nextDouble() < 0.3 ? 1 : 0);
    }

    double p = 1 / (1 + Math.exp(1.5 - data.dot(beta)));
    int target = 0;
    if (gen.nextDouble() < p) {
      target = 1;
    }
    return new AdaptiveLogisticRegression.TrainingExample(i, null, target, data);
View Full Code Here

  public EigenStatus verify(VectorIterable corpus, Vector vector) {
    Vector resultantVector = corpus.timesSquared(vector);
    double newNorm = resultantVector.norm(2);
    double oldNorm = vector.norm(2);
    double eigenValue = (newNorm > 0 && oldNorm > 0) ? newNorm / oldNorm : 1;
    double cosAngle = (newNorm > 0 && oldNorm > 0) ? resultantVector.dot(vector) / (newNorm * oldNorm) : 0;
    return new EigenStatus(eigenValue, cosAngle, false);
  }

}
View Full Code Here

      state.getHelperVector().set(i, 0);
    }
    if (DEBUG && currentPseudoEigen.norm(2) > 0) {
      for (int i = 0; i < state.getNumEigensProcessed(); i++) {
        Vector previousEigen = previousEigens.getRow(i);
        log.info("dot with previous: {}", previousEigen.dot(currentPseudoEigen) / currentPseudoEigen.norm(2));
      }
    }
    /*
     * Step 3: verify how eigen-like the prospective eigen is.  This is potentially asynchronous.
     */
 
View Full Code Here

    for (Vector.Element element : data) {
      element.set(gen.nextDouble() < 0.3 ? 1 : 0);
    }

    double p = 1 / (1 + Math.exp(1.5 - data.dot(beta)));
    int target = 0;
    if (gen.nextDouble() < p) {
      target = 1;
    }
    return new AdaptiveLogisticRegression.TrainingExample(i, null, target, data);
View Full Code Here

    protected void map(IntWritable key, VectorWritable value, Context context)
      throws IOException, InterruptedException {
      Vector qRow = value.get();
      for (int i = 0; i < k; i++) {
        vRow.setQuick(i,
                      qRow.dot(uHat.getColumn(i)) / sValues.getQuick(i));
      }
      context.write(key, vRowWritable); // U inherits original A row labels.
    }

    @Override
View Full Code Here

      throws IOException, InterruptedException {
      Vector qRow = value.get();
      if (sValues != null) {
        for (int i = 0; i < k; i++) {
          uRow.setQuick(i,
                        qRow.dot(uHat.getColumn(i)) * sValues.getQuick(i));
        }
      } else {
        for (int i = 0; i < k; i++) {
          uRow.setQuick(i, qRow.dot(uHat.getColumn(i)));
        }
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.