Package cern.colt.matrix

Examples of cern.colt.matrix.DoubleMatrix2D.assign()


  System.out.println("\n\n");
  System.out.println("now initializing... ");
   
  final cern.jet.math.Functions F = cern.jet.math.Functions.functions;
  DoubleMatrix2D A = cern.colt.matrix.DoubleFactory2D.dense.make(rows,columns);
  A.assign(new cern.jet.random.engine.DRand()); // initialize randomly
  DoubleMatrix2D B = A.copy();

  double[] v1 = A.viewColumn(0).toArray();
  double[] v2 = A.viewColumn(0).toArray();
  System.out.print("now quick sorting... ");
View Full Code Here


  System.out.print("now initializing... ");
  cern.colt.Timer timer = new cern.colt.Timer().start();

  final cern.jet.math.Functions F = cern.jet.math.Functions.functions;
  DoubleMatrix2D A = cern.colt.matrix.DoubleFactory2D.dense.make(rows,columns);
  A.assign(new cern.jet.random.engine.DRand()); // initialize randomly
  timer.stop().display();

  // also benchmark copying in its several implementation flavours
  DoubleMatrix2D B = A.like();
  timer.reset().start();
View Full Code Here

  // also benchmark copying in its several implementation flavours
  DoubleMatrix2D B = A.like();
  timer.reset().start();
  System.out.print("now copying... ");
  B.assign(A);
  timer.stop().display();

  timer.reset().start();
  System.out.print("now copying subrange... ");
  B.viewPart(0,0,rows,columns).assign(A.viewPart(0,0,rows,columns));
View Full Code Here

  System.out.println("\n\n");
  System.out.println("now initializing... ");

  final cern.jet.math.Functions F = cern.jet.math.Functions.functions;
  DoubleMatrix2D A = cern.colt.matrix.DoubleFactory2D.dense.make(rows,columns);
  A.assign(new cern.jet.random.engine.DRand()); // initialize randomly
  DoubleMatrix2D B = A.copy();

  double[] v1 = A.viewColumn(0).toArray();
  double[] v2 = A.viewColumn(0).toArray();
  System.out.print("now quick sorting... ");
View Full Code Here

  }
  */
  System.out.println("\ntesting...");
  if (print) System.out.println(matrix);
  DoubleMatrix2D dense = DoubleFactory2D.dense.make(size,size);
  dense.assign(matrix);
  if (! dense.equals(matrix)) throw new InternalError();
  DoubleMatrix2D ADense = dense.copy();
  DoubleMatrix2D BDense = dense.copy();
  DoubleMatrix2D CDense = dense.copy();
  ADense.zMult(BDense,CDense);
View Full Code Here

    DoubleMatrix2D B = matrix.copy();
    //DoubleMatrix2D C = Basic.product(A,B);
    DoubleMatrix2D C = matrix.copy();
    A.zMult(B,C);
    if (! (C.equals(CDense))) throw new InternalError();
    C.assign(matrix);
    System.out.println("\nNow benchmarking...");
   
    timer3.start();
    for (int i=0; i<runs; i++) {
      A.zMult(B,C);
View Full Code Here

  else throw new RuntimeException("unknown kind");
 
  System.out.println("\nNow filling...");
  //if (kind.equals("sparse")) ((SparseDoubleMatrix2D)matrix).elements.hashCollisions = 0;
  for (int i=0; i<runs; i++) {
    matrix.assign(0);
    matrix.ensureCapacity(initialCapacity);
    if (kind.equals("sparse")) ((SparseDoubleMatrix2D)matrix).ensureCapacity(initialCapacity);
    timer1.start();
    int value = 0;
    for (int row=0; row < rows; row++) {
View Full Code Here

  else if (kind.equals("dense")) matrix = new DenseDoubleMatrix2D(rows,columns);
  //else if (kind.equals("denseArray")) matrix = new DoubleArrayMatrix2D(rows,columns);
  else throw new RuntimeException("unknown kind");
 
  System.out.println("\nNow multiplying...");
  matrix.assign(1);
  //if (kind.equals("sparse")) ((SparseDoubleMatrix2D)matrix).elements.hashCollisions = 0;
  for (int i=0; i<runs; i++) {
    timer1.start();
    cern.colt.matrix.doublealgo.Transform.mult(matrix, 3);
    timer1.stop();
View Full Code Here

    System.out.println("--> "+ ((double)hashCollisions / (rows*columns)) +" hashCollisions/element on average.");
  }
  */
 
  System.out.println("\nNow multiplying2...");
  matrix.assign(1);
  //if (kind.equals("sparse")) ((SparseDoubleMatrix2D)matrix).elements.hashCollisions = 0;
  for (int i=0; i<runs; i++) {
    timer2.start();
    cern.colt.matrix.doublealgo.Transform.mult(matrix,3);
    timer2.stop();
View Full Code Here

public static void doubleTest4() {
int rows = 4;
int columns = 5; // make a 4*5 matrix
DoubleMatrix2D master = new DenseDoubleMatrix2D(rows,columns);
System.out.println(master);
master.assign(1); // set all cells to 1
DoubleMatrix2D view = master.viewPart(2,0,2,3).assign(2);
System.out.println("\n"+master);
System.out.println("\n"+view);
Transform.mult(view,3);
System.out.println("\n"+master);
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.