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:com.microrisc.hdlcframing.v2.HDLC_DataTransformer.java

public static short[] transformToHLDCFormat(short[] dataToTransform) {
    checkRequestData(dataToTransform);//from  w w  w .java  2 s. c o m
    List<Short> convertedDataList = new LinkedList<>();

    // begining byte
    convertedDataList.add(FLAG_SEQUENCE);

    // data and computing checksum
    short crc = 0xFF;

    for (int dataId = 0; dataId < dataToTransform.length; dataId++) {
        crc = updateCRC(crc, dataToTransform[dataId]);
        convertAndAddByte(dataToTransform[dataId], convertedDataList);
    }

    // adding checksum
    convertAndAddByte(crc, convertedDataList);

    // ending byte
    convertedDataList.add(FLAG_SEQUENCE);

    Short[] transformedData = convertedDataList.toArray(new Short[] {});
    return ArrayUtils.toPrimitive(transformedData);
}

From source file:com.goncalomb.bukkit.nbteditor.nbt.MobNBT.java

public float[] getDropChances() {
    if (_data.hasKey("DropChances")) {
        return ArrayUtils
                .toPrimitive(Arrays.copyOfRange(_data.getListAsArray("DropChances"), 0, 5, Float[].class));
    }/*w ww  . j  a  va2  s. com*/
    return null;
}

From source file:com.opengamma.analytics.financial.model.interestrate.curve.YieldAndDiscountAddZeroSpreadCurve.java

@Override
public double[] getInterestRateParameterSensitivity(double time) {
    final List<Double> result = new ArrayList<Double>();
    double[] temp;
    temp = _curves[0].getInterestRateParameterSensitivity(time);
    for (int loops = 0; loops < temp.length; loops++) {
        result.add(temp[loops]);// w  w w  .j  ava  2 s .  c  o m
    }
    for (int loopcurve = 1; loopcurve < _curves.length; loopcurve++) {
        temp = _curves[loopcurve].getInterestRateParameterSensitivity(time);
        for (int loops = 0; loops < temp.length; loops++) {
            result.add(temp[loops]);
        }
    }
    return ArrayUtils.toPrimitive(result.toArray(new Double[0]));
}

From source file:com.microrisc.hdlcframing.v1.HDLC_DataTransformer.java

public static short[] transformToHLDCFormat(short[] dataToTransform) {
    checkRequestData(dataToTransform);/*from   w  w w  .  j a va2  s .c o  m*/
    List<Short> convertedDataList = new LinkedList<>();

    // begining byte
    convertedDataList.add(FLAG_SEQUENCE);

    // data and computing checksum
    short checksum = dataToTransform[0];

    for (int dataId = 0; dataId < dataToTransform.length; dataId++) {
        if (dataId != 0) {
            checksum ^= dataToTransform[dataId];
        }
        convertAndAddByte(dataToTransform[dataId], convertedDataList);
    }

    // adding checksum
    checksum ^= 0x5F;
    convertAndAddByte(checksum, convertedDataList);

    // ending byte
    convertedDataList.add(FLAG_SEQUENCE);

    Short[] transformedData = convertedDataList.toArray(new Short[] {});
    return ArrayUtils.toPrimitive(transformedData);
}

From source file:de.l3s.common.features.hadoop.TimeSeriesReducer.java

public void reduce(Text key, Iterator<Timeseries> values, Context context)
        throws IOException, InterruptedException {
    // To load JRI library
    // Set -Djava.library.path = /usr/lib64/R/library/rJava/jri
    Timeseries timeSeries;/*  www.  j  a v a2s.  c  o  m*/
    List<Integer> ts_list = Lists.newArrayList();
    while (values.hasNext()) {

        timeSeries = values.next();
        for (KeyData keydata : timeSeries.ts_points) {
            ts_list.add((int) keydata.dataPoint.fValue);
        }
        // calculate auto correlation score
        double[] acf_score = eval.computeAutoCorrel(ts_list.size(),
                ArrayUtils.toPrimitive(ts_list.toArray(new Integer[ts_list.size()])));

        context.write(key, new DoubleWritable(acf_score[0]));
    }

}

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

public double[] getErrors(boolean discard_ghosts) {
    if (!computed) {
        compute();/*  w  w  w. jav  a2s  . c o m*/
    }

    List<Double> errorList;
    if (discard_ghosts) {
        errorList = err_noghost;
    } else {
        errorList = err;
    }

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

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

@Override
public void executePairwiseComparisons(SingleCellAnalysisGroup singleCellAnalysisGroup,
        String statisticalTestName, String parameter) {
    StatisticsCalculator statisticsCalculator = StatisticsTestFactory.getInstance()
            .getStatisticsCalculator(statisticalTestName);

    Double[][] dataMatrix = generateDataMatrix(singleCellAnalysisGroup, parameter);

    Double[][] pValuesMatrix = new Double[dataMatrix.length][dataMatrix.length];
    for (int i = 0; i < dataMatrix.length; i++) {
        double[] firstVector = ArrayUtils.toPrimitive(AnalysisUtils.excludeNullValues(dataMatrix[i]));
        for (int seq = 0; seq < dataMatrix.length; seq++) {
            if (seq != i) {
                double[] secondVector = ArrayUtils
                        .toPrimitive(AnalysisUtils.excludeNullValues(dataMatrix[seq]));
                double pValue = statisticsCalculator.executeStatisticalTest(firstVector, secondVector);
                pValuesMatrix[i][seq] = pValue;
            }/*from w w  w.  jav  a2 s  .  c o m*/
        }
    }
    Double[][] transposedMatrix = AnalysisUtils.transpose2DArray(pValuesMatrix);
    Double[][] formatSymmetricMatrix = AnalysisUtils.formatSymmetricMatrix(transposedMatrix);
    singleCellAnalysisGroup.setpValuesMatrix(formatSymmetricMatrix);
}

From source file:com.naver.template.social.TwitterBO.java

public List<TwitterProfile> getFriendList(String userId) {
    CursoredList<Long> friendIdList = getFriendIdList(userId);
    List<List<Long>> chunkedList = ChunkUtils.chunk(friendIdList, 10);

    List<TwitterProfile> twitterFriends = new ArrayList<TwitterProfile>();
    for (List<Long> eachList : chunkedList) {
        Long[] array = eachList.toArray(new Long[0]);
        twitterFriends.addAll(getTwitterProfiles(userId, ArrayUtils.toPrimitive(array)));
    }//from  ww  w . j a v  a2  s . c o  m

    return twitterFriends;
}

From source file:be.ugent.maf.cellmissy.analysis.EntropiesTest.java

@Test
public void testEntropies() {
    stepCentricOperator.generateCoordinatesMatrix(stepCentricDataHolder, 1.0);
    double[] timeIndexes = new double[] { 1, 2, 3, 4, 5, 6 }; // time indexes of the track
    stepCentricDataHolder.setTimeIndexes(timeIndexes);
    stepCentricOperator.init2Dtrees(stepCentricDataHolder);

    Double[][] coordinatesMatrix = stepCentricDataHolder.getCoordinatesMatrix();
    double[] xCoord = ArrayUtils
            .toPrimitive(AnalysisUtils.excludeNullValues(AnalysisUtils.transpose2DArray(coordinatesMatrix)[0]));
    double[] yCoord = ArrayUtils
            .toPrimitive(AnalysisUtils.excludeNullValues(AnalysisUtils.transpose2DArray(coordinatesMatrix)[1]));
    List<EnclosingBall> enclosingBalls = enclosingBallsCalculator.findEnclosingBalls(xCoord, yCoord,
            stepCentricDataHolder.getxY2DTree(), 1.5);

    List<List<EnclosingBall>> list = new ArrayList<>();
    list.add(enclosingBalls);/*from w  w  w.j  a  va2  s. com*/
    stepCentricDataHolder.setxYEnclosingBalls(list);
    cellCentricOperator.computeEntropies(stepCentricDataHolder, cellCentricDataHolder);
    Double entropy = cellCentricDataHolder.getEntropies().get(0);

    //        stepCentricDataHolder.setxYEnclosingBalls(list);
    //        cellCentricOperator.computeEntropies(stepCentricDataHolder, cellCentricDataHolder);
    //        entropy = cellCentricDataHolder.getEntropies().get(0);
    //        Assert.assertEquals(0.113, entropy, 0.1);
}

From source file:be.ugent.maf.cellmissy.analysis.EnclosingBallsCalculatorTest.java

@Test
public void testEnclosingBalls() {
    stepCentricOperator.generateCoordinatesMatrix(stepCentricDataHolder, 1.0);
    double[] timeIndexes = new double[] { 2, 3, 5, 6, 7, 10 }; // time indexes of the track
    stepCentricDataHolder.setTimeIndexes(timeIndexes);
    stepCentricOperator.init2Dtrees(stepCentricDataHolder);

    Double[][] coordinatesMatrix = stepCentricDataHolder.getCoordinatesMatrix();
    double[] xCoord = ArrayUtils
            .toPrimitive(AnalysisUtils.excludeNullValues(AnalysisUtils.transpose2DArray(coordinatesMatrix)[0]));
    double[] yCoord = ArrayUtils
            .toPrimitive(AnalysisUtils.excludeNullValues(AnalysisUtils.transpose2DArray(coordinatesMatrix)[1]));
    List<EnclosingBall> enclosingBalls = enclosingBallsCalculator.findEnclosingBalls(xCoord, yCoord,
            stepCentricDataHolder.getxY2DTree(), 0.1);
    Assert.assertEquals(6, enclosingBalls.size());

    enclosingBalls = enclosingBallsCalculator.findEnclosingBalls(xCoord, yCoord,
            stepCentricDataHolder.getxY2DTree(), 0.5);
    Assert.assertEquals(5, enclosingBalls.size());
    List<List<EnclosingBall>> list = new ArrayList<>();
    list.add(enclosingBalls);/*  ww  w. ja  va  2 s .c  o m*/
    stepCentricDataHolder.setxYEnclosingBalls(list);
    cellCentricOperator.computeEntropies(stepCentricDataHolder, cellCentricDataHolder);
    Double entropy = cellCentricDataHolder.getEntropies().get(0);
    //        Assert.assertEquals(0.113, entropy, 0.1);
    //
    //        enclosingBalls = enclosingBallsCalculator.findEnclosingBalls(xCoord, yCoord, stepCentricDataHolder.getxY2DTree(), 1.1);
    //        Assert.assertEquals(3, enclosingBalls.size());
    //        Assert.assertEquals(3, enclosingBalls.get(0).getEnclosingPoints().size());
    //        Assert.assertEquals(2, enclosingBalls.get(1).getEnclosingPoints().size());
    //        Assert.assertEquals(1, enclosingBalls.get(2).getEnclosingPoints().size());
    //
    //        enclosingBalls = enclosingBallsCalculator.findEnclosingBalls(timeIndexes, xCoord, stepCentricDataHolder.getxT2DTree(), 0.5);
    //        Assert.assertEquals(6, enclosingBalls.size());
    //        enclosingBalls = enclosingBallsCalculator.findEnclosingBalls(timeIndexes, xCoord, stepCentricDataHolder.getxT2DTree(), 1.0);
    //        Assert.assertEquals(6, enclosingBalls.size());
    //        enclosingBalls = enclosingBallsCalculator.findEnclosingBalls(timeIndexes, xCoord, stepCentricDataHolder.getxT2DTree(), 1.5);
    //        Assert.assertEquals(4, enclosingBalls.size());
    //
    //        stepCentricDataHolder.setxYEnclosingBalls(list);
    //        cellCentricOperator.computeEntropies(stepCentricDataHolder, cellCentricDataHolder);
    //        entropy = cellCentricDataHolder.getEntropies().get(0);
    //        Assert.assertEquals(0.113, entropy, 0.1);
}