Search in sources :

Example 1 with IntArrayList

use of cern.colt.list.IntArrayList in project tdq-studio-se by Talend.

the class DynamicBin1D method toString.

/**
 * Returns a String representation of the receiver.
 */
public synchronized String toString() {
    StringBuffer buf = new StringBuffer(super.toString());
    DoubleArrayList distinctElements = new DoubleArrayList();
    IntArrayList frequencies = new IntArrayList();
    frequencies(distinctElements, frequencies);
    if (distinctElements.size() < 100) {
        // don't cause unintended floods
        buf.append("Distinct elements: " + distinctElements + "\n");
        buf.append("Frequencies: " + frequencies + "\n");
    } else {
        buf.append("Distinct elements & frequencies not printed (too many).");
    }
    return buf.toString();
}
Also used : DoubleArrayList(cern.colt.list.DoubleArrayList) IntArrayList(cern.colt.list.IntArrayList)

Example 2 with IntArrayList

use of cern.colt.list.IntArrayList in project tdq-studio-se by Talend.

the class TestMatrix2D method doubleTest30.

/**
 */
public static void doubleTest30(int size, int val) {
    // int[] values = { 0, 2};
    int[] values = { 2 };
    IntArrayList list = new IntArrayList(values);
    int l = values.length - 1;
    int sum = 0;
    cern.colt.Timer timer = new cern.colt.Timer().start();
    for (int i = size; --i >= 0; ) {
        int k = cern.colt.Sorting.binarySearchFromTo(values, val, 0, l);
        // int k = list.binarySearchFromTo(val,0,l);
        // System.out.println(list+", "+val+" --> i="+k+", -i-1="+(-k-1));
        sum += k;
    }
    timer.stop().display();
    System.out.println("sum = " + sum);
/*
System.out.println("\n\n");
System.out.println("initializing...");
boolean dense = false;
DoubleMatrix2D A;
DoubleFactory2D factory;
if (dense) 
	factory = Factory2D.dense;
else 
	factory = Factory2D.sparse;
	
double value = 0.5;	

DoubleMatrix2D C = Factory2D.dense.sample(size,size,value,0.01);

A = factory.make(size,size);
cern.colt.Timer timer = new cern.colt.Timer().start();
A.assign(C);
timer.stop().display();

timer.reset().start();
double sum=0;
for (int i=0; i<size; i++) {
	for (int j=0; j<size; j++ ) {
		sum+=A.getQuick(i,j);
	}
}
timer.stop().display();
System.out.println(sum);
//System.out.println(A);

JSci.maths.DoubleSparseMatrix B = new JSci.maths.DoubleSparseMatrix(size);
timer.reset().start();
for (int i=size; --i>=0; ) {
	for (int j=size; --j>=0; ) {
//for (int i=0; i<size; i++) {
//	for (int j=0; j<size; j++ ) {
		B.setElement2(i,j,C.getQuick(i,j));
	}
}
//System.out.println(A);
timer.stop().display();

timer.reset().start();
sum=0;
for (int i=0; i<size; i++) {
	for (int j=0; j<size; j++ ) {
		sum+=B.getElement2(i,j);
	}
}
System.out.println(sum);
timer.stop().display();

System.out.println("done.");

*/
}
Also used : IntArrayList(cern.colt.list.IntArrayList)

Example 3 with IntArrayList

use of cern.colt.list.IntArrayList in project tdq-studio-se by Talend.

the class Benchmark method test2.

/**
 * Prints the first <tt>size</tt> random numbers generated by the distribution.
 */
public static void test2(int size, AbstractDistribution a, AbstractDistribution b) {
    hep.aida.bin.DynamicBin1D binA = new hep.aida.bin.DynamicBin1D();
    hep.aida.bin.DynamicBin1D binB = new hep.aida.bin.DynamicBin1D();
    for (int j = 0, i = size; --i >= 0; j++) {
        binA.add(a.nextDouble());
        binB.add(b.nextDouble());
    }
    // System.out.println(binA);
    // System.out.println(binB);
    // System.out.println(binA.compareWith(binB));
    System.out.println("\n\nBenchmarking frequencies...\n");
    IntArrayList freq = new IntArrayList();
    DoubleArrayList distinct = new DoubleArrayList();
    cern.colt.Timer timer = new cern.colt.Timer();
    timer.reset();
    timer.start();
    binA.frequencies(distinct, freq);
    timer.stop().display();
    // System.out.println(distinct);
    // System.out.println(freq);
    /*
	timer.reset();
	timer.start();
	binA.xfrequencies2(distinct,freq);
	timer.stop().display();
	//System.out.println(distinct);
	//System.out.println(freq);
	*/
    /*
	distinct.shuffle();
	timer.reset().start();
	distinct.sort();
	timer.stop().display();

	timer.reset().start();
	binA.frequencies(distinct,freq);
	timer.stop().display();
	//System.out.println(distinct);
	//System.out.println(freq);
	*/
    System.out.println("\n\nGood bye.\n");
}
Also used : IntArrayList(cern.colt.list.IntArrayList) DoubleArrayList(cern.colt.list.DoubleArrayList)

Example 4 with IntArrayList

use of cern.colt.list.IntArrayList in project tdq-studio-se by Talend.

the class RCMDoubleMatrix2D method setQuick.

/**
 * Sets the matrix cell at coordinate <tt>[row,column]</tt> to the specified value.
 *
 * <p>Provided with invalid parameters this method may access illegal indexes without throwing any exception.
 * <b>You should only use this method when you are absolutely sure that the coordinate is within bounds.</b>
 * Precondition (unchecked): <tt>0 &lt;= column &lt; columns() && 0 &lt;= row &lt; rows()</tt>.
 *
 * @param     row   the index of the row-coordinate.
 * @param     column   the index of the column-coordinate.
 * @param    value the value to be filled into the specified cell.
 */
public void setQuick(int row, int column, double value) {
    int i = row;
    int j = column;
    int k = -1;
    IntArrayList indexList = indexes[i];
    if (indexList != null)
        k = indexList.binarySearch(j);
    if (k >= 0) {
        // found
        if (value == 0) {
            DoubleArrayList valueList = values[i];
            indexList.remove(k);
            valueList.remove(k);
            int s = indexList.size();
            if (s > 2 && s * 3 < indexList.elements().length) {
                indexList.setSize(s * 3 / 2);
                indexList.trimToSize();
                indexList.setSize(s);
                valueList.setSize(s * 3 / 2);
                valueList.trimToSize();
                valueList.setSize(s);
            }
        } else {
            values[i].setQuick(k, value);
        }
    } else {
        // not found
        if (value == 0)
            return;
        k = -k - 1;
        if (indexList == null) {
            indexes[i] = new IntArrayList(3);
            values[i] = new DoubleArrayList(3);
        }
        indexes[i].beforeInsert(k, j);
        values[i].beforeInsert(k, value);
    }
}
Also used : IntArrayList(cern.colt.list.IntArrayList) DoubleArrayList(cern.colt.list.DoubleArrayList)

Example 5 with IntArrayList

use of cern.colt.list.IntArrayList in project tdq-studio-se by Talend.

the class AbstractIntIntMap method keys.

/**
 * Returns a list filled with all keys contained in the receiver.
 * The returned list has a size that equals <tt>this.size()</tt>.
 * Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(IntProcedure)}.
 * <p>
 * This method can be used to iterate over the keys of the receiver.
 *
 * @return the keys.
 */
public IntArrayList keys() {
    IntArrayList list = new IntArrayList(size());
    keys(list);
    return list;
}
Also used : IntArrayList(cern.colt.list.IntArrayList)

Aggregations

IntArrayList (cern.colt.list.IntArrayList)27 DoubleArrayList (cern.colt.list.DoubleArrayList)6 ExperimentalFactor (ubic.gemma.model.expression.experiment.ExperimentalFactor)2 ArrayList (java.util.ArrayList)1 ChiSquaredDistribution (org.apache.commons.math3.distribution.ChiSquaredDistribution)1 ChiSquareTest (org.apache.commons.math3.stat.inference.ChiSquareTest)1 ExpressionDataDoubleMatrix (ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix)1 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)1 FactorValue (ubic.gemma.model.expression.experiment.FactorValue)1