List of usage examples for java.util.function ToDoubleFunction applyAsDouble
double applyAsDouble(T value);
From source file:at.gridtec.lambda4j.function.tri.conversion.TriDoubleToShortFunction.java
/** * Returns a composed {@link ToShortTriFunction} that first applies the {@code before} functions to its input, and * then applies this function to the result. * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation. * * @param <A> The type of the argument to the first given function, and of composed function * @param <B> The type of the argument to the second given function, and of composed function * @param <C> The type of the argument to the third given function, and of composed function * @param before1 The first function to apply before this function is applied * @param before2 The second function to apply before this function is applied * @param before3 The third function to apply before this function is applied * @return A composed {@code ToShortTriFunction} that first applies the {@code before} functions to its input, and * then applies this function to the result. * @throws NullPointerException If given argument is {@code null} * @implSpec The input argument of this method is able to handle every type. *///from ww w . ja v a2 s . c o m @Nonnull default <A, B, C> ToShortTriFunction<A, B, C> compose(@Nonnull final ToDoubleFunction<? super A> before1, @Nonnull final ToDoubleFunction<? super B> before2, @Nonnull final ToDoubleFunction<? super C> before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (a, b, c) -> applyAsShort(before1.applyAsDouble(a), before2.applyAsDouble(b), before3.applyAsDouble(c)); }
From source file:at.gridtec.lambda4j.operator.ternary.DoubleTernaryOperator.java
/** * Returns a composed {@link ToDoubleTriFunction} that first applies the {@code before} functions to its input, and * then applies this operator to the result. * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation. * * @param <A> The type of the argument to the first given function, and of composed function * @param <B> The type of the argument to the second given function, and of composed function * @param <C> The type of the argument to the third given function, and of composed function * @param before1 The first function to apply before this operator is applied * @param before2 The second function to apply before this operator is applied * @param before3 The third function to apply before this operator is applied * @return A composed {@code ToDoubleTriFunction} that first applies the {@code before} functions to its input, and * then applies this operator to the result. * @throws NullPointerException If given argument is {@code null} * @implSpec The input argument of this method is able to handle every type. *//*from w w w . ja va 2 s . co m*/ @Nonnull default <A, B, C> ToDoubleTriFunction<A, B, C> compose(@Nonnull final ToDoubleFunction<? super A> before1, @Nonnull final ToDoubleFunction<? super B> before2, @Nonnull final ToDoubleFunction<? super C> before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (a, b, c) -> applyAsDouble(before1.applyAsDouble(a), before2.applyAsDouble(b), before3.applyAsDouble(c)); }
From source file:at.gridtec.lambda4j.predicate.tri.obj.BiObjDoublePredicate.java
/** * Returns a composed {@link TriPredicate} that first applies the {@code before} functions to its input, and * then applies this predicate to the result. * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation. * * @param <A> The type of the argument to the first given function, and of composed predicate * @param <B> The type of the argument to the second given function, and of composed predicate * @param <C> The type of the argument to the third given function, and of composed predicate * @param before1 The first function to apply before this predicate is applied * @param before2 The second function to apply before this predicate is applied * @param before3 The third function to apply before this predicate is applied * @return A composed {@code TriPredicate} that first applies the {@code before} functions to its input, and then * applies this predicate to the result. * @throws NullPointerException If given argument is {@code null} * @implSpec The input argument of this method is able to handle every type. */// ww w .j av a 2 s . c o m @Nonnull default <A, B, C> TriPredicate<A, B, C> compose(@Nonnull final Function<? super A, ? extends T> before1, @Nonnull final Function<? super B, ? extends U> before2, @Nonnull final ToDoubleFunction<? super C> before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (a, b, c) -> test(before1.apply(a), before2.apply(b), before3.applyAsDouble(c)); }
From source file:at.gridtec.lambda4j.predicate.tri.TriDoublePredicate.java
/** * Returns a composed {@link TriPredicate} that first applies the {@code before} functions to its input, and * then applies this predicate to the result. * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation. * * @param <A> The type of the argument to the first given function, and of composed predicate * @param <B> The type of the argument to the second given function, and of composed predicate * @param <C> The type of the argument to the third given function, and of composed predicate * @param before1 The first function to apply before this predicate is applied * @param before2 The second function to apply before this predicate is applied * @param before3 The third function to apply before this predicate is applied * @return A composed {@code TriPredicate} that first applies the {@code before} functions to its input, and then * applies this predicate to the result. * @throws NullPointerException If given argument is {@code null} * @implSpec The input argument of this method is able to handle every type. */// w w w. j a v a 2s.c om @Nonnull default <A, B, C> TriPredicate<A, B, C> compose(@Nonnull final ToDoubleFunction<? super A> before1, @Nonnull final ToDoubleFunction<? super B> before2, @Nonnull final ToDoubleFunction<? super C> before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (a, b, c) -> test(before1.applyAsDouble(a), before2.applyAsDouble(b), before3.applyAsDouble(c)); }
From source file:at.gridtec.lambda4j.predicate.tri.obj.ObjBiDoublePredicate.java
/** * Returns a composed {@link TriPredicate} that first applies the {@code before} functions to its input, and * then applies this predicate to the result. * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation. * * @param <A> The type of the argument to the first given function, and of composed predicate * @param <B> The type of the argument to the second given function, and of composed predicate * @param <C> The type of the argument to the third given function, and of composed predicate * @param before1 The first function to apply before this predicate is applied * @param before2 The second function to apply before this predicate is applied * @param before3 The third function to apply before this predicate is applied * @return A composed {@code TriPredicate} that first applies the {@code before} functions to its input, and then * applies this predicate to the result. * @throws NullPointerException If given argument is {@code null} * @implSpec The input argument of this method is able to handle every type. *//* w w w . j av a 2 s. c o m*/ @Nonnull default <A, B, C> TriPredicate<A, B, C> compose(@Nonnull final Function<? super A, ? extends T> before1, @Nonnull final ToDoubleFunction<? super B> before2, @Nonnull final ToDoubleFunction<? super C> before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (a, b, c) -> test(before1.apply(a), before2.applyAsDouble(b), before3.applyAsDouble(c)); }
From source file:gedi.riboseq.inference.orf.OrfFinder.java
/** * orf->[total-activity,fraction-by-coverage] * @param equi//from w w w . j a v a 2s . c o m * @param uniqueRegions * @param acti * @return */ private HashMap<OrfWithCodons, double[]> estimateByCoverage( HashMap<HashSet<OrfWithCodons>, HashSet<Codon>> equi, HashMap<HashSet<OrfWithCodons>, Integer> equiLengths, ToDoubleFunction<Codon> acti) { HashMap<HashSet<OrfWithCodons>, Double> vv = new HashMap<HashSet<OrfWithCodons>, Double>(); double[] v = new double[equi.size()]; OrfWithCodons[][] E = new OrfWithCodons[equi.size()][]; HashSet<Codon>[] codons = new HashSet[E.length]; int ind = 0; for (HashSet<OrfWithCodons> e : equi.keySet()) { codons[ind] = equi.get(e); E[ind] = e.toArray(new OrfWithCodons[0]); for (Codon c : equi.get(e)) v[ind] += acti.applyAsDouble(c); vv.put(e, v[ind]); v[ind] /= equiLengths.get(e); ind++; } HashMap<OrfWithCodons, double[]> re = new HashMap<OrfWithCodons, double[]>(); new EquivalenceClassMinimizeFactors<OrfWithCodons>(E, v) .compute((orf, pi) -> re.put(orf, new double[] { 0, pi })); for (HashSet<OrfWithCodons> e : equi.keySet()) { double sum = EI.wrap(e).mapToDouble(i -> re.get(i)[1]).sum(); for (OrfWithCodons i : e) { double[] r = re.get(i); r[0] += vv.get(e) * r[1] / sum; } } return re; }
From source file:com.simiacryptus.mindseye.lang.Tensor.java
/** * Fill by coord tensor./*from w w w. j a v a 2 s . c o m*/ * * @param f the f * @param parallel the parallel * @return the tensor */ @Nonnull public Tensor setByCoord(@Nonnull final ToDoubleFunction<Coordinate> f, boolean parallel) { coordStream(parallel).forEach(c -> set(c, f.applyAsDouble(c))); return this; }
From source file:com.simiacryptus.mindseye.lang.Tensor.java
/** * Map coords tensor.//from w ww.j av a 2 s . co m * * @param f the f * @param parallel the parallel * @return the tensor */ @Nullable public Tensor mapCoords(@Nonnull final ToDoubleFunction<Coordinate> f, boolean parallel) { return new Tensor(Tensor.getDoubles(coordStream(parallel).mapToDouble(i -> f.applyAsDouble(i)), length()), dimensions); }
From source file:com.simiacryptus.mindseye.lang.Tensor.java
/** * Map coords and free tensor.// www . j av a 2 s .co m * * @param f the f * @param parallel the parallel * @return the tensor */ @Nullable public Tensor mapCoordsAndFree(@Nonnull final ToDoubleFunction<Coordinate> f, boolean parallel) { Tensor tensor = new Tensor( Tensor.getDoubles(coordStream(parallel).mapToDouble(i -> f.applyAsDouble(i)), length()), dimensions); freeRef(); return tensor; }
From source file:org.briljantframework.array.AbstractArray.java
@Override public DoubleArray mapToDouble(ToDoubleFunction<? super T> f) { DoubleArray array = getArrayFactory().newDoubleArray(getShape()); for (int i = 0; i < size(); i++) { array.set(i, f.applyAsDouble(get(i))); }/*from w w w. j a va 2 s . com*/ return array; }