Package cern.colt.matrix

Examples of cern.colt.matrix.DoubleFactory2D


*/
public static void doubleTest24(int runs, int size, boolean dense) {
System.out.println("\n\n");
System.out.println("initializing...");
DoubleMatrix2D A;
DoubleFactory2D factory;
if (dense)
  factory = Factory2D.dense;
else
  factory = Factory2D.sparse;
 
double value = 2;
double omega = 1.25;
final double alpha = omega * 0.25;
final double beta = 1-omega;
A = factory.make(size,size,value);

cern.colt.function.Double9Function function = new cern.colt.function.Double9Function() {
  public final double apply(double a00, double a01, double a02, double a10, double a11, double a12, double a20, double a21, double a22) {
    return alpha*a11 + beta*(a01+a10+a12+a21);
  }
};
cern.colt.Timer timer = new cern.colt.Timer().start();

System.out.println("benchmarking stencil...");
for (int i=0; i<runs; i++) {
  A.zAssign8Neighbors(A,function);
}
//A.zSum4Neighbors(A,alpha,beta,runs);
timer.stop().display();
//System.out.println("A="+A);
A=null;

double[][] B =  factory.make(size,size,value).toArray();
timer.reset().start();

System.out.println("benchmarking stencil scimark...");
for (int i=0; i<runs; i++) {
//  jnt.scimark2.SOR.execute(omega, B, runs);
View Full Code Here


 
System.out.println("\n\n");
System.out.println("initializing...");
boolean dense = true;
DoubleMatrix2D A;
DoubleFactory2D factory;
if (dense)
  factory = Factory2D.dense;
else
  factory = Factory2D.sparse;
 
double value = 0.5;
A = factory.make(size,size,value);
Property.generateNonSingular(A);
cern.colt.Timer timer = new cern.colt.Timer().start();

System.out.println(A);
System.out.println(Algebra.ZERO.inverse(A));
View Full Code Here

 
System.out.println("\n\n");
System.out.println("initializing...");
boolean dense = true;
DoubleMatrix2D A;
DoubleFactory2D factory;
if (dense)
  factory = Factory2D.dense;
else
  factory = Factory2D.sparse;
 
double value = 0.5;
A = factory.make(size,size,value);
Property.generateNonSingular(A);
cern.colt.Timer timer = new cern.colt.Timer().start();

DoubleMatrix2DComparator fun = new DoubleMatrix2DComparator() {
  public int compare(DoubleMatrix2D a, DoubleMatrix2D b) {
View Full Code Here

  double[][] arrMatrix =
  {
    { 1, 2, 3, 4, 5, 6},
    { 2, 3, 4, 5, 6, 7}
  };
  DoubleFactory2D f = DoubleFactory2D.dense;
  DoubleMatrix1D vector = new DenseDoubleMatrix1D(data);
  DoubleMatrix2D matrix = f.make(arrMatrix);
  DoubleMatrix1D res = vector.like(matrix.rows());
 
  matrix.zMult(vector,res);

  System.out.println(res);
View Full Code Here

  { 1, 2, 3 },
  { 2, 4, 6 },
  { 3, 6, 9 },
  { 4, -8, -10 }
};
DoubleFactory2D factory = DoubleFactory2D.dense;
DoubleMatrix2D A = factory.make(values);
System.out.println("\n\nmatrix="+A);
System.out.println("\ncovar1="+covariance(A));
//System.out.println(correlation(covariance(A)));
//System.out.println(distance(A,EUCLID));
View Full Code Here

/**
* Demonstrates usage of this class.
*/
public static void demo2(int rows, int columns, boolean print) {
System.out.println("\n\ninitializing...");
DoubleFactory2D factory = DoubleFactory2D.dense;
DoubleMatrix2D A = factory.ascending(rows,columns);
//double value = 1;
//DoubleMatrix2D A = factory.make(rows,columns);
//A.assign(value);

System.out.println("benchmarking correlation...");
View Full Code Here

  { 1.53451660.02135884},
  {-1.13415420.20388430}
};

System.out.println("\n\ninitializing...");
DoubleFactory2D factory = DoubleFactory2D.dense;
DoubleMatrix2D A = factory.make(values).viewDice();

System.out.println("\nA="+A.viewDice());
System.out.println("\ndist="+distance(A,norm).viewDice());
}
View Full Code Here

}
/**
* Not yet documented.
*/
protected static DoubleFactory2D getFactory(String type) {
  DoubleFactory2D factory;
  if (type.equals("dense")) return DoubleFactory2D.dense;
  if (type.equals("sparse")) return DoubleFactory2D.sparse;
  if (type.equals("rowCompressed")) return DoubleFactory2D.rowCompressed;
  String s = "type="+type+" is unknown. Use one of {dense,sparse,rowCompressed}";
  throw new IllegalArgumentException(s);
View Full Code Here

  DoubleMatrix3D timings = DoubleFactory3D.dense.make(types.length,sizes.length,densities.length);
  cern.colt.Timer runTime = new cern.colt.Timer().start();
  for (int k=0; k<types.length; k++) {
    //DoubleFactory2D factory = (k==0 ? DoubleFactory2D.dense : k==1 ? DoubleFactory2D.sparse : DoubleFactory2D.rowCompressed);
    //DoubleFactory2D factory = (k==0 ? DoubleFactory2D.dense : k==1 ? DoubleFactory2D.sparse : k==2 ? DoubleFactory2D.rowCompressed : DoubleFactory2D.rowCompressedModified);
    DoubleFactory2D factory = getFactory(types[k]);
    System.out.print("\n@");

    for (int i=0; i<sizes.length; i++) {
      int size = sizes[i];
      System.out.print("x");
      //System.out.println("doing size="+size+"...");

      for (int j=0; j<densities.length; j++) {
        final double density = densities[j];
        System.out.print(".");
        //System.out.println("   doing density="+density+"...");
        float opsPerSec;

        //if (true) {
        //if (!((k==1 && density >= 0.1 && size >=100) || (size>5000 && (k==0 || density>1.0E-4) ))) {
        if (!((k>0 && density >= 0.1 && size >=500) )) {
          double val = 0.5;
          function.A=null; function.B=null; function.C=null; function.D=null; // --> help gc before allocating new mem
          DoubleMatrix2D A = factory.sample(size,size,val,density);
          DoubleMatrix2D B = factory.sample(size,size,val,density);
          function.setParameters(A,B);
          A = null; B = null; // help gc
          double ops = function.operations();
          double secs = BenchmarkKernel.run(minSeconds,function);
          opsPerSec = (float) (ops / secs);
View Full Code Here

  cern.colt.Timer runTime = new cern.colt.Timer().start();
  for (int i=0; i<sizes.length; i++) {
    int size = sizes[i];
    double density = densities[i];
    boolean sparse = sparses[i];
    final DoubleFactory2D factory = (sparse ? DoubleFactory2D.sparse : DoubleFactory2D.dense);
    System.out.print("\n@");

    System.out.print("x");
    double val = 0.5;
    function.A=null; function.B=null; function.C=null; function.D=null; // --> help gc before allocating new mem
    DoubleMatrix2D A = factory.sample(size,size,val,density);
    DoubleMatrix2D B = factory.sample(size,size,val,density);
    function.setParameters(A,B);
    A = null; B = null; // help gc
    float secs = BenchmarkKernel.run(minSeconds,function);
    double ops = function.operations();
    float opsPerSec = (float) (ops / secs);
View Full Code Here

TOP

Related Classes of cern.colt.matrix.DoubleFactory2D

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.