Package mikera.matrixx

Examples of mikera.matrixx.Matrix


   
    if ((ic!=b.rowCount())) {
      throw new IllegalArgumentException(ErrorMessages.incompatibleShapes(a,b));
    }   

    Matrix result=Matrix.create(rc, cc);
    if (ic==0) return result;
   
    int block=(WORKING_SET_TARGET/ic)+1;
    // working set stores up to <block> number of columns from second matrix
    Matrix wsb=Matrix.create(Math.min(block,cc), ic);
   
    for (int bj=0; bj<cc; bj+=block) {
      int bjsize=Math.min(block, cc-bj);
     
      // copy columns into working set
View Full Code Here


   
    if ((ic!=b.rowCount())) {
      throw new IllegalArgumentException(ErrorMessages.incompatibleShapes(a,b));
    }   

    Matrix result=Matrix.create(rc, cc);
    if (ic==0) return result;
   
    int block=(WORKING_SET_TARGET/ic)+1;
    // working sets stores up to <block> number of columns from each matrix
    Matrix wsa=Matrix.create(Math.min(block,rc), ic);
    Matrix wsb=Matrix.create(Math.min(block,cc), ic);
   
    for (int bj=0; bj<cc; bj+=block) {
      int bjsize=Math.min(block, cc-bj);
     
      // copy columns into working set
View Full Code Here

   
    if ((ic!=b.rowCount())) {
      throw new IllegalArgumentException(ErrorMessages.incompatibleShapes(a,b));
    }

    Matrix result=Matrix.create(rc,cc);
    double[] tmp=new double[ic];
    for (int j=0; j<cc; j++) {
      b.copyColumnTo(j, tmp, 0);
     
      for (int i=0; i<rc; i++) {
//        double acc=0.0;
//        for (int k=0; k<ic; k++) {
//          acc+=a.unsafeGet(i, k)*tmp[k];
//        }
        double acc=DoubleArrays.dotProduct(a.data, i*ic, tmp, 0, ic);
        result.unsafeSet(i,j,acc);
      }
    }
    return result;   
  }
View Full Code Here

   
    if ((ic!=b.rowCount())) {
      throw new IllegalArgumentException(ErrorMessages.incompatibleShapes(a,b));
    }

    Matrix result=Matrix.create(rc,cc);
    for (int i=0; i<rc; i++) {
      for (int j=0; j<cc; j++) {
        double acc=0.0;
        for (int k=0; k<ic; k++) {
          acc+=a.unsafeGet(i, k)*b.unsafeGet(k, j);
        }
        result.unsafeSet(i,j,acc);
      }
    }
    return result;   
  }
View Full Code Here

    assertEquals(new Double(2.0),SliceArray.create(Vector.of(1,2,3)).getSlices().get(1));
  }
 
  @Test
  public void testJoinedSlice() {
    Matrix m=Matrix.create(new double[][] {{1,2},{3,4}});
    INDArray j=m.join(m, 1);
    assertEquals(Vector.of(1,3),j.slice(1,0));
    assertEquals(Vector.of(2,4),j.slice(1,3));
  }
View Full Code Here

     assertEquals(3, PermutationMatrix.create(1,2,0).elementPowSum(2), 0.0001);
    
     assertEquals(10, DiagonalMatrix.create(1,0,2,7).elementAbsPowSum(1), 0.0001);
     assertEquals(14, DiagonalMatrix.create(1,2,0,3).elementPowSum(2), 0.0001);
    
     Matrix i = Matrix.createIdentity(3);
     Matrix j = Matrix.create(2,2);
     assertEquals(3, BlockDiagonalMatrix.create(i,j).elementAbsPowSum(1), 0.0001);
     assertEquals(3, BlockDiagonalMatrix.create(i,j).elementPowSum(4), 0.0001);
    
     assertEquals(6, ColumnMatrix.wrap(Vector.of(1,2,3)).elementAbsPowSum(1), 0.0001);
     assertEquals(126, ColumnMatrix.wrap(Vector.of(1,5,10)).elementPowSum(2), 0.0001);
View Full Code Here

 
  @Test public void testWrap() {
    Vector v=Vector.of(0,1,2,3);
    assertEquals(v,NDArray.wrap(v));
   
    Matrix m=Matrix.create(Matrixx.createRandomSquareMatrix(3));
    assertEquals(m,NDArray.wrap(m));

  }
View Full Code Here

   
    assertTrue(Arrays.equals(new int[] {1,2,3,1,2,3},a.outerProduct(a).getShape()));
  }
 
  @Test public void testInnerProduct() {
    Matrix m=Matrixx.createYAxisRotationMatrix(2.0).toMatrix();
   
    NDArray a=NDArray.wrap(m);
   
    assertEquals(a.innerProduct(a),m.innerProduct(m));
  }
View Full Code Here

    /**
     * Checks to see if the modifyA() flag is set correctly
     */
    @Test
    public void modifiesA() {
        Matrix A_orig = Matrix.createRandom(4,4);
        Matrix A = A_orig.copy();

        LUSolver solver = new LUSolver();

        assertNotNull(solver.setA(A));

View Full Code Here

    /**
     * Checks to see if the modifyB() flag is set correctly
     */
    @Test
    public void modifiesB() {
        Matrix A = Matrix.createRandom(4,4);

        LUSolver solver = new LUSolver();
       
        assertNotNull(solver.setA(A));

        Matrix B = Matrix.createRandom(4,2);
        Matrix B_orig = B.copy();

        solver.solve(B);

        assertTrue(B_orig.epsilonEquals(B));
    }
View Full Code Here

TOP

Related Classes of mikera.matrixx.Matrix

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.