Search in sources :

Example 16 with IntArrayList

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

the class DoubleMatrix2D method viewSelection.

/**
 *Constructs and returns a new <i>selection view</i> that is a matrix holding all <b>rows</b> matching the given condition.
 *Applies the condition to each row and takes only those row where <tt>condition.apply(viewRow(i))</tt> yields <tt>true</tt>.
 *To match columns, use a dice view.
 *<p>
 *<b>Example:</b>
 *<br>
 *<pre>
 *// extract and view all rows which have a value < threshold in the first column (representing "age")
 *final double threshold = 16;
 *matrix.viewSelection(
 *&nbsp;&nbsp;&nbsp;new DoubleMatrix1DProcedure() {
 *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public final boolean apply(DoubleMatrix1D m) { return m.get(0) < threshold; }
 *&nbsp;&nbsp;&nbsp;}
 *);
 *
 *// extract and view all rows with RMS < threshold
 *// The RMS (Root-Mean-Square) is a measure of the average "size" of the elements of a data sequence.
 *matrix = 0 1 2 3
 *final double threshold = 0.5;
 *matrix.viewSelection(
 *&nbsp;&nbsp;&nbsp;new DoubleMatrix1DProcedure() {
 *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public final boolean apply(DoubleMatrix1D m) { return Math.sqrt(m.aggregate(F.plus,F.square) / m.size()) < threshold; }
 *&nbsp;&nbsp;&nbsp;}
 *);
 *</pre>
 *For further examples, see the <a href="package-summary.html#FunctionObjects">package doc</a>.
 *The returned view is backed by this matrix, so changes in the returned view are reflected in this matrix, and vice-versa.
 *
 *@param  condition The condition to be matched.
 *@return the new view.
 */
public DoubleMatrix2D viewSelection(DoubleMatrix1DProcedure condition) {
    IntArrayList matches = new IntArrayList();
    for (int i = 0; i < rows; i++) {
        if (condition.apply(viewRow(i)))
            matches.add(i);
    }
    matches.trimToSize();
    // take all columns
    return viewSelection(matches.elements(), null);
}
Also used : IntArrayList(cern.colt.list.IntArrayList)

Example 17 with IntArrayList

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

the class AbstractIntIntMap method values.

/**
 * Returns a list filled with all values 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 values of the receiver.
 *
 * @return the values.
 */
public IntArrayList values() {
    IntArrayList list = new IntArrayList(size());
    values(list);
    return list;
}
Also used : IntArrayList(cern.colt.list.IntArrayList)

Example 18 with IntArrayList

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

the class AbstractIntIntMap 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() {
    IntArrayList theKeys = new IntArrayList();
    keysSortedByValue(theKeys);
    StringBuffer buf = new StringBuffer();
    buf.append("[");
    int maxIndex = theKeys.size() - 1;
    for (int i = 0; i <= maxIndex; i++) {
        int 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 : IntArrayList(cern.colt.list.IntArrayList)

Example 19 with IntArrayList

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

the class AbstractIntIntMap 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() {
    IntArrayList theKeys = keys();
    // theKeys.sort();
    StringBuffer buf = new StringBuffer();
    buf.append("[");
    int maxIndex = theKeys.size() - 1;
    for (int i = 0; i <= maxIndex; i++) {
        int 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 : IntArrayList(cern.colt.list.IntArrayList)

Example 20 with IntArrayList

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

the class AbstractIntDoubleMap 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() {
    IntArrayList theKeys = keys();
    String tmp = theKeys.toString() + "\n";
    theKeys.sort();
    StringBuffer buf = new StringBuffer(tmp);
    // StringBuffer buf = new StringBuffer();
    buf.append("[");
    int maxIndex = theKeys.size() - 1;
    for (int i = 0; i <= maxIndex; i++) {
        int 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 : IntArrayList(cern.colt.list.IntArrayList)

Aggregations

IntArrayList (cern.colt.list.IntArrayList)26 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