List of usage examples for java.util.function ToDoubleFunction applyAsDouble
double applyAsDouble(T value);
From source file:org.briljantframework.array.AbstractArray.java
@Override public DoubleArray asDouble(ToDoubleFunction<? super T> to, DoubleFunction<T> from) { return new AsDoubleArray(getArrayFactory(), getOffset(), getShape(), getStride(), getMajorStrideIndex()) { @Override/*from w ww . j av a2 s .c o m*/ protected double getElement(int i) { return to.applyAsDouble(AbstractArray.this.getElement(i)); } @Override protected void setElement(int i, double value) { AbstractArray.this.setElement(i, from.apply(value)); } @Override protected int elementSize() { return AbstractArray.this.elementSize(); } }; }
From source file:org.briljantframework.array.AbstractComplexArray.java
@Override public DoubleArray mapToDouble(ToDoubleFunction<Complex> function) { DoubleArray matrix = factory.newDoubleArray(getShape()); for (int i = 0; i < size(); i++) { matrix.set(i, function.applyAsDouble(get(i))); }/*from w w w. j av a 2s . co m*/ return matrix; }
From source file:org.briljantframework.array.AbstractDoubleArray.java
@Override public void assign(ComplexArray array, ToDoubleFunction<? super Complex> function) { array = ShapeUtils.broadcastIfSensible(this, array); Check.size(this, array); for (int i = 0; i < size(); i++) { set(i, function.applyAsDouble(array.get(i))); }/* w ww .ja v a2 s.c o m*/ }
From source file:org.briljantframework.array.AbstractDoubleArray.java
@Override public DoubleArray reduceVectors(int dim, ToDoubleFunction<? super DoubleArray> reduce) { Check.argument(dim < dims(), INVALID_DIMENSION, dim, dims()); DoubleArray reduced = newEmptyArray(ArrayUtils.remove(getShape(), dim)); int vectors = vectors(dim); for (int i = 0; i < vectors; i++) { double value = reduce.applyAsDouble(getVector(dim, i)); reduced.set(i, value);/* ww w. j av a 2s . c o m*/ } return reduced; }