Example usage for java.math BigInteger doubleValue

List of usage examples for java.math BigInteger doubleValue

Introduction

In this page you can find the example usage for java.math BigInteger doubleValue.

Prototype

public double doubleValue() 

Source Link

Document

Converts this BigInteger to a double .

Usage

From source file:com.github.jessemull.microflex.stat.statbiginteger.NBigIntegerTest.java

/**
 * Tests well calculation.// www  . j a va  2s  . c o m
 */
@Test
public void testWell() {

    for (PlateBigInteger plate : array) {

        for (WellBigInteger well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (BigInteger bi : well) {
                input[index++] = bi.doubleValue();
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getN();
            double returned = n.well(well);

            assertTrue(result == returned);
        }
    }
}

From source file:com.github.jessemull.microflexbiginteger.stat.NTest.java

/**
 * Tests well calculation.//from  w  w w.j av  a  2 s  . co m
 */
@Test
public void testWell() {

    for (Plate plate : array) {

        for (Well well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (BigInteger bi : well) {
                input[index++] = bi.doubleValue();
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getN();
            double returned = n.well(well);

            assertTrue(result == returned);
        }
    }
}

From source file:cc.redberry.core.number.Numeric.java

@Override
public Numeric divide(BigInteger bg) {
    checkNotNull(bg);/*  w w  w .jav a 2  s . co m*/
    //FUTURE fraction.doubleValue() is very unefficient operation
    return divide(bg.doubleValue());

}

From source file:com.github.jessemull.microflex.stat.statbiginteger.NBigIntegerTest.java

/**
 * Tests the aggregated plate statistics method.
 *///from  www  .ja va  2s.  c om
@Test
public void testAggregatedPlate() {

    for (PlateBigInteger plate : array) {

        List<Double> resultList = new ArrayList<Double>();
        int aggregatedReturned = n.platesAggregated(plate);

        for (WellBigInteger well : plate) {

            for (BigInteger bi : well) {
                resultList.add(bi.doubleValue());
            }

        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregated = statAggregated.getN();

        assertEquals((int) resultAggregated, aggregatedReturned);
    }
}

From source file:com.github.jessemull.microflex.stat.statbiginteger.NBigIntegerTest.java

/**
 * Tests the aggregated plate statistics method.
 *//* ww  w  .  j a  va2s  . c  o m*/
@Test
public void testAggregatedSet() {

    for (PlateBigInteger plate : array) {

        List<Double> resultList = new ArrayList<Double>();
        int aggregatedReturned = n.setsAggregated(plate.dataSet());

        for (WellBigInteger well : plate) {

            for (BigInteger bi : well) {
                resultList.add(bi.doubleValue());
            }

        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregated = statAggregated.getN();

        assertEquals((int) resultAggregated, aggregatedReturned);
    }
}

From source file:com.github.jessemull.microflexbiginteger.stat.NTest.java

/**
 * Tests the aggregated plate statistics method.
 *//*from   w ww .  j  a  v  a2 s  . c o  m*/
@Test
public void testAggregatedPlate() {

    for (Plate plate : array) {

        List<Double> resultList = new ArrayList<Double>();
        int aggregatedReturned = n.platesAggregated(plate);

        for (Well well : plate) {

            for (BigInteger bi : well) {
                resultList.add(bi.doubleValue());
            }

        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregated = statAggregated.getN();

        assertEquals((int) resultAggregated, aggregatedReturned);
    }
}

From source file:com.github.jessemull.microflexbiginteger.stat.NTest.java

/**
 * Tests the aggregated plate statistics method.
 *///from  w w  w .ja  v  a2  s. com
@Test
public void testAggregatedSet() {

    for (Plate plate : array) {

        List<Double> resultList = new ArrayList<Double>();
        int aggregatedReturned = n.setsAggregated(plate.dataSet());

        for (Well well : plate) {

            for (BigInteger bi : well) {
                resultList.add(bi.doubleValue());
            }

        }

        double[] inputAggregated = new double[resultList.size()];

        for (int i = 0; i < resultList.size(); i++) {
            inputAggregated[i] = resultList.get(i);
        }

        DescriptiveStatistics statAggregated = new DescriptiveStatistics(inputAggregated);
        double resultAggregated = statAggregated.getN();

        assertEquals((int) resultAggregated, aggregatedReturned);
    }
}

From source file:cc.redberry.core.number.Numeric.java

@Override
public Numeric pow(BigInteger exponent) {
    checkNotNull(exponent);/*from  ww  w .ja va2 s .com*/
    //FUTURE bg.doubleValue() is very unefficient operation
    return pow(exponent.doubleValue());
}

From source file:com.github.jessemull.microflex.stat.statbiginteger.NBigIntegerTest.java

/**
 * Tests the plate statistics method./*  w w  w . j  a v a2  s . c om*/
 */
@Test
public void testPlate() {

    for (PlateBigInteger plate : array) {

        Map<WellBigInteger, Integer> resultMap = new TreeMap<WellBigInteger, Integer>();
        Map<WellBigInteger, Integer> returnedMap = n.plate(plate);

        for (WellBigInteger well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (BigInteger bi : well) {
                input[index++] = bi.doubleValue();
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getN();

            resultMap.put(well, (int) result);
        }

        for (WellBigInteger well : plate) {

            int result = resultMap.get(well);
            int returned = returnedMap.get(well);

            assertEquals(result, returned);
        }
    }
}

From source file:com.github.jessemull.microflexbiginteger.stat.NTest.java

/**
 * Tests the plate statistics method./* w w w.  j av a  2  s. com*/
 */
@Test
public void testPlate() {

    for (Plate plate : array) {

        Map<Well, Integer> resultMap = new TreeMap<Well, Integer>();
        Map<Well, Integer> returnedMap = n.plate(plate);

        for (Well well : plate) {

            double[] input = new double[well.size()];
            int index = 0;

            for (BigInteger bi : well) {
                input[index++] = bi.doubleValue();
            }

            DescriptiveStatistics stat = new DescriptiveStatistics(input);
            double result = stat.getN();

            resultMap.put(well, (int) result);
        }

        for (Well well : plate) {

            int result = resultMap.get(well);
            int returned = returnedMap.get(well);

            assertEquals(result, returned);
        }
    }
}