Package mikera.matrixx

Examples of mikera.matrixx.Matrix


  }
 
  @Override
  public Matrix innerProduct(Matrix a) {
    if (!(dimensions==a.rowCount())) throw new IllegalArgumentException(ErrorMessages.incompatibleShapes(this,a));
    Matrix m=a.clone();
    for (int i=0; i<dimensions; i++) {
      double dv=unsafeGetDiagonalValue(i);
      m.multiplyRow(i, dv);
    }
    return m;
  }
View Full Code Here


    return 1.0/dimensions;
  }
 
  @Override
  public Matrix toMatrix() {
    Matrix m=Matrix.create(dimensions, dimensions);
    for (int i=0; i<dimensions; i++) {
      m.data[i*(dimensions+1)]=unsafeGetDiagonalValue(i);
    }
    return m;
  }
View Full Code Here

     * Returns the bidiagonal matrix.
     *
     * @return The bidiagonal matrix.
     */
    private AMatrix getB() {
        Matrix B = handleB(m,n,min);

        //System.arraycopy(UBV.data, 0, B.data, 0, UBV.getNumElements());

        B.set(0,0,UBV.get(0,0));
        for( int i = 1; i < min; i++ ) {
            B.set(i,i, UBV.get(i,i));
            B.set(i-1,i, UBV.get(i-1,i));
        }
        if( n > m )
            B.set(min-1,min,UBV.get(min-1,min));

        return B;
    }
View Full Code Here

     * Returns the orthogonal U matrix.
     *
     * @return The extracted Q matrix.
     */
    private AMatrix getU() {
        Matrix U = handleU(m,n,min);

        for( int i = 0; i < m; i++ ) u[i] = 0;

        for( int j = min-1; j >= 0; j-- ) {
            u[j] = 1;
View Full Code Here

     * Returns the orthogonal V matrix.
     *
     * @return The extracted Q matrix.
     */
    private AMatrix getV() {
        Matrix V = handleV(m,n,min);

//        UBV.print();

        // todo the very first multiplication can be avoided by setting to the rank1update output
        for( int j = min-1; j >= 0; j-- ) {
View Full Code Here

 
  @Override
  public Matrix toMatrix() {
    int rc = rowCount();
    int cc = columnCount();
    Matrix m = Matrix.create(rc, cc);
    for (int i=-lowerBandwidthLimit(); i<=upperBandwidthLimit(); i++) {
      m.getBand(i).set(this.getBand(i));
    }
    return m;
  }
View Full Code Here

 
  @Override
  public Matrix toMatrixTranspose() {
    int rc = rowCount();
    int cc = columnCount();
    Matrix m = Matrix.create(cc, rc);
    for (int i=-lowerBandwidthLimit(); i<=upperBandwidthLimit(); i++) {
      m.getBand(-i).set(this.getBand(i));
    }
    return m;
  }
View Full Code Here

    }
  }
 
  @Override
  public Matrix toMatrixTranspose() {
    Matrix m=Matrix.create(cols, rows);
        for (int i = 0; i < cols; ++i) {
      getColumn(i).copyTo(m.data, rows*i);
    }
    return m;
  }
View Full Code Here

    return m;
  }

  @Override
  public double[] toDoubleArray() {
    Matrix m=Matrix.create(rows, cols);
    for (int i=0; i<cols; i++) {
      AVector v = unsafeGetVec(i);
      if (v != null)
                m.getColumn(i).set(v);
    }
    return m.getArray();
  }
View Full Code Here

   
        // ----------------------------------------------------------------------
    // Convert this sparse matrix into a dense matrix.
    startTimer();
    Matrix D = Matrix.create(M);
    printTime("Convert small sparse matrix to dense: ");

   
        // ----------------------------------------------------------------------
    // Check equality from M.
    startTimer();
    boolean eq = M.equals(D);
    printTime("Equality check result (" + eq + "): ");
   
   
        // ----------------------------------------------------------------------
    // Check equality from D.
    startTimer();
    eq = D.epsilonEquals(M, 0.000001);
    printTime("epsilonEquals check result (" + eq + ", should be true): ");
   
   
        // ----------------------------------------------------------------------
    // Change sparse matrix and test equality again (shouldn't be equal)
    startTimer();
        M.addAt(SSIZE-1, SSIZE-1, 3.14159);
    eq = M.equals(D);
    printTime("Equality check result (" + eq + ", should be false): ");
   
   
        // ----------------------------------------------------------------------
    // Change dense matrix also; should be equal again.
    startTimer();
        D.addAt(SSIZE-1, SSIZE-1, 3.14159);
    eq = M.equals(D);
    printTime("Equality check result (" + eq + ", should be true): ");
   
  }
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.