Java Utililty Methods Double Array Create

List of utility methods to do Double Array Create

Description

The list of methods to do Double Array Create are organized into topic(s).

Method

double[]toDoubleArray(byte[] byteArray)
to Double Array
if (byteArray == null)
    return null;
if (byteArray.length % 8 != 0)
    return null;
double[] dbls = new double[byteArray.length / 8];
for (int i = 0; i < dbls.length; i++) {
    dbls[i] = toDouble(new byte[] { byteArray[(i * 8)], byteArray[(i * 8) + 1], byteArray[(i * 8) + 2],
            byteArray[(i * 8) + 3], byteArray[(i * 8) + 4], byteArray[(i * 8) + 5], byteArray[(i * 8) + 6],
...
double[]toDoubleArray(byte[] data)
Convenience method for creating a double array from a byte array.
double[] result = new double[data.length / 8];
byte[] tmp = new byte[8];
for (int i = 0; i < result.length; i++) {
    System.arraycopy(data, i * 8, tmp, 0, 8);
    result[i] = toDouble(tmp);
return result;
double[]toDoubleArray(Double[] data)
Converts a Double array to a double array
double[] result = new double[data.length];
for (int i = 0; i < data.length; i++)
    result[i] = data[i].doubleValue();
return result;
double[]toDoubleArray(final byte[] array)
to Double Array
return toDoubleArray(array, 0, array.length);
double[]toDoubleArray(final long[] array)
Converts an array of long primitives to an array of doubles.
double[] values = new double[array.length];
for (int i = 0; i < array.length; i++)
    values[i] = array[i];
return values;
double[]toDoubleArray(final Object[] array)
to Double Array
if (array == null) {
    return new double[0];
final double[] retVal = new double[array.length];
try {
    for (int i = 0; i < array.length; i++) {
        retVal[i] = Double.parseDouble(String.valueOf(array[i]));
    return retVal;
} catch (Exception e) {
    return new double[0];
double[]toDoubleArray(int... intArray)
to Double Array
int nmb = intArray.length;
double[] ret = new double[nmb];
for (int i = 0; i < nmb; i++)
    ret[i] = intArray[i];
return ret;
double[]toDoubleArray(int[] ints)
Returns an array with the same shape and the contents converted to doubles.
double[] retVal = new double[ints.length];
for (int i = 0; i < ints.length; i++) {
    retVal[i] = ints[i];
return retVal;
double[]toDoubleArray(Number[] array)
Turns the Number array into one consisting of primitive doubles.
double[] result;
int i;
result = new double[array.length];
for (i = 0; i < array.length; i++)
    result[i] = array[i].doubleValue();
return result;
double[]toDoubleArray(String array)
Cast a string to an array of double

String should have the format "[1.2,2.6,3]"

if (array.length() == 2)
    return new double[0];
String[] cast = array.substring(1, array.length() - 1).split(",");
double[] result = new double[cast.length];
for (int i = 0; i < cast.length; i++) {
    result[i] = Double.valueOf(cast[i]);
return result;
...