Package mikera.matrixx.impl

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


    assertEquals(3, M.elementMax(), 0.01);
    assertEquals(3, M.nonZeroCount());

    SparseColumnMatrix N = SparseColumnMatrix.create(3,3);
    v=Vector.of(4,5,6);
    N.replaceColumn(1, v);
        M.add(N);           // test add
        M.swapRows(0,1);      // test swapRows
    assertEquals(7, M.get(0,1), 0.01);

    SparseRowMatrix M1 = SparseRowMatrix.create(3, 3);
View Full Code Here


    Vector v=Vector.of(1,2,3);
    M.replaceRow(1, v);

    SparseColumnMatrix N = SparseColumnMatrix.create(3,3);
    v=Vector.of(4,5,6);
    N.replaceColumn(1, v);

    assertEquals(32, M.innerProduct(N).get(1,1), 0.01);
    assertEquals(32, M.innerProduct(N).elementSum(), 0.01);
  }
View Full Code Here

  @Test public void testReplace() {
    SparseColumnMatrix m=SparseColumnMatrix.create(3, 3);
   
    Vector v=Vector.of(1,2,3);
   
    m.replaceColumn(1, v);
    assertTrue(v==m.getColumn(1)); // identical objects
    assertEquals(Vector.of(0,2,0),m.getRow(1));
  }

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

  }

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

        M.swapColumns(0,1);      // test swapColumns
    assertEquals(7, M.get(1,0), 0.01);

    SparseColumnMatrix M1 = SparseColumnMatrix.create(3, 3);
    Vector v1=Vector.of(-1,2,3);
    M1.replaceColumn(1, v1);

        int[] index = {0,2};
        double[] data = {7,8};
    SparseColumnMatrix M2 = SparseColumnMatrix.create(Vector.of(0,1,2),SparseIndexedVector.wrap(3, index, data),null);
        M2.validate();
View Full Code Here

  }

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

    SparseRowMatrix N = SparseRowMatrix.create(3,3);
    v=Vector.of(4,5,6);
    N.replaceRow(1, v);
View Full Code Here

      double[] data=new double[DSIZE];
      for (int j=0; j<DSIZE; j++) {
        data[j]=Rand.nextDouble();
      }
      Index indy=Indexz.createRandomChoice(DSIZE, SSIZE);
      M.replaceColumn(i,SparseIndexedVector.create(SSIZE, indy, data));
    }
    Matrix D = Matrix.create(M);
    assertTrue(M.equals(D));
    assertTrue(D.epsilonEquals(M, 0.1));
        M.set(SSIZE-1, SSIZE-1, M.get(SSIZE-1, SSIZE-1) + 3.14159);
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.