Examples of DoubleMatrix1D


Examples of cern.colt.matrix.DoubleMatrix1D

  if (isNoView && other.isNoView) { // quickest
    System.arraycopy(other.elements, 0, this.elements, 0, this.elements.length);
    return this;
  }
  if (haveSharedCells(other)) {
    DoubleMatrix1D c = other.copy();
    if (! (c instanceof DenseDoubleMatrix1D)) { // should not happen
      return super.assign(source);
    }
    other = (DenseDoubleMatrix1D) c;
  }
View Full Code Here

Examples of cern.colt.matrix.DoubleMatrix1D

The returned view is backed by this matrix, so changes in the returned view are reflected in this matrix, and vice-versa.

@return a new flip view.
*/
public DoubleMatrix1D viewFlip() {
  DoubleMatrix1D view = new WrapperDoubleMatrix1D(this) {
    public double getQuick(int index) {
      return content.get(size-1-index);
    }
    public void setQuick(int index, double value) {
      content.set(size-1-index,value);
View Full Code Here

Examples of cern.colt.matrix.DoubleMatrix1D

@return the new view.
   
*/
public DoubleMatrix1D viewPart(final int index, int width) {
  checkRange(index,width);
  DoubleMatrix1D view = new WrapperDoubleMatrix1D(this) {
    public double getQuick(int i) {
      return content.get(index+i);
    }
    public void setQuick(int i, double value) {
      content.set(index+i,value);
View Full Code Here

Examples of cern.colt.matrix.DoubleMatrix1D

  }
 
  checkIndexes(indexes);
  final int[] idx = indexes;

  DoubleMatrix1D view = new WrapperDoubleMatrix1D(this) {
    public double getQuick(int i) {
      return content.get(idx[i]);
    }
    public void setQuick(int i, double value) {
      content.set(idx[i],value);
View Full Code Here

Examples of cern.colt.matrix.DoubleMatrix1D

@return the new view.
   
*/
public DoubleMatrix1D viewStrides(final int _stride) {
  if (stride<=0) throw new IndexOutOfBoundsException("illegal stride: "+stride);
  DoubleMatrix1D view = new WrapperDoubleMatrix1D(this) {
    public double getQuick(int index) {
      return content.get(index*_stride);
    }
    public void setQuick(int index, double value) {
      content.set(index*_stride,value);
View Full Code Here

Examples of cern.colt.matrix.DoubleMatrix1D

}
/**
*/
public static void doubleTest13() {
double[] values = {0, 1, 2, 3};
DoubleMatrix1D matrix = new DenseDoubleMatrix1D(values);
System.out.println(matrix);

// Sum( x[i]*x[i] )
System.out.println(matrix.viewSelection(
  new cern.colt.function.DoubleProcedure() {
    public final boolean apply(double a) { return a % 2 == 0; }
  }
));
//--> 14

// Sum( x[i]*x[i] )
System.out.println(matrix.aggregate(F.plus,F.square));
//--> 14

// Sum( x[i]*x[i]*x[i] )
System.out.println(matrix.aggregate(F.plus,F.pow(3)));
//--> 36

// Sum( x[i] )
System.out.println(matrix.aggregate(F.plus,F.identity));
//--> 6

// Min( x[i] )
System.out.println(matrix.aggregate(F.min,F.identity));
//--> 0

// Max( Sqrt(x[i]) / 2 )
System.out.println(matrix.aggregate(F.max,F.chain(F.div(2),F.sqrt)));
//--> 0.8660254037844386

// Number of all cells with 0 <= value <= 2
System.out.println(matrix.aggregate(F.plus,F.between(0,2)));
//--> 3

// Number of all cells with 0.8 <= Log2(value) <= 1.2
System.out.println(matrix.aggregate(F.plus,F.chain(F.between(0.8,1.2),F.log2)));
//--> 1

// Product( x[i] )
System.out.println(matrix.aggregate(F.mult,F.identity));
//--> 0

// Product( x[i] ) of all x[i] > limit
final double limit = 1;
DoubleFunction f = new DoubleFunction() {
  public final double apply(double a) { return a>limit ? a : 1; }
};
System.out.println(matrix.aggregate(F.mult,f));
//--> 6

// Sum( (x[i]+y[i])^2 )
DoubleMatrix1D otherMatrix1D = matrix.copy();
System.out.println(matrix.aggregate(otherMatrix1D, F.plus, F.chain(F.square,F.plus)));
// --> 56


matrix.assign(F.plus(1));
View Full Code Here

Examples of cern.colt.matrix.DoubleMatrix1D

*/
public static void doubleTest23(int runs, int size, double nonZeroFraction, boolean dense) {
System.out.println("\n\n");
System.out.println("initializing...");
DoubleMatrix2D A, LU, I, Inv;
DoubleMatrix1D b, solved;

double mean = 5.0;
double stdDev = 3.0;
cern.jet.random.Normal random = new cern.jet.random.Normal(mean, stdDev, new cern.jet.random.engine.MersenneTwister());

System.out.println("sampling...");
double value = 2;
if (dense)
  A = Factory2D.dense.sample(size,size, value, nonZeroFraction);
else
  A = Factory2D.sparse.sample(size,size, value, nonZeroFraction);
b = A.like1D(size).assign(1);

//A.assign(random);
//A.assign(F.rint); // round
System.out.println("generating invertible matrix...");
Property.generateNonSingular(A);

//I = Factory2D.identity(size);

LU = A.like();
solved = b.like();
//Inv = Factory2D.make(size,size);

LUDecompositionQuick lu = new LUDecompositionQuick();

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

Examples of cern.colt.matrix.DoubleMatrix1D

  {
    { 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

Examples of cern.colt.matrix.DoubleMatrix1D

  {
    { 1, 2, 3, 4, 5, 6},
    { 2, 3, 4, 5, 6, 7}
  };
 
  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

Examples of cern.colt.matrix.DoubleMatrix1D

/**
*/
public static void doubleTest31(int size) {

System.out.println("\ninit");
DoubleMatrix1D a = Factory1D.dense.descending(size);
DoubleMatrix1D b = new WrapperDoubleMatrix1D(a);
DoubleMatrix1D c = b.viewPart(2,3);
DoubleMatrix1D d = c.viewFlip();
//DoubleMatrix1D c = b.viewFlip();
//DoubleMatrix1D d = c.viewFlip();
d.set(0,99);
b = b.viewSorted();
System.out.println("a = "+a);
System.out.println("b = "+b);
System.out.println("c = "+c);
System.out.println("d = "+d);
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.