Package org.apache.mahout.math

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


   
    Vector x = new DenseVector(b.size());

    iterations = 0;
    Vector residual = b.minus(a.times(x));
    residualNormSquared = residual.dot(residual);

    log.info("Conjugate gradient initial residual norm = " + Math.sqrt(residualNormSquared));
    double previousConditionedNormSqr = 0.0;
    Vector updateDirection = null;
    while (Math.sqrt(residualNormSquared) > maxError && iterations < maxIterations) {
View Full Code Here


        // Apply Householder similarity transformation
        // H = (I-u*u'/h)*H*(I-u*u')/h)

        Vector ortPiece = ort.viewPart(m, high - m + 1);
        for (int j = m; j < n; j++) {
          double f = ortPiece.dot(hessenBerg.viewColumn(j).viewPart(m, high - m + 1)) / h;
          hessenBerg.viewColumn(j).viewPart(m, high - m + 1).assign(ortPiece, Functions.plusMult(-f));
        }

        for (int i = 0; i <= high; i++) {
          double f = ortPiece.dot(hessenBerg.viewRow(i).viewPart(m, high - m + 1)) / h;
View Full Code Here

          double f = ortPiece.dot(hessenBerg.viewColumn(j).viewPart(m, high - m + 1)) / h;
          hessenBerg.viewColumn(j).viewPart(m, high - m + 1).assign(ortPiece, Functions.plusMult(-f));
        }

        for (int i = 0; i <= high; i++) {
          double f = ortPiece.dot(hessenBerg.viewRow(i).viewPart(m, high - m + 1)) / h;
          hessenBerg.viewRow(i).viewPart(m, high - m + 1).assign(ortPiece, Functions.plusMult(-f));
        }
        ort.setQuick(m, scale * ort.getQuick(m));
        hessenBerg.setQuick(m, m - 1, scale * g);
      }
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.viewRow(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

      boolean isSymmetric) {
    if (e.getLengthSquared() == 0) {
      return;
    }
    Vector afterMultiply = isSymmetric ? corpus.times(e) : corpus.timesSquared(e);
    double dot = afterMultiply.dot(e);
    double afterNorm = afterMultiply.getLengthSquared();
    double error = 1 - Math.abs(dot / Math.sqrt(afterNorm * e.getLengthSquared()));
    log.info("the eigen-error: {} for eigen {}", error, i);
    assertTrue("Error: {" + error + " too high! (for eigen " + i + ')', Math.abs(error) < errorMargin);
  }
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

   
    Vector x = new DenseVector(b.size());

    iterations = 0;
    Vector residual = b.minus(a.times(x));
    residualNormSquared = residual.dot(residual);

    log.info("Conjugate gradient initial residual norm = {}", Math.sqrt(residualNormSquared));
    double previousConditionedNormSqr = 0.0;
    Vector updateDirection = null;
    while (Math.sqrt(residualNormSquared) > maxError && iterations < maxIterations) {
View Full Code Here

        double mu = Math.min(k + 1, 200);
       
       
        // the dot product of the parameter vector and the current instance
        // is the hypothesis value for the currnet instance
        double hypothesis_value = v.dot(this.polr.getBeta().viewRow(0));
       
        double error = Math.abs( hypothesis_value - actual );


        if (Double.POSITIVE_INFINITY == error) {
View Full Code Here

        batch_vec_factory_time += (endTime - startTime);

       
        // the dot product of the parameter vector and the current instance
        // is the hypothesis value for the currnet instance
        double hypothesis_value = v.dot(this.polr.getBeta().viewRow(0));
       
        double error = Math.abs( hypothesis_value - actual );


        if (Double.POSITIVE_INFINITY == error) {
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.