Examples of elementSum()


Examples of mikera.matrixx.AMatrix.elementSum()

    startTimer();
   
    AMatrix t=Matrixx.createRandomMatrix(SIZE, CSIZE);
    printTime("Construct dense matrix: ");
   
    System.out.println("Dense element sum = "+t.elementSum());

    // Finally compute the innerProduct (matrix multiplication) of
    // sparse matrix with dense matrix
   
    startTimer();
View Full Code Here

Examples of mikera.matrixx.AMatrix.elementSum()

   
    AMatrix result=m.innerProduct(t);
   
    printTime("Multiply with dense matrix: ");
   
    System.out.println("Result element sum = "+result.elementSum());
    // if this demo is working, the element sum should be roughly the same before and after transformation
    // (modulo some small numerical errors)

        // ----------------------------------------------------------------------
    // Construct another (smaller) sparse matrix.
View Full Code Here

Examples of mikera.matrixx.AMatrix.elementSum()

    AMatrix m=Matrixx.createSparse(2000000,2000000);
    m.set(3,4,7.0);
   
    AMatrix r=m.innerProduct(m.getTranspose());
    assertEquals(49.0,r.get(3,3),0.0);
    assertEquals(49.0,r.elementSum(),0.0);
  }
 
  @Test public void testSparseAdd() {
    AMatrix m=Matrixx.createSparse(20000,20000);
    m.add(ZeroMatrix.create(20000, 20000));
View Full Code Here

Examples of mikera.matrixx.impl.SparseColumnMatrix.elementSum()

  @Test public void testArithmetic() {
    SparseColumnMatrix M=SparseColumnMatrix.create(3, 3);
    Vector v=Vector.of(-1,2,3);
    M.replaceColumn(1, v);

    assertEquals(4, M.elementSum(), 0.01);
    assertEquals(14, M.elementSquaredSum(), 0.01);
    assertEquals(-1, M.elementMin(), 0.01);
    assertEquals(3, M.elementMax(), 0.01);
    assertEquals(3, M.nonZeroCount());
View Full Code Here

Examples of mikera.vectorz.AVector.elementSum()

   
    startTimer();
   
    for (int i=0; i<SIZE; i++) {
      AVector row=m.getRow(i);
      double sum=row.elementSum();
      if (sum>0) {
        row.divide(sum);
      } else {
        m.setRow(i, RepeatedElementVector.create(SIZE,1.0/SIZE));
      }
View Full Code Here

Examples of mikera.vectorz.AVector.elementSum()


  private void testAsVector(INDArray a) {
    AVector v = a.asVector();
    assertEquals(a.elementCount(), v.length());
    assertEquals(a.elementSum(), v.elementSum(),0.00000001);

    if (a.isMutable() && (v.length() > 0)) {
      assertTrue(v.isMutable());
      // assertTrue((a==v)||(v.isView())); not always...
    } else {
View Full Code Here

Examples of mikera.vectorz.AVector.elementSum()

  private void doVectorTest(AMatrix m) {
    m=m.clone();
    AVector v=m.asVector();
    assertEquals(v,m.toVector());
   
    assertEquals(m.elementSum(),v.elementSum(),0.000001);
   
    AMatrix m2=Matrixx.createFromVector(v, m.rowCount(), m.columnCount());
   
    assertEquals(m,m2);
    assertEquals(v,m2.asVector());
View Full Code Here

Examples of mikera.vectorz.Vector.elementSum()

            // And store the data into the matrix
            userFeatures.setColumn(f, uvec);
            assert Math.abs(userFeatures.getColumnView(f).elementSum() - uvec.elementSum()) < 1.0e-4 : "user column sum matches";
            itemFeatures.setColumn(f, ivec);
            assert Math.abs(itemFeatures.getColumnView(f).elementSum() - ivec.elementSum()) < 1.0e-4 : "item column sum matches";

            timer.stop();
            logger.info("Finished feature {} in {}", f, timer);
        }
View Full Code Here

Examples of mikera.vectorz.impl.SparseHashedVector.elementSum()

  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());
   
  }
 
  @Test
View Full Code Here

Examples of mikera.vectorz.impl.SparseIndexedVector.elementSum()

    SparseIndexedVector v=SparseIndexedVector.createLength(10);
   
    assertEquals(0,v.nonZeroCount());

    v.set(1,1);
    assertEquals(1.0,v.elementSum(),0.0);
    assertEquals(1,v.nonZeroCount());
        assertTrue(Arrays.equals(new int[]{1},v.nonZeroIndices()));

        SparseIndexedVector w=v.clone();
        v.add(ZeroVector.create(10));
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.