List of usage examples for java.util Arrays parallelSetAll
public static void parallelSetAll(double[] array, IntToDoubleFunction generator)
From source file:com.simiacryptus.mindseye.lang.Tensor.java
/** * Instantiates a new Tensor.//from w w w . ja va2 s . c om * * @param data the data * @param dims the dims */ public Tensor(@Nullable final float[] data, @Nonnull final int... dims) { if (Tensor.length(dims) >= Integer.MAX_VALUE) throw new IllegalArgumentException(); dimensions = Arrays.copyOf(dims, dims.length); strides = Tensor.getSkips(dims); if (null != data) { this.data = RecycleBin.DOUBLES.obtain(data.length);// Arrays.copyOf(data, data.length); Arrays.parallelSetAll(this.data, i -> { final double v = data[i]; return Double.isFinite(v) ? v : 0; }); assert Arrays.stream(this.data).allMatch(v -> Double.isFinite(v)); } assert isValid(); //assert (null == data || Tensor.length(dims) == data.length); }
From source file:com.simiacryptus.mindseye.lang.Tensor.java
/** * Minus tensor./*from w ww . j av a 2s .c om*/ * * @param right the right * @return the tensor */ @Nonnull public Tensor minus(@Nonnull final Tensor right) { if (!Arrays.equals(getDimensions(), right.getDimensions())) { throw new IllegalArgumentException( Arrays.toString(getDimensions()) + " != " + Arrays.toString(right.getDimensions())); } @Nonnull final Tensor copy = new Tensor(getDimensions()); @Nullable final double[] thisData = getData(); @Nullable final double[] rightData = right.getData(); Arrays.parallelSetAll(copy.getData(), i -> thisData[i] - rightData[i]); return copy; }
From source file:com.simiacryptus.mindseye.lang.Tensor.java
/** * Set tensor./*w ww . j ava 2 s . c o m*/ * * @param f the f * @return the tensor */ @Nonnull public Tensor set(@Nonnull final IntToDoubleFunction f) { Arrays.parallelSetAll(getData(), f); return this; }
From source file:com.simiacryptus.mindseye.lang.Tensor.java
/** * Set./* w w w .j a v a 2 s . co m*/ * * @param right the right * @return the tensor */ public Tensor set(@Nonnull final Tensor right) { assertAlive(); assert length() == right.length(); @Nullable final double[] rightData = right.getData(); Arrays.parallelSetAll(getData(), i -> rightData[i]); return this; }
From source file:org.apache.sysml.runtime.matrix.data.LibMatrixNative.java
public static void fromFloatBuffer(FloatBuffer buff, double[] output) { Arrays.parallelSetAll(output, i -> (double) buff.get(i)); }