Search in sources :

Example 6 with DoubleArrayList

use of cern.colt.list.DoubleArrayList 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 7 with DoubleArrayList

use of cern.colt.list.DoubleArrayList 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 8 with DoubleArrayList

use of cern.colt.list.DoubleArrayList 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 9 with DoubleArrayList

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

the class AbstractDoubleIntMap method toString.

/**
 * Returns a string representation of the receiver, containing
 * the String representation of each key-value pair, sorted ascending by key.
 */
public String toString() {
    DoubleArrayList theKeys = keys();
    theKeys.sort();
    StringBuffer buf = new StringBuffer();
    buf.append("[");
    int maxIndex = theKeys.size() - 1;
    for (int i = 0; i <= maxIndex; i++) {
        double key = theKeys.get(i);
        buf.append(String.valueOf(key));
        buf.append("->");
        buf.append(String.valueOf(get(key)));
        if (i < maxIndex)
            buf.append(", ");
    }
    buf.append("]");
    return buf.toString();
}
Also used : DoubleArrayList(cern.colt.list.DoubleArrayList)

Example 10 with DoubleArrayList

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

the class AbstractDoubleIntMap method toStringByValue.

/**
 * Returns a string representation of the receiver, containing
 * the String representation of each key-value pair, sorted ascending by value.
 */
public String toStringByValue() {
    DoubleArrayList theKeys = new DoubleArrayList();
    keysSortedByValue(theKeys);
    StringBuffer buf = new StringBuffer();
    buf.append("[");
    int maxIndex = theKeys.size() - 1;
    for (int i = 0; i <= maxIndex; i++) {
        double key = theKeys.get(i);
        buf.append(String.valueOf(key));
        buf.append("->");
        buf.append(String.valueOf(get(key)));
        if (i < maxIndex)
            buf.append(", ");
    }
    buf.append("]");
    return buf.toString();
}
Also used : DoubleArrayList(cern.colt.list.DoubleArrayList)

Aggregations

DoubleArrayList (cern.colt.list.DoubleArrayList)82 RegressionResult (edu.cmu.tetrad.regression.RegressionResult)11 ArrayList (java.util.ArrayList)9 AndersonDarlingTest (edu.cmu.tetrad.data.AndersonDarlingTest)8 IntArrayList (cern.colt.list.IntArrayList)6 DenseDoubleMatrix2D (cern.colt.matrix.impl.DenseDoubleMatrix2D)5 TetradVector (edu.cmu.tetrad.util.TetradVector)5 Test (org.junit.Test)5 DoubleMatrix2D (cern.colt.matrix.DoubleMatrix2D)4 TetradMatrix (edu.cmu.tetrad.util.TetradMatrix)4 DoubleMatrix1D (cern.colt.matrix.DoubleMatrix1D)3 DenseDoubleMatrix1D (cern.colt.matrix.impl.DenseDoubleMatrix1D)3 Regression (edu.cmu.tetrad.regression.Regression)3 RegressionDataset (edu.cmu.tetrad.regression.RegressionDataset)3 StopWatch (org.apache.commons.lang3.time.StopWatch)2 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)2 Record (org.onebusaway.transit_data.model.realtime.CurrentVehicleEstimateQueryBean.Record)2 ScheduledBlockLocation (org.onebusaway.transit_data_federation.services.blocks.ScheduledBlockLocation)2 BlockLocation (org.onebusaway.transit_data_federation.services.realtime.BlockLocation)2 ByteArrayConverter (ubic.basecode.io.ByteArrayConverter)2