I am trying to convert a double[]
to float[]
using Java 8 lambda calculus. So far, I just created a toy method which should be revised. Trying to find help for converting primitive arrays. Mostly, is there any approach to get rid of the guava conversion because converting to List and back are too heavy for large arrays.
import com.google.common.primitives.Floats;
public static float[] doubleToFloat(double[] vector) {
Float[] f = Arrays.stream(vector).<Float>mapToObj(x -> (float) x).toArray(Float[]::new);
return Floats.toArray(Arrays.asList(f));
}