Package mikera.vectorz.impl

Examples of mikera.vectorz.impl.SparseHashedVector


public class SparseArrays {
  public static final int SIZE=1000000;
  private static Random r=new Random();

  public static SparseHashedVector createRow() {
    SparseHashedVector v=SparseHashedVector.createLength(SIZE);
   
    for (int i=0; i<1000; i++) {
      v.set(r.nextInt(SIZE), r.nextDouble());
    }

    return v;
  }
View Full Code Here


public class TestSparseVectors {

  @Test
  public void testHashed() {
    SparseHashedVector v=SparseHashedVector.createLength(10);
    assertEquals(0,v.nonZeroCount());

    v.set(1,1);
    assertEquals(1.0,v.elementSum(),0.0);
    assertEquals(1,v.nonZeroCount());
   
  }
View Full Code Here

TOP

Related Classes of mikera.vectorz.impl.SparseHashedVector

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.