Package mikera.matrixx

Examples of mikera.matrixx.AMatrix


    validateQR(a, result);
  }
 
  @Test
  public void testWide() {
    AMatrix a = Matrix.createRandom(3, 5);
    IQRResult result = QR.decompose(a);
    validateQR(a, result);
  }
View Full Code Here


    validateQR(a, result);
  }
 
  @Test
  public void testReallyTall() {
    AMatrix a = Matrix.createRandom(15, 3);
    IQRResult result = QR.decompose(a);
    validateQR(a, result);
  }
View Full Code Here

    validateQR(a, result);
  }
 
  @Test
  public void testReallyWide() {
    AMatrix a = Matrix.createRandom(3, 15);
    IQRResult result = QR.decompose(a);
    validateQR(a, result);
  }
View Full Code Here

    IQRResult result = QR.decompose(a);
    validateQR(a, result);
  }
 
  public void validateQR(AMatrix a, IQRResult result) {
    AMatrix q=result.getQ();
    AMatrix r=result.getR();
   
    assertTrue(q.isOrthogonal(1e-8));
    assertTrue(r.isUpperTriangular());
    assertTrue(r.rowCount() == a.rowCount() && r.columnCount() == a.columnCount());
   
    assertTrue("product not valid",q.innerProduct(r).epsilonEquals(a));
  }
View Full Code Here

    }

    private boolean extractTogether() {
        // extract the orthogonal from the similar transform
//        V = decomp.getQ(V,true);
        AMatrix temp = decomp.getQ(true);
        V = Matrix.wrap(temp.rowCount(), temp.columnCount(), temp.asDoubleArray());

        // tell eigenvector algorithm to update this matrix as it computes the rotators
        helper.setQ(V);

        vector.setFastEigenvalues(false);
View Full Code Here

        diagSaved = helper.swapDiag(diagSaved);
        offSaved = helper.swapOff(offSaved);

        // extract the orthogonal from the similar transform
//        V = decomp.getQ(V,true);
        AMatrix temp = decomp.getQ(true);
        V = Matrix.wrap(temp.rowCount(), temp.columnCount(), temp.asDoubleArray());

        // tell eigenvector algorithm to update this matrix as it computes the rotators
        vector.setQ(V);

        // extract eigenvectors
View Full Code Here

      u.set(i,i,uii);
    }
   
    // TODO: should be null return for a failed decomposition?
   
    AMatrix L = Matrixx.extractLowerTriangular(u);
    return new CholeskyResult(L);
  }
View Full Code Here

  @Override
  public AMatrix innerProduct(AMatrix a) {
    if (a instanceof SparseColumnMatrix) {
      return innerProduct((SparseColumnMatrix) a);
    }
    AMatrix r = Matrix.create(rows, a.columnCount());

        for (int i = 0; i < rows; ++i) {
      AVector row = unsafeGetVec(i);
            if (! ((row == null) || (row.isZero()))) {
          r.setRow(i,row.innerProduct(a));
            }
    }
    return r;
  }
View Full Code Here

    }
    return r;
  }
 
  public AMatrix innerProduct(SparseColumnMatrix a) {
    AMatrix r = Matrixx.createSparse(rows, a.cols);

        for (int i = 0; i < rows; ++i) {
      AVector row = unsafeGetVec(i);
            if (! ((row == null) || (row.isZero()))) {
                for (int j = 0; j < cols; ++j) {
            AVector acol = a.unsafeGetVec(j);
            double v = ((acol == null) || acol.isZero()) ? 0.0 : row.dotProduct(acol);
            if (v!=0.0) r.unsafeSet(i, j, v);
          }
            }
    }
    return r;
  }
View Full Code Here

    public AMatrix invert() {
        if (!A.isSquare()) { throw new IllegalArgumentException(
            "Matrix must be square for inverse!"); }

        double []vv = decomp._getVV();
        AMatrix LU = decomp.getLU();
       
        Matrix A_inv = Matrix.create(LU.rowCount(), LU.columnCount());

        int n = A.columnCount();

        double dataInv[] = A_inv.data;
View Full Code Here

TOP

Related Classes of mikera.matrixx.AMatrix

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.