List of utility methods to do Float Array Create
Float[] | floatArray(int len) float Array return new Float[len]; |
float[] | toFloatArray(boolean[] array) Coverts given booleans array to array of floats. float[] result = new float[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i] ? 1 : 0; return result; |
float[] | toFloatArray(byte[] byteArray) to Float Array if (byteArray == null || byteArray.length % 4 != 0) return null; float[] flts = new float[byteArray.length / 4]; for (int i = 0; i < flts.length; i++) { flts[i] = toFloat(new byte[] { byteArray[(i * 4)], byteArray[(i * 4) + 1], byteArray[(i * 4) + 2], byteArray[(i * 4) + 3], }); return flts; ... |
float[] | toFloatArray(byte[] data) Convenience method for creating a float array from a byte array. float[] result = new float[data.length / 4]; byte[] tmp = new byte[4]; for (int i = 0; i < result.length; i++) { System.arraycopy(data, i * 4, tmp, 0, 4); result[i] = toFloat(tmp); return result; |
float[] | toFloatArray(byte[] data) to Float Array if ((data == null) || (data.length % 4 != 0)) { return null; float[] flts = new float[data.length / 4]; for (int i = 0; i < flts.length; i++) { flts[i] = toFloat( new byte[] { data[(i * 4)], data[(i * 4) + 1], data[(i * 4) + 2], data[(i * 4) + 3], }); return flts; |
float[] | toFloatArray(double[] doubleArray) to Float Array float[] floatArray = new float[doubleArray.length]; for (int i = 0; i < doubleArray.length; i++) { floatArray[i] = (float) doubleArray[i]; return floatArray; |
float[][] | toFloatArray(double[][] array) to Float Array int nr = array.length; int nc = array[0].length; float[][] ret = new float[nr][nc]; for (int i = 0; i < nr; i++) { for (int j = 0; j < nc; j++) { ret[i][j] = (float) array[i][j]; return ret; |
float[] | toFloatArray(final byte[] array) to Float Array return toFloatArray(array, 0, array.length);
|
float[] | toFloatArray(final double[] doubleArray) to Float Array if (doubleArray == null) { return null; } else { final int size = doubleArray.length; final float[] floatArray = new float[size]; for (int i = 0; i < size; i++) { floatArray[i] = (float) doubleArray[i]; return floatArray; |
float[] | toFloatArray(final Object[] array) to Float Array if (array == null) { return new float[0]; final float[] retVal = new float[array.length]; try { for (int i = 0; i < array.length; i++) { retVal[i] = Float.parseFloat(String.valueOf(array[i])); return retVal; } catch (Exception e) { return new float[0]; |