Package cern.colt.matrix

Examples of cern.colt.matrix.DoubleMatrix2D


/**
*/
public static void doubleTest9() {
int rows = 2;
int columns = 3; // make a 4*5 matrix
DoubleMatrix2D master = Factory2D.ascending(rows,columns);
//master.assign(1); // set all cells to 1
System.out.println("\n"+master);
//master.viewPart(2,0,2,3).assign(2); // set [2,1] .. [3,3] to 2
//System.out.println("\n"+master);

DoubleMatrix2D view1 = master.viewRowFlip();
System.out.println("view1="+view1);
DoubleMatrix2D view2 = view1.viewRowFlip();
System.out.println("view2="+view2);

view2.assign(-1);
System.out.println("master replaced"+master);
System.out.println("flip1 replaced"+view1);
System.out.println("flip2 replaced"+view2);

}
View Full Code Here


  {-0.166829, -0.10321 , 0.582301, 0.142583,0},
  { 0       , -0.112952,-0.04932 ,-0.700157,0},
  { 0       , 0        ,0        ,0        ,0}
};
DoubleMatrix2D H = new DenseDoubleMatrix2D( vals ); // see values below...
System.out.println("\nHplus="+H.viewDice().zMult(H,null));

DoubleMatrix2D Hplus = Algebra.DEFAULT.inverse(H.viewDice().zMult( H,null )).zMult(H.viewDice(),null);
Hplus.assign(cern.jet.math.Functions.round(1.0E-10));
System.out.println("\nHplus="+Hplus);

    /*
DoubleMatrix2D HtH = new DenseDoubleMatrix2D( 5, 5 );
DoubleMatrix2D Hplus = new DenseDoubleMatrix2D( 5, 6 );
View Full Code Here

@return a new flip view.
@see #viewRowFlip()
*/
public DoubleMatrix2D viewColumnFlip() {
  if (columns==0) return this;
  DoubleMatrix2D view = new WrapperDoubleMatrix2D(this) {
    public double getQuick(int row, int column) {
      return content.get(row,columns-1-column);
    }
    public void setQuick(int row, int column, double value) {
      content.set(row,columns-1-column,value);
View Full Code Here

</table>

@return a new dice view.
*/
public DoubleMatrix2D viewDice() {
  DoubleMatrix2D view = new WrapperDoubleMatrix2D(this) {
    public double getQuick(int row, int column) {
      return content.get(column,row);
    }
    public void setQuick(int row, int column, double value) {
      content.set(column,row,value);
View Full Code Here

  buf.append("\n\nU = ");
  try { buf.append(String.valueOf(this.getU()));}
  catch (IllegalArgumentException exc) { buf.append(unknown+exc.getMessage()); }
 
  buf.append("\n\ninverse(A) = ");
  DoubleMatrix2D identity = cern.colt.matrix.DoubleFactory2D.dense.identity(LU.rows());
  try { this.solve(identity); buf.append(String.valueOf(identity)); }
  catch (IllegalArgumentException exc) { buf.append(unknown+exc.getMessage()); }
 
  return buf.toString();
}
View Full Code Here

@exception  IllegalArgumentException  if <tt>B.rows() != A.rows()</tt>.
@exception  IllegalArgumentException  if <tt>!isSymmetricPositiveDefinite()</tt>.
*/
public DoubleMatrix2D solve(DoubleMatrix2D B) {
  // Copy right hand side.
  DoubleMatrix2D X = B.copy();
  int nx = B.columns();

  // fix by MG Ferreira <mgf@webmail.co.za>
  // old code is in method xxxSolveBuggy()
  for (int c = 0; c < nx; c++ ) {
    // Solve L*Y = B;
    for (int i = 0; i < n; i++)  {
      double sum = B.getQuick( i, c );
      for (int k = i-1; k >= 0; k--) {
        sum -= L.getQuick(i,k) * X.getQuick( k, c );
      }
      X.setQuick( i, c, sum / L.getQuick( i, i ) );
    }

    // Solve L'*X = Y;
    for (int i = n-1; i >= 0; i--) {
      double sum = X.getQuick( i, c );
      for (int k = i+1; k < n; k++) {
        sum -= L.getQuick(k,i) * X.getQuick( k, c );
      }
      X.setQuick( i, c, sum / L.getQuick( i, i ) );
    }
  }

  return X;
}
View Full Code Here

  if (!isSymmetricPositiveDefinite) {
    throw new IllegalArgumentException("Matrix is not symmetric positive definite.");
  }
 
  // Copy right hand side.
  DoubleMatrix2D X = B.copy();
  int nx = B.columns();
 
  // precompute and cache some views to avoid regenerating them time and again
  DoubleMatrix1D[] Xrows = new DoubleMatrix1D[n];
  for (int k = 0; k < n; k++) Xrows[k] = X.viewRow(k);
 
  // Solve L*Y = B;
  for (int k = 0; k < n; k++) {
    for (int i = k+1; i < n; i++) {
      // X[i,j] -= X[k,j]*L[i,k]
 
View Full Code Here

  final DoubleMatrix2D[] blocks = new DoubleMatrix2D[noOfTasks];
  for (int i=0; i<noOfTasks; i++) {
    final int offset = i*span;
    if (i==noOfTasks-1) span = p - span*i; // last span may be a bit larger

    final DoubleMatrix2D AA,BB,CC;
    if (!splitHoriz) {   // split B along columns into blocks
      blocks[i] = A.viewPart(0,offset, A.rows(), span);
    }
    else { // split A along rows into blocks
      blocks[i] = A.viewPart(offset,0,span,A.columns());
View Full Code Here

  final DoubleMatrix2D[] blocks = new DoubleMatrix2D[noOfTasks];
  for (int i=0; i<noOfTasks; i++) {
    final int offset = i*span;
    if (i==noOfTasks-1) span = p - span*i; // last span may be a bit larger

    final DoubleMatrix2D AA,BB,CC;
    if (!splitHoriz) {
      // split B along columns into blocks
      blocks[i] = A.viewPart(0,i,A.rows(),A.columns()-i).viewStrides(1,noOfTasks);
    }
    else {
View Full Code Here

@exception  IllegalArgumentException  if A is singular, that is, if <tt>!this.isNonsingular()</tt>.
@exception  IllegalArgumentException  if <tt>A.rows() < A.columns()</tt>.
*/

public DoubleMatrix2D solve(DoubleMatrix2D B) {
  DoubleMatrix2D X = B.copy();
  quick.solve(X);
  return X;
}
View Full Code Here

TOP

Related Classes of cern.colt.matrix.DoubleMatrix2D

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.