Example usage for org.apache.commons.lang ArrayUtils toPrimitive

List of usage examples for org.apache.commons.lang ArrayUtils toPrimitive

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils toPrimitive.

Prototype

public static boolean[] toPrimitive(Boolean[] array) 

Source Link

Document

Converts an array of object Booleans to primitives.

Usage

From source file:de.codesourcery.jasm16.emulator.devices.impl.RawImage.java

public int[] getUniqueColors() {
    final Set<Integer> result = new HashSet<Integer>();
    for (int i = 0; i < data.length; i++) {
        result.add(data[i]);//ww w  .j av a2s  .c  o m
    }
    return ArrayUtils.toPrimitive(result.toArray(new Integer[result.size()]));
}

From source file:be.ugent.maf.cellmissy.analysis.singlecell.processing.impl.SingleCellStatisticsAnalyzerImpl.java

@Override
public void generateSummaryStatistics(SingleCellAnalysisGroup singleCellAnalysisGroup,
        String statisticalTestName, String parameter) {
    StatisticsCalculator statisticsCalculator = StatisticsTestFactory.getInstance()
            .getStatisticsCalculator(statisticalTestName);
    List<StatisticalSummary> statisticalSummaries = new ArrayList<>();

    singleCellAnalysisGroup.getConditionDataHolders().stream().map((conditionDataHolder) -> {
        Double data[] = null;/*from   w  ww  . j av a 2s.  c o m*/
        if (parameter.equalsIgnoreCase("cell speed")) {
            data = conditionDataHolder.getTrackSpeedsVector();
        } else if (parameter.equals("cell direct")) {
            data = conditionDataHolder.getEndPointDirectionalityRatios();
        }
        return data;
    }).map((data) -> statisticsCalculator
            .getSummaryStatistics(ArrayUtils.toPrimitive(AnalysisUtils.excludeNullValues(data))))
            .forEach((statisticalSummary) -> {
                statisticalSummaries.add(statisticalSummary);
            });
    singleCellAnalysisGroup.setStatisticalSummaries(statisticalSummaries);
}

From source file:de.alpharogroup.wicket.base.util.WicketImageExtensions.java

/**
 * Gets a non caching image from the given wicketId, contentType and the Byte array data.
 * /* ww  w . j ava 2s  . c  om*/
 * @param wicketId
 *            the id from the image for the html template.
 * @param contentType
 *            the content type of the image.
 * @param data
 *            the data for the image as an Byte array.
 * @return the non caching image
 */
public static NonCachingImage getNonCachingImage(final String wicketId, final String contentType,
        final Byte[] data) {
    final byte[] byteArrayData = ArrayUtils.toPrimitive(data);
    return getNonCachingImage(wicketId, contentType, byteArrayData);
}

From source file:com.opengamma.util.timeseries.fast.longint.object.FastArrayLongObjectTimeSeries.java

@SuppressWarnings("unchecked")
public FastArrayLongObjectTimeSeries(final DateTimeNumericEncoding encoding, final Long[] times,
        final T[] values) {
    super(encoding);
    _times = new long[times.length];
    _values = (T[]) new Object[values.length];
    init(ArrayUtils.toPrimitive(times), values);
}

From source file:com.trickl.math.lanczos.TridiagonalMatrix.java

public double[] getEigenvalues(boolean discard_ghosts) {
    if (!computed) {
        compute();/*from w w  w  . j av  a2s  . c  o m*/
    }

    List<Double> eigenvalueList;
    if (discard_ghosts) {
        eigenvalueList = eigval_distinct_noghost;
    } else {
        eigenvalueList = eigval_distinct;
    }

    return ArrayUtils.toPrimitive(eigenvalueList.toArray(new Double[eigenvalueList.size()]));
}

From source file:com.opengamma.util.timeseries.fast.longint.FastArrayLongDoubleTimeSeries.java

public FastArrayLongDoubleTimeSeries(final DateTimeNumericEncoding encoding, final Long[] times,
        final Double[] values) {
    super(encoding);
    _times = new long[times.length];
    _values = new double[values.length];
    init(ArrayUtils.toPrimitive(times), ArrayUtils.toPrimitive(values));
}

From source file:it.acubelab.smaph.entityfilters.LibSvmEntityFilter.java

/**
 * Turns a frature_name-feature_value mapping to an array of features.
 * /*from w  ww  .  j  av  a2  s .  co m*/
 * @param features
 *            the mapping from feature names to feature values.
 * @return an array of feature values.
 */
public static double[] featuresToFtrVectStatic(HashMap<String, Double> features) {

    if (!checkFeatures(features)) {
        for (String ftrName : features.keySet())
            System.err.printf("%s -> %f%n", ftrName, features.get(ftrName));
        throw new RuntimeException("Implementation error -- check the features");
    }

    Vector<Double> ftrValues = new Vector<>();
    for (String ftrName : ftrNames)
        ftrValues.add(getOrDefault(features, ftrName, 0.0));

    return ArrayUtils.toPrimitive(ftrValues.toArray(new Double[] {}));
}

From source file:com.opengamma.util.timeseries.fast.integer.FastArrayIntDoubleTimeSeries.java

public FastArrayIntDoubleTimeSeries(final DateTimeNumericEncoding encoding, final Integer[] times,
        final Double[] values) {
    super(encoding);
    _times = new int[times.length];
    _values = new double[values.length];
    init(ArrayUtils.toPrimitive(times), ArrayUtils.toPrimitive(values));
}

From source file:com.opengamma.util.timeseries.fast.integer.object.FastArrayIntObjectTimeSeries.java

@SuppressWarnings("unchecked")
public FastArrayIntObjectTimeSeries(final DateTimeNumericEncoding encoding, final Integer[] times,
        final T[] values) {
    super(encoding);
    _times = new int[times.length];
    _values = (T[]) new Object[values.length];
    init(ArrayUtils.toPrimitive(times), values);
}

From source file:mil.jpeojtrs.sca.util.PrimitiveArrayUtils.java

public static float[] convertToFloatArray(final Object array) {
    if (array == null) {
        return null;
    }/*from www  . j a va 2  s .c om*/
    if (array instanceof float[]) {
        return (float[]) array;
    }
    if (array instanceof Float[]) {
        return ArrayUtils.toPrimitive((Float[]) array);
    }
    final float[] newArray = new float[Array.getLength(array)];
    for (int i = 0; i < newArray.length; i++) {
        final Number val = (Number) Array.get(array, i);
        newArray[i] = val.floatValue();
    }
    return newArray;
}