Package org.apache.mahout.math

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


    // should have 9 values set
    assertEquals(9.0, v.norm(0), 0);
    // all should be = 1 except for the 3.1
    assertEquals(3.1, v.maxValue(), 0);
    v.set(v.maxValueIndex(), 0);
    assertEquals(8.0, v.norm(0), 0);
    assertEquals(8.0, v.norm(1), 0);
    assertEquals(1.0, v.maxValue(), 0);

    v.assign(0);
    t = csv.processLine("ignore,5.3,no,line, \"and more text and more\",ignore", v);
View Full Code Here


    assertEquals(9.0, v.norm(0), 0);
    // all should be = 1 except for the 3.1
    assertEquals(3.1, v.maxValue(), 0);
    v.set(v.maxValueIndex(), 0);
    assertEquals(8.0, v.norm(0), 0);
    assertEquals(8.0, v.norm(1), 0);
    assertEquals(1.0, v.maxValue(), 0);

    v.assign(0);
    t = csv.processLine("ignore,5.3,no,line, \"and more text and more\",ignore", v);
    assertEquals(1, t);
View Full Code Here

    v.assign(0);
    t = csv.processLine("ignore,5.3,no,line, \"and more text and more\",ignore", v);
    assertEquals(1, t);

    // should have 9 values set
    assertEquals(9.0, v.norm(0), 0);
    // all should be = 1 except for the 3.1
    assertEquals(5.3, v.maxValue(), 0);
    v.set(v.maxValueIndex(), 0);
    assertEquals(8.0, v.norm(0), 0);
    assertEquals(10.339850002884626, v.norm(1), 1.0e-6);
View Full Code Here

    // should have 9 values set
    assertEquals(9.0, v.norm(0), 0);
    // all should be = 1 except for the 3.1
    assertEquals(5.3, v.maxValue(), 0);
    v.set(v.maxValueIndex(), 0);
    assertEquals(8.0, v.norm(0), 0);
    assertEquals(10.339850002884626, v.norm(1), 1.0e-6);
    assertEquals(1.5849625007211563, v.maxValue(), 1.0e-6);

    v.assign(0);
    t = csv.processLine("ignore,5.3,invalid,line, \"and more text and more\",ignore", v);
View Full Code Here

    assertEquals(9.0, v.norm(0), 0);
    // all should be = 1 except for the 3.1
    assertEquals(5.3, v.maxValue(), 0);
    v.set(v.maxValueIndex(), 0);
    assertEquals(8.0, v.norm(0), 0);
    assertEquals(10.339850002884626, v.norm(1), 1.0e-6);
    assertEquals(1.5849625007211563, v.maxValue(), 1.0e-6);

    v.assign(0);
    t = csv.processLine("ignore,5.3,invalid,line, \"and more text and more\",ignore", v);
    assertEquals(1, t);
View Full Code Here

    v.assign(0);
    t = csv.processLine("ignore,5.3,invalid,line, \"and more text and more\",ignore", v);
    assertEquals(1, t);

    // should have 9 values set
    assertEquals(9.0, v.norm(0), 0);
    // all should be = 1 except for the 3.1
    assertEquals(5.3, v.maxValue(), 0);
    v.set(v.maxValueIndex(), 0);
    assertEquals(8.0, v.norm(0), 0);
    assertEquals(10.339850002884626, v.norm(1), 1.0e-6);
View Full Code Here

    // should have 9 values set
    assertEquals(9.0, v.norm(0), 0);
    // all should be = 1 except for the 3.1
    assertEquals(5.3, v.maxValue(), 0);
    v.set(v.maxValueIndex(), 0);
    assertEquals(8.0, v.norm(0), 0);
    assertEquals(10.339850002884626, v.norm(1), 1.0e-6);
    assertEquals(1.5849625007211563, v.maxValue(), 1.0e-6);
  }

  @Test
View Full Code Here

    assertEquals(9.0, v.norm(0), 0);
    // all should be = 1 except for the 3.1
    assertEquals(5.3, v.maxValue(), 0);
    v.set(v.maxValueIndex(), 0);
    assertEquals(8.0, v.norm(0), 0);
    assertEquals(10.339850002884626, v.norm(1), 1.0e-6);
    assertEquals(1.5849625007211563, v.maxValue(), 1.0e-6);
  }

  @Test
  public void testDictionaryOrder() {
View Full Code Here

      endTime(TimingSection.ITERATE);
      startTime(TimingSection.ORTHOGANLIZE);
      orthoganalizeAgainstAllButLast(nextVector, state);
      endTime(TimingSection.ORTHOGANLIZE);
      // and normalize
      beta = nextVector.norm(2);
      if (outOfRange(beta) || outOfRange(alpha)) {
        log.warn("Lanczos parameters out of range: alpha = {}, beta = {}.  Bailing out early!",
            alpha, beta);
        break;
      }
View Full Code Here

public class SimpleEigenVerifier implements SingularVectorVerifier {

  @Override
  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

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.