Examples of AMatrix


Examples of mikera.matrixx.AMatrix

    doAffineTests(new ConstantTransform(7, Vector.of(1,2,3,4,5,6)));
    doAffineTests(new ConstantTransform(0, Vector.of()));
  }
 
  @Test public void genericAffineTests() {
    AMatrix m65=Matrixx.createRandomMatrix(6,5);
    assertTrue(!m65.isSquare());
    doAffineTests(m65);
   

    doAffineTests(Transformz.identityTranslation(3));
    doAffineTests(Transformz.identityTranslation(7));
View Full Code Here

Examples of mikera.matrixx.AMatrix

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

Examples of mikera.matrixx.AMatrix

 
  @Override
  public AMatrix addCopy(AMatrix m) {
    if (!isSameShape(m))throw new IllegalArgumentException(ErrorMessages.incompatibleShapes(this, m));
   
    AMatrix r=m.clone();
    if (r instanceof ADenseArrayMatrix) {
      ADenseArrayMatrix ar=(ADenseArrayMatrix) r;
      this.addToArray(ar.getArray(),ar.getArrayOffset());
    } else {
      for (int i=0; i<dimensions; i++) {
        r.addAt(i, i,1.0);
      }
    }
    return r;
  }
View Full Code Here

Examples of mikera.matrixx.AMatrix

    return equalsByRows(m);
  }
 
  @Override
  public AMatrix clone() {
    AMatrix avm= super.clone();
    return avm;
  }
View Full Code Here

Examples of mikera.matrixx.AMatrix

     */
    public static AVector solveLeastSquares(AMatrix A, AVector b) {
        QRHouseColSolver solver = new QRHouseColSolver();
        solver.setA(A);
//        create AMatrix from AVector
        AMatrix B = b.asColumnMatrix();
        AMatrix X = solver.solve(B);
//        convert AMatrix into AVector and return
        return X.asVector();
    }
View Full Code Here

Examples of mikera.matrixx.AMatrix

     * @return AMatrix X
     */
    public static AMatrix solveLeastSquares(AMatrix A, AMatrix B) {
        QRHouseColSolver solver = new QRHouseColSolver();
        solver.setA(A);
        AMatrix x = solver.solve(B);
        return x;
    }
View Full Code Here

Examples of mikera.matrixx.AMatrix

  private static AVector solveSquare(AMatrix A, AVector b) {
      A.checkSquare();
      LUSolver solver = new LUSolver();
      solver.setA(A);
//      create AMatrix from AVector
      AMatrix B = b.asColumnMatrix();
      AMatrix X = solver.solve(B);
//      if no solution
      if(X == null)
          return null;
      return X.asVector();
  }
View Full Code Here

Examples of mikera.matrixx.AMatrix

    return super.compose(a);
  }
 
  public ATransform compose(AAffineTransform a) {
    AVector v=a.copyOfTranslationVector();
    AMatrix thisM=getMatrix();
    thisM.transformInPlace(v);
    v.add(getTranslation().getTranslationVector());
   
    AMatrix m=thisM.compose(a.getMatrix());
   
    return Transformz.createAffineTransform(m, v);
  }
View Full Code Here

Examples of mikera.matrixx.AMatrix

         a.getTranslation().equals(getTranslation())
  }

  @Override
  public AAffineTransform inverse() {
    AMatrix m=getMatrix().inverse();
    AVector v=getTranslation().getTranslationVector().clone();
    v.negate();
    m.transformInPlace(v);
    return Transformz.createAffineTransform(m, v);
  }
View Full Code Here

Examples of mikera.matrixx.AMatrix

   
    // We construct a dense matrix for later multiplication
   
    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();
   
    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
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.