Package org.apache.mahout.math

Examples of org.apache.mahout.math.DiagonalMatrix


  /**
   * Constructs a sampler with diagonal scale matrix.
   * @param diagonal The diagonal elements of the scale matrix.
   */
  public MultiNormal(Vector diagonal) {
    this(new DiagonalMatrix(diagonal), null);
  }
View Full Code Here


   * non-zero mean.
   * @param diagonal The scale matrix's principal diagonal.
   * @param mean The desired mean.  Set to null if zero mean is desired.
   */
  public MultiNormal(Vector diagonal, Vector mean) {
    this(new DiagonalMatrix(diagonal), mean);
  }
View Full Code Here

  public MultiNormal(int dimension) {
    this(null, null, dimension);
  }

  public MultiNormal(double radius, Vector mean) {
    this(new DiagonalMatrix(radius, mean.size()), mean);
  }
View Full Code Here

    for (Preference pref : prefs) {
      long userId = pref.getUserID();
      int userIdx = userIndex(userId);
      confidenceMatrix.setQuick(userIdx, userIdx, 1);
    }
    return new DiagonalMatrix(confidenceMatrix);
  }
View Full Code Here

    for (Preference pref : prefs) {
      long itemId = pref.getItemID();
      int itemIdx = itemIndex(itemId);
      confidenceMatrix.setQuick(itemIdx, itemIdx, 1);
    }
    return new DiagonalMatrix(confidenceMatrix);
  }
View Full Code Here

  private static Matrix ones(int size) {
    double[] vector = new double[size];
    for (int i = 0; i < size; i++) {
      vector[i] = 1;
    }
    return new DiagonalMatrix(vector);
  }
View Full Code Here

    SingularValueDecomposition svd = new SingularValueDecomposition(A);

    Vector reference = new DenseVector(svd.getSingularValues()).viewPart(0, 8);
    assertEquals(reference, s.getSingularValues());

    assertEquals(A, s.getU().times(new DiagonalMatrix(s.getSingularValues())).times(s.getV().transpose()));
  }
View Full Code Here

    assertEquals(v1, v2);
  }

  private static Matrix lowRankMatrix() {
    Matrix u = new RandomTrinaryMatrix(1, 20, 4, false);
    Matrix d = new DiagonalMatrix(new double[]{5, 3, 1, 0.5});
    Matrix v = new RandomTrinaryMatrix(2, 23, 4, false);

    return u.times(d).times(v.transpose());
  }
View Full Code Here

        return fileName.matches("V-.*");
      }
    })));

    // The values in A are pretty big so this is a pretty tight relative tolerance
    assertEquals(0, A.minus(u.times(new DiagonalMatrix(s.getSingularValues())).times(v.transpose())).aggregate(Functions.PLUS, Functions.ABS), 1.0e-7);
  }
View Full Code Here

    for (Preference pref : prefs) {
      long userId = pref.getUserID();
      int userIdx = userIndex(userId);
      confidenceMatrix.setQuick(userIdx, userIdx, 1);
    }
    return new DiagonalMatrix(confidenceMatrix);
  }
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.DiagonalMatrix

Copyright © 2018 www.massapicom. 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.