Package org.apache.hama.commons.math.DoubleVector

Examples of org.apache.hama.commons.math.DoubleVector.DoubleVectorElement


    DoubleVector vec = new DenseDoubleVector(expectedRes);
    Iterator<DoubleVectorElement> itr = vec.iterate();
   
    int curIdx = 0;
    while (itr.hasNext()) {
      DoubleVectorElement elem = itr.next();
      assertEquals(curIdx, elem.getIndex());
      assertEquals(expectedRes[curIdx++], elem.getValue(), 0.000001);
    }
   
    Iterator<DoubleVectorElement> itrNonZero = vec.iterateNonDefault();
   
    curIdx = 0;
View Full Code Here


  public void testIterators() {
    DoubleVector v1 = new SparseDoubleVector(10, 5.5);
    Iterator<DoubleVectorElement> itr1 = v1.iterate();
    int idx1 = 0;
    while (itr1.hasNext()) {
      DoubleVectorElement elem = itr1.next();
      assertEquals(idx1++, elem.getIndex());
      assertEquals(5.5, elem.getValue(), 0.000001);
    }

    v1.set(2, 20);
    v1.set(6, 30);

    Iterator<DoubleVectorElement> itr2 = v1.iterateNonDefault();
    DoubleVectorElement elem = itr2.next();
    assertEquals(2, elem.getIndex());
    assertEquals(20, elem.getValue(), 0.000001);
    elem = itr2.next();
    assertEquals(6, elem.getIndex());
    assertEquals(30, elem.getValue(), 0.000001);

    assertFalse(itr2.hasNext());
  }
View Full Code Here

TOP

Related Classes of org.apache.hama.commons.math.DoubleVector.DoubleVectorElement

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.