Examples of CardinalityException


Examples of org.apache.mahout.math.CardinalityException

  }
 
  @Override
  public double distance(Vector v1, Vector v2) {
    if (v1.size() != v2.size()) {
      throw new CardinalityException(v1.size(), v2.size());
    }
    double lengthSquaredv1 = v1.getLengthSquared();
    double lengthSquaredv2 = v2.getLengthSquared();
   
    double dotProduct = v2.dot(v1);
View Full Code Here

Examples of org.apache.mahout.math.CardinalityException

  }

  @Override
  public double distance(Vector v1, Vector v2) {
    if (v1.size() != v2.size()) {
      throw new CardinalityException(v1.size(), v2.size());
    }
    if (inverseCovarianceMatrix== null)
      System.out.println();
    return Math.sqrt(v1.minus(v2).dot(Algebra.mult(inverseCovarianceMatrix, v1.minus(v2))));
  }
View Full Code Here

Examples of org.apache.mahout.math.CardinalityException

   * @param m A covariance matrix.
   * @throws IllegalArgumentException if <tt>eigen values equal to 0 found</tt>.
   */
  public void setCovarianceMatrix(Matrix m) {
    if (m.numRows() != m.numCols()) {
      throw new CardinalityException(m.numRows(), m.numCols());
    }
    // See http://www.mlahanas.de/Math/svd.htm for details,
    // which specifically details the case of covariance matrix inversion
    // Complexity: O(min(nm2,mn2))
    SingularValueDecomposition svd = new SingularValueDecomposition(m);
View Full Code Here

Examples of org.apache.mahout.math.CardinalityException

   * @param outPath path to write result to
   * @return    a DistributedRowMatrix containing the product
   */
  public DistributedRowMatrix times(DistributedRowMatrix other, Path outPath) throws IOException {
    if (numRows != other.numRows()) {
      throw new CardinalityException(numRows, other.numRows());
    }

    Configuration initialConf = getConf() == null ? new Configuration() : getConf();
    Configuration conf =
        MatrixMultiplicationJob.createMatrixMultiplyJobConf(initialConf,
View Full Code Here

Examples of org.apache.mahout.math.CardinalityException

    if (a.numRows() != a.numCols()) {
      throw new IllegalArgumentException("Matrix must be square, symmetric and positive definite.");
    }
   
    if (a.numCols() != b.size()) {
      throw new CardinalityException(a.numCols(), b.size());
    }

    if (maxIterations <= 0) {
      throw new IllegalArgumentException("Max iterations must be positive.");     
    }
View Full Code Here

Examples of org.apache.mahout.matrix.CardinalityException

  }

  @Override
  public double distance(Vector v1, Vector v2) {
    if (v1.cardinality() != v2.cardinality())
      throw new CardinalityException();
    double result = 0;
    for (int i = 0; i < v1.cardinality(); i++) {
      double delta = v2.getQuick(i) - v1.getQuick(i);
      result += delta * delta;
    }
View Full Code Here

Examples of org.apache.mahout.matrix.CardinalityException

  }

@Override
public double distance(Vector v1, Vector v2) {
    if (v1.cardinality() != v2.cardinality())
      throw new CardinalityException();
    double result = 0;
    for (int i = 0; i < v1.cardinality(); i++)
      result += Math.abs(v2.getQuick(i) - v1.getQuick(i));
    return result;
  }
View Full Code Here

Examples of org.apache.mahout.matrix.CardinalityException

  }

  @Override
  public double distance(Vector v1, Vector v2) {
    if (v1.size() != v2.size()) {
      throw new CardinalityException();
    }
    double lengthSquaredv1 = 0.0;
    Iterator<Vector.Element> iter = v1.iterateNonZero();
    while (iter.hasNext()) {
      Vector.Element elt = iter.next();
View Full Code Here

Examples of org.apache.mahout.matrix.CardinalityException

  }

  @Override
  public double distance(Vector v1, Vector v2) {
    if (v1.size() != v2.size()) {
      throw new CardinalityException();
    }
    Vector vector = v1.minus(v2);
    return vector.dot(vector);
  }
View Full Code Here

Examples of org.apache.mahout.matrix.CardinalityException

  }

  @Override
  public double distance(double centroidLengthSquare, Vector centroid, Vector v) {
    if (centroid.size() != v.size()) {
      throw new CardinalityException();
    }
    return centroidLengthSquare + v.getDistanceSquared(centroid);
  }
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.