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();
}
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");
}
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 <= column < columns() && 0 <= row < 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);
}
}
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();
}
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();
}
Aggregations