當前位置: 首頁>>代碼示例>>Java>>正文


Java DoubleUnaryOperator.applyAsDouble方法代碼示例

本文整理匯總了Java中java.util.function.DoubleUnaryOperator.applyAsDouble方法的典型用法代碼示例。如果您正苦於以下問題:Java DoubleUnaryOperator.applyAsDouble方法的具體用法?Java DoubleUnaryOperator.applyAsDouble怎麽用?Java DoubleUnaryOperator.applyAsDouble使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.function.DoubleUnaryOperator的用法示例。


在下文中一共展示了DoubleUnaryOperator.applyAsDouble方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: integrate

import java.util.function.DoubleUnaryOperator; //導入方法依賴的package包/類
static double integrate(DoubleUnaryOperator f, double a, double b) {
    double dx = (b - a);
    double sum0;
    double sum1 = f.applyAsDouble(a) * (b - a);
    int it = 1;
    do {
        dx /= 2.;
        it *= 2;
        sum0 = sum1;
        sum1 = .0;
        for (double x = a, eps = dx / 2.; x + eps < b; x += dx) {
            sum1 += dx * f.applyAsDouble(x);
        }
    } while (Math.abs(sum0 - sum1) > 1e-7 && it < 100000000);
    return sum1;
}
 
開發者ID:biblelamp,項目名稱:JavaExercises,代碼行數:17,代碼來源:Stepic_3_5_7.java

示例2: iterate

import java.util.function.DoubleUnaryOperator; //導入方法依賴的package包/類
/**
 * Returns an infinite sequential ordered {@code DoubleStream} produced by iterative
 * application of a function {@code f} to an initial element {@code seed},
 * producing a {@code Stream} consisting of {@code seed}, {@code f(seed)},
 * {@code f(f(seed))}, etc.
 *
 * <p>The first element (position {@code 0}) in the {@code DoubleStream}
 * will be the provided {@code seed}.  For {@code n > 0}, the element at
 * position {@code n}, will be the result of applying the function {@code f}
 *  to the element at position {@code n - 1}.
 *
 * @param seed the initial element
 * @param f a function to be applied to to the previous element to produce
 *          a new element
 * @return a new sequential {@code DoubleStream}
 */
public static DoubleStream iterate(final double seed, final DoubleUnaryOperator f) {
    Objects.requireNonNull(f);
    final PrimitiveIterator.OfDouble iterator = new PrimitiveIterator.OfDouble() {
        double t = seed;

        @Override
        public boolean hasNext() {
            return true;
        }

        @Override
        public double nextDouble() {
            double v = t;
            t = f.applyAsDouble(t);
            return v;
        }
    };
    return StreamSupport.doubleStream(Spliterators.spliteratorUnknownSize(
            iterator,
            Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL), false);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:38,代碼來源:DoubleStream.java

示例3: iterate

import java.util.function.DoubleUnaryOperator; //導入方法依賴的package包/類
/**
 * Returns an infinite sequential ordered {@code DoubleStream} produced by iterative
 * application of a function {@code f} to an initial element {@code seed},
 * producing a {@code Stream} consisting of {@code seed}, {@code f(seed)},
 * {@code f(f(seed))}, etc.
 *
 * <p>The first element (position {@code 0}) in the {@code DoubleStream}
 * will be the provided {@code seed}.  For {@code n > 0}, the element at
 * position {@code n}, will be the result of applying the function {@code f}
 *  to the element at position {@code n - 1}.
 *
 * <p>The action of applying {@code f} for one element
 * <a href="../concurrent/package-summary.html#MemoryVisibility"><i>happens-before</i></a>
 * the action of applying {@code f} for subsequent elements.  For any given
 * element the action may be performed in whatever thread the library
 * chooses.
 *
 * @param seed the initial element
 * @param f a function to be applied to the previous element to produce
 *          a new element
 * @return a new sequential {@code DoubleStream}
 */
public static DoubleStream iterate(final double seed, final DoubleUnaryOperator f) {
    Objects.requireNonNull(f);
    Spliterator.OfDouble spliterator = new Spliterators.AbstractDoubleSpliterator(Long.MAX_VALUE,
           Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL) {
        double prev;
        boolean started;

        @Override
        public boolean tryAdvance(DoubleConsumer action) {
            Objects.requireNonNull(action);
            double t;
            if (started)
                t = f.applyAsDouble(prev);
            else {
                t = seed;
                started = true;
            }
            action.accept(prev = t);
            return true;
        }
    };
    return StreamSupport.doubleStream(spliterator, false);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:46,代碼來源:DoubleStream.java

示例4: iterate

import java.util.function.DoubleUnaryOperator; //導入方法依賴的package包/類
/**
 * Returns an infinite sequential ordered {@code DoubleStream} produced by iterative
 * application of a function {@code f} to an initial element {@code seed},
 * producing a {@code Stream} consisting of {@code seed}, {@code f(seed)},
 * {@code f(f(seed))}, etc.
 *
 * <p>The first element (position {@code 0}) in the {@code DoubleStream}
 * will be the provided {@code seed}.  For {@code n > 0}, the element at
 * position {@code n}, will be the result of applying the function {@code f}
 *  to the element at position {@code n - 1}.
 *
 * @param seed the initial element
 * @param f a function to be applied to the previous element to produce
 *          a new element
 * @return a new sequential {@code DoubleStream}
 */
public static DoubleStream iterate(final double seed, final DoubleUnaryOperator f) {
    Objects.requireNonNull(f);
    Spliterator.OfDouble spliterator = new Spliterators.AbstractDoubleSpliterator(Long.MAX_VALUE,
           Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL) {
        double prev;
        boolean started;

        @Override
        public boolean tryAdvance(DoubleConsumer action) {
            Objects.requireNonNull(action);
            double t;
            if (started)
                t = f.applyAsDouble(prev);
            else {
                t = seed;
                started = true;
            }
            action.accept(prev = t);
            return true;
        }
    };
    return StreamSupport.doubleStream(spliterator, false);
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:40,代碼來源:DoubleStream.java

示例5: map

import java.util.function.DoubleUnaryOperator; //導入方法依賴的package包/類
@NonNull
@Override
public MuVector2d map(@NonNull final DoubleUnaryOperator operator) {
  this.x = operator.applyAsDouble(this.x);
  this.y = operator.applyAsDouble(this.y);
  return this;
}
 
開發者ID:KyoriPowered,項目名稱:math,代碼行數:8,代碼來源:MuVector2d.java

示例6: map

import java.util.function.DoubleUnaryOperator; //導入方法依賴的package包/類
@NonNull
@Override
public MuVector3d map(@NonNull final DoubleUnaryOperator operator) {
  this.x = operator.applyAsDouble(this.x);
  this.y = operator.applyAsDouble(this.y);
  this.z = operator.applyAsDouble(this.z);
  return this;
}
 
開發者ID:KyoriPowered,項目名稱:math,代碼行數:9,代碼來源:MuVector3d.java

示例7: map

import java.util.function.DoubleUnaryOperator; //導入方法依賴的package包/類
@NonNull
@Override
public MuVector4d map(@NonNull final DoubleUnaryOperator operator) {
  this.x = operator.applyAsDouble(this.x);
  this.y = operator.applyAsDouble(this.y);
  this.z = operator.applyAsDouble(this.z);
  this.w = operator.applyAsDouble(this.w);
  return this;
}
 
開發者ID:KyoriPowered,項目名稱:math,代碼行數:10,代碼來源:MuVector4d.java

示例8: map

import java.util.function.DoubleUnaryOperator; //導入方法依賴的package包/類
@NonNull
@Override
public MuVector4f map(@NonNull final DoubleUnaryOperator operator) {
  this.x = (float) operator.applyAsDouble(this.x);
  this.y = (float) operator.applyAsDouble(this.y);
  this.z = (float) operator.applyAsDouble(this.z);
  this.w = (float) operator.applyAsDouble(this.w);
  return this;
}
 
開發者ID:KyoriPowered,項目名稱:math,代碼行數:10,代碼來源:MuVector4f.java

示例9: map

import java.util.function.DoubleUnaryOperator; //導入方法依賴的package包/類
@NonNull
@Override
public MuVector3f map(@NonNull final DoubleUnaryOperator operator) {
  this.x = (float) operator.applyAsDouble(this.x);
  this.y = (float) operator.applyAsDouble(this.y);
  this.z = (float) operator.applyAsDouble(this.z);
  return this;
}
 
開發者ID:KyoriPowered,項目名稱:math,代碼行數:9,代碼來源:MuVector3f.java

示例10: map

import java.util.function.DoubleUnaryOperator; //導入方法依賴的package包/類
@NonNull
@Override
public MuVector2f map(@NonNull final DoubleUnaryOperator operator) {
  this.x = (float) operator.applyAsDouble(this.x);
  this.y = (float) operator.applyAsDouble(this.y);
  return this;
}
 
開發者ID:KyoriPowered,項目名稱:math,代碼行數:8,代碼來源:MuVector2f.java

示例11: updateAndGet

import java.util.function.DoubleUnaryOperator; //導入方法依賴的package包/類
public final double updateAndGet( DoubleUnaryOperator updateFunction ) {
    double prev, next;
    do {
        prev = get();
        next = updateFunction.applyAsDouble( prev );
    } while ( !compareAndSet( prev, next ) );
    return next;
}
 
開發者ID:lukas81298,項目名稱:FlexMC,代碼行數:9,代碼來源:BetterAtomicDouble.java

示例12: getAndUpdate

import java.util.function.DoubleUnaryOperator; //導入方法依賴的package包/類
public final double getAndUpdate( DoubleUnaryOperator updateFunction ) {
    double prev, next;
    do {
        prev = get();
        next = updateFunction.applyAsDouble( prev );
    } while ( !compareAndSet( prev, next ) );
    return prev;
}
 
開發者ID:lukas81298,項目名稱:FlexMC,代碼行數:9,代碼來源:BetterAtomicDouble.java

示例13: applyToArray

import java.util.function.DoubleUnaryOperator; //導入方法依賴的package包/類
public static double[] applyToArray(final double[] array, final DoubleUnaryOperator func) {
    Utils.nonNull(func, "function may not be null");
    Utils.nonNull(array, "array may not be null");
    final double[] result = new double[array.length];
    for (int m = 0; m < result.length; m++) {
        result[m] = func.applyAsDouble(array[m]);
    }
    return result;
}
 
開發者ID:BGI-flexlab,項目名稱:SOAPgaea,代碼行數:10,代碼來源:VCFQualityControlUtil.java

示例14: applyToArrayInPlace

import java.util.function.DoubleUnaryOperator; //導入方法依賴的package包/類
public static double[] applyToArrayInPlace(final double[] array, final DoubleUnaryOperator func) {
    Utils.nonNull(array, "array may not be null");
    Utils.nonNull(func, "function may not be null");
    for (int m = 0; m < array.length; m++) {
        array[m] = func.applyAsDouble(array[m]);
    }
    return array;
}
 
開發者ID:BGI-flexlab,項目名稱:SOAPgaea,代碼行數:9,代碼來源:VCFQualityControlUtil.java

示例15: applyToArray

import java.util.function.DoubleUnaryOperator; //導入方法依賴的package包/類
public static double[] applyToArray(final double[] array, final DoubleUnaryOperator func) {
JointCallingUtils.nonNull(func, "function may not be null");
      JointCallingUtils.nonNull(array, "array may not be null");
      final double[] result = new double[array.length];
      for (int m = 0; m < result.length; m++) {
          result[m] = func.applyAsDouble(array[m]);
      }
      return result;
  }
 
開發者ID:BGI-flexlab,項目名稱:SOAPgaea,代碼行數:10,代碼來源:GvcfMathUtils.java


注:本文中的java.util.function.DoubleUnaryOperator.applyAsDouble方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。