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());
}