diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java index ee090e1c1ac7134433c540a1242dc2a56006ab89..98257aacce7f7dcbbfba7046936ea787652cb8f0 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java @@ -40,6 +40,8 @@ import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.MaterializedFrame; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.TruffleObject; +import com.oracle.truffle.api.nodes.DirectCallNode; +import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.profiles.ConditionProfile; @@ -309,6 +311,7 @@ final class REngine implements Engine, Engine.Timings { private final class PolyglotEngineRootNode extends RootNode { private final List<RSyntaxNode> statements; + @Children private final DirectCallNode[] calls; private final boolean printResult; @Child private Node findContext = TruffleRLanguage.INSTANCE.actuallyCreateFindContextNode(); @@ -318,6 +321,7 @@ final class REngine implements Engine, Engine.Timings { // can't print if initializing the system in embedded mode (no builtins yet) this.printResult = !sourceSection.getSource().getName().equals(RSource.Internal.INIT_EMBEDDED.string); this.statements = statements; + this.calls = new DirectCallNode[statements.size()]; } /** @@ -326,6 +330,7 @@ final class REngine implements Engine, Engine.Timings { * control over what that might be when the call is initiated. */ @Override + @ExplodeLoop public Object execute(VirtualFrame frame) { RContext oldContext = RContext.getThreadLocalInstance(); RContext newContext = TruffleRLanguage.INSTANCE.actuallyFindContext0(findContext); @@ -334,8 +339,11 @@ final class REngine implements Engine, Engine.Timings { Object lastValue = RNull.instance; for (int i = 0; i < statements.size(); i++) { RSyntaxNode node = statements.get(i); - RootCallTarget callTarget = doMakeCallTarget(node.asRNode(), RSource.Internal.REPL_WRAPPER.string, printResult, true); - lastValue = callTarget.call(newContext.stateREnvironment.getGlobalFrame()); + if (calls[i] == null) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + calls[i] = insert(Truffle.getRuntime().createDirectCallNode(doMakeCallTarget(node.asRNode(), RSource.Internal.REPL_WRAPPER.string, printResult, true))); + } + lastValue = calls[i].call(frame, new Object[]{newContext.stateREnvironment.getGlobalFrame()}); } return lastValue; } catch (ReturnException ex) { @@ -526,7 +534,7 @@ final class REngine implements Engine, Engine.Timings { if (topLevel) { RErrorHandling.printWarnings(suppressWarnings); } - setVisibility.executeEndOfFunction(vf); + setVisibility.executeEndOfFunction(vf, this); } catch (RError e) { CompilerDirectives.transferToInterpreter(); throw e; @@ -558,6 +566,11 @@ final class REngine implements Engine, Engine.Timings { return result; } + @Override + public String getName() { + return description; + } + @Override public String toString() { return description; diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Chisq.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Chisq.java index c39fa8c5e71ef0ff5c84add184ea21ccee6cd3df..62205497a7d92a5001454b1052b948a90fd643b7 100644 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Chisq.java +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Chisq.java @@ -13,11 +13,18 @@ package com.oracle.truffle.r.library.stats; import static com.oracle.truffle.r.library.stats.GammaFunctions.dgamma; import static com.oracle.truffle.r.library.stats.GammaFunctions.pgamma; +import static com.oracle.truffle.r.library.stats.GammaFunctions.qgamma; +import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandFunction1_Double; +import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandomNumberProvider; import com.oracle.truffle.r.library.stats.StatsFunctions.Function2_1; import com.oracle.truffle.r.library.stats.StatsFunctions.Function2_2; public final class Chisq { + private Chisq() { + // only static members + } + public static final class PChisq implements Function2_2 { @Override public double evaluate(double x, double df, boolean lowerTail, boolean logP) { @@ -31,4 +38,25 @@ public final class Chisq { return dgamma(x, df / 2., 2., giveLog); } } + + public static final class QChisq implements Function2_2 { + @Override + public double evaluate(double p, double df, boolean lowerTail, boolean logP) { + return qgamma(p, 0.5 * df, 2.0, lowerTail, logP); + } + } + + public static final class RChisq extends RandFunction1_Double { + public static double rchisq(double df, RandomNumberProvider rand) { + if (!Double.isFinite(df) || df < 0.0) { + return RMath.mlError(); + } + return new RGamma().execute(df / 2.0, 2.0, rand); + } + + @Override + public double execute(double a, RandomNumberProvider rand) { + return rchisq(a, rand); + } + } } diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/DPQ.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/DPQ.java index 35a19b7a93b62001827c828b49d9b444d85f9d3c..4509a1f64689f66db8aefc9e0e839648c10b4b84 100644 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/DPQ.java +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/DPQ.java @@ -51,6 +51,11 @@ public final class DPQ { return logP ? Double.NEGATIVE_INFINITY : 0.; } + // R_D_half (log_p ? -M_LN2 : 0.5) + public static double rdhalf(boolean logP) { + return logP ? -M_LN2 : 0.5; + } + // R_D__1 public static double rd1(boolean logP) { return logP ? 0. : 1.; @@ -117,6 +122,11 @@ public final class DPQ { return logP ? RMath.log1p(-(p)) : (0.5 - (p) + 0.5); } + // R_D_qIv (log_p ? exp(p) : (p)) + public static double rdqiv(double p, boolean logP) { + return logP ? Math.exp(p) : p; + } + // R_DT_qIv public static double rdtqiv(double p, boolean lowerTail, boolean logP) { return logP ? lowerTail ? Math.exp(p) : -Math.expm1(p) : rdlval(p, lowerTail); diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/GammaFunctions.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/GammaFunctions.java index 2a700e05a9605b176c60f1b734439fdcb02bb986..645d38b0cf9865ef4b9806138fdc8766a048a5f2 100644 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/GammaFunctions.java +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/GammaFunctions.java @@ -895,9 +895,8 @@ public abstract class GammaFunctions { if (logp) { return rlog1exp(RMath.log1p(sum) + lf2); } else { - double f1m1 = sum; double f2m1 = RMath.expm1(lf2); - return -(f1m1 + f2m1 + f1m1 * f2m1); + return -(sum + f2m1 + sum * f2m1); } } } /* pgamma_smallx() */ @@ -1382,7 +1381,7 @@ public abstract class GammaFunctions { // pnorm // - private static double pnorm(double x, double mu, double sigma, boolean lowerTail, boolean logp) { + static double pnorm(double x, double mu, double sigma, boolean lowerTail, boolean logp) { double p; double cp = 0; double localX = x; diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Geom.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Geom.java index 29390fe21162fdb557584439c284c88402a1f74c..a01c809ff41a1f05c90d102784cf48b3c0b36356 100644 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Geom.java +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Geom.java @@ -91,6 +91,37 @@ public final class Geom { } } + public static final class PGeom implements Function2_2 { + @Override + public double evaluate(double xIn, double p, boolean lowerTail, boolean logP) { + if (Double.isNaN(xIn) || Double.isNaN(p)) { + return xIn + p; + } + if (p <= 0 || p > 1) { + return RMath.mlError(); + } + + if (xIn < 0.) { + return DPQ.rdt0(lowerTail, logP); + } + if (!Double.isFinite(xIn)) { + return DPQ.rdt1(lowerTail, logP); + } + double x = Math.floor(xIn + 1e-7); + + if (p == 1.) { /* we cannot assume IEEE */ + x = lowerTail ? 1 : 0; + return logP ? Math.log(x) : x; + } + x = RMath.log1p(-p) * (x + 1); + if (logP) { + return DPQ.rdtclog(x, lowerTail, logP); + } else { + return lowerTail ? -RMath.expm1(x) : Math.exp(x); + } + } + } + public static final class RGeom extends RandFunction1_Double { @Override public double execute(double p, RandomNumberProvider rand) { diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/MathConstants.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/MathConstants.java index 61bc036c42e836445108ea3208bfecf9089332f2..1f257567fca09a92c5d911e6934d8762ae6c30e2 100644 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/MathConstants.java +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/MathConstants.java @@ -86,6 +86,8 @@ public final class MathConstants { public static final double DBL_EPSILON = Math.ulp(1.0); + public static final double ML_NAN = Double.NaN; + /** * Compute the log of a sum from logs of terms, i.e., * diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/PPois.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/PPois.java new file mode 100644 index 0000000000000000000000000000000000000000..cb67510db3cd5d1c41278662627c9583032cf25f --- /dev/null +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/PPois.java @@ -0,0 +1,37 @@ +/* + * This material is distributed under the GNU General Public License + * Version 2. You may review the terms of this license at + * http://www.gnu.org/licenses/gpl-2.0.html + * + * Copyright (C) 1998 Ross Ihaka + * Copyright (c) 2000, The R Core Team + * Copyright (c) 2016, Oracle and/or its affiliates + * + * All rights reserved. + */ +package com.oracle.truffle.r.library.stats; + +import static com.oracle.truffle.r.library.stats.GammaFunctions.pgamma; + +import com.oracle.truffle.r.library.stats.StatsFunctions.Function2_2; + +public class PPois implements Function2_2 { + @Override + public double evaluate(double x, double lambda, boolean lowerTail, boolean logP) { + if (Double.isNaN(x) || Double.isNaN(lambda) || lambda < 0.) { + return RMath.mlError(); + } + if (x < 0) { + return DPQ.rdt0(lowerTail, logP); + } + if (lambda == 0.) { + return DPQ.rdt1(lowerTail, logP); + } + if (!Double.isFinite(x)) { + return DPQ.rdt1(lowerTail, logP); + } + x = Math.floor(x + 1e-7); + + return pgamma(lambda, x + 1, 1., !lowerTail, logP); + } +} diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Pbeta.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Pbeta.java index 02c713c68abadf8fe6755b5a2ead937269cc88bd..4c12e76f64cc9dc11324231c7a825de34b62abb3 100644 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Pbeta.java +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Pbeta.java @@ -29,7 +29,7 @@ public final class Pbeta implements Function3_2 { } @TruffleBoundary - private static double pbetaRaw(double x, double a, double b, boolean lowerTail, boolean logProb) { + static double pbetaRaw(double x, double a, double b, boolean lowerTail, boolean logProb) { // treat limit cases correctly here: if (a == 0 || b == 0 || !Double.isFinite(a) || !Double.isFinite(b)) { // NB: 0 < x < 1 : diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Pt.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Pt.java new file mode 100644 index 0000000000000000000000000000000000000000..20373ea17dd2e82f10ee5acf05d595feb4e55b8f --- /dev/null +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Pt.java @@ -0,0 +1,85 @@ +/* + * This material is distributed under the GNU General Public License + * Version 2. You may review the terms of this license at + * http://www.gnu.org/licenses/gpl-2.0.html + * + * Copyright (c) 1995, 1996, Robert Gentleman and Ross Ihaka + * Copyright (c) 2000-2007, The R Core Team + * Copyright (c) 2016, Oracle and/or its affiliates + * + * All rights reserved. + */ +package com.oracle.truffle.r.library.stats; + +import static com.oracle.truffle.r.library.stats.GammaFunctions.pnorm; +import static com.oracle.truffle.r.library.stats.LBeta.lbeta; +import static com.oracle.truffle.r.library.stats.MathConstants.M_LN2; +import static com.oracle.truffle.r.library.stats.Pbeta.pbeta; + +import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.r.library.stats.StatsFunctions.Function2_2; + +public class Pt implements Function2_2 { + private final BranchProfile pbetaNanProfile = BranchProfile.create(); + + @Override + public double evaluate(double x, double n, boolean lowerTail, boolean logP) { + /* + * return P[ T <= x ] where T ~ t_{n} (t distrib. with n degrees of freedom). + * + * --> ./pnt.c for NON-central + */ + if (Double.isNaN(x) || Double.isNaN(n)) { + return x + n; + } + + if (n <= 0.0) { + return RMath.mlError(); + } + + if (!Double.isFinite(x)) { + return (x < 0) ? DPQ.rdt0(lowerTail, logP) : DPQ.rdt1(lowerTail, logP); + } + if (!Double.isFinite(n)) { + return pnorm(x, 0.0, 1.0, lowerTail, logP); + } + + double nx = 1 + (x / n) * x; + /* + * FIXME: This test is probably losing rather than gaining precision, now that pbeta(*, + * log_p = true) is much better. Note however that a version of this test *is* needed for + * x*x > D_MAX + */ + double val; + if (nx > 1e100) { /* <==> x*x > 1e100 * n */ + /* + * Danger of underflow. So use Abramowitz & Stegun 26.5.4 pbeta(z, a, b) ~ z^a(1-z)^b / + * aB(a,b) ~ z^a / aB(a,b), with z = 1/nx, a = n/2, b= 1/2 : + */ + double lval; + lval = -0.5 * n * (2 * Math.log(Math.abs(x)) - Math.log(n)) - lbeta(0.5 * n, 0.5) - Math.log(0.5 * n); + val = logP ? lval : Math.exp(lval); + } else { + val = (n > x * x) + ? pbeta(x * x / (n + x * x), 0.5, n / 2., /* lower_tail */false, logP, pbetaNanProfile) + : pbeta(1. / nx, n / 2., 0.5, /* lower_tail */true, logP, pbetaNanProfile); + } + + /* Use "1 - v" if lower_tail and x > 0 (but not both): */ + if (x <= 0.) { + lowerTail = !lowerTail; + } + + if (logP) { + if (lowerTail) { + return RMath.log1p(-0.5 * Math.exp(val)); + } else { + return val - M_LN2; /* = Math.log(.5* pbeta(....)) */ + } + } else { + val /= 2.; + return DPQ.rdcval(val, lowerTail); + } + + } +} diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/QBeta.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/QBeta.java new file mode 100644 index 0000000000000000000000000000000000000000..7af7d44a25bedc7d72d42edbc8005805d6c0e0d7 --- /dev/null +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/QBeta.java @@ -0,0 +1,659 @@ +/* + * This material is distributed under the GNU General Public License + * Version 2. You may review the terms of this license at + * http://www.gnu.org/licenses/gpl-2.0.html + * + * Copyright (c) 1995, 1996, Robert Gentleman and Ross Ihaka + * Copyright (c) 1998-2015, The R Core Team + * Copyright (c) 2016, Oracle and/or its affiliates + * + * All rights reserved. + */ +/* + * based on code (C) 1979 and later Royal Statistical Society + * + * Reference: + * Cran, G. W., K. J. Martin and G. E. Thomas (1977). + * Remark AS R19 and Algorithm AS 109, + * Applied Statistics, 26(1), 111-114. + * Remark AS R83 (v.39, 309-310) and the correction (v.40(1) p.236) + * have been incorporated in this version. + */ +package com.oracle.truffle.r.library.stats; + +import static com.oracle.truffle.r.library.stats.Arithmetic.powDi; +import static com.oracle.truffle.r.library.stats.LBeta.lbeta; +import static com.oracle.truffle.r.library.stats.MathConstants.DBL_MANT_DIG; +import static com.oracle.truffle.r.library.stats.MathConstants.DBL_MIN_EXP; +import static com.oracle.truffle.r.library.stats.MathConstants.ML_NAN; +import static com.oracle.truffle.r.library.stats.MathConstants.M_LN2; +import static com.oracle.truffle.r.library.stats.Pbeta.pbetaRaw; + +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.r.library.stats.RMath.MLError; +import com.oracle.truffle.r.library.stats.StatsFunctions.Function3_2; +import com.oracle.truffle.r.runtime.RError.Message; + +public final class QBeta implements Function3_2 { + private static final double USE_LOG_X_CUTOFF = -5.; + private static final int N_NEWTON_FREE = 4; + // TODO: find out why this??? Is swap_01 R logical?? + private static final int MLOGICAL_NA = -1; + + @Override + public double evaluate(double alpha, double p, double q, boolean lowerTail, boolean logP) { + if (Double.isNaN(p) || Double.isNaN(q) || Double.isNaN(alpha)) { + return p + q + alpha; + } + + if (p < 0. || q < 0.) { + return RMath.mlError(); + } + // allowing p==0 and q==0 <==> treat as one- or two-point mass + + double[] qbet = new double[2]; // = { qbeta(), 1 - qbeta() } + new QBetaRawMethod().qbeta_raw(alpha, p, q, lowerTail, logP, MLOGICAL_NA, USE_LOG_X_CUTOFF, N_NEWTON_FREE, qbet); + return qbet[0]; + + } + + /** + * Debugging printfs should print exactly the same output as GnuR, this can help with debugging. + */ + private static void debugPrintf(@SuppressWarnings("unused") String fmt, @SuppressWarnings("unused") Object... args) { + // System.out.printf(fmt + "\n", args); + } + + private static final double acu_min = 1e-300; + private static final double log_eps_c = M_LN2 * (1. - DBL_MANT_DIG); // = log(DBL_EPSILON) = + // -36.04..; + private static final double fpu = 3e-308; + private static final double p_lo = fpu; + private static final double p_hi = 1 - 2.22e-16; + + private static final double const1 = 2.30753; + private static final double const2 = 0.27061; + private static final double const3 = 0.99229; + private static final double const4 = 0.04481; + + private static final double DBL_very_MIN = Double.MIN_VALUE / 4.; + private static final double DBL_log_v_MIN = M_LN2 * (DBL_MIN_EXP - 2); + private static final double DBL_1__eps = 0x1.fffffffffffffp-1; // = 1 - 2^-53 + + // The fields and variables are named after local variables from GnuR, we keep the original + // names for the ease of debugging + // Checkstyle: stop field name check + private static class QBetaRawMethod { + private boolean give_log_q; + private boolean use_log_x; + private boolean add_N_step; + private double logbeta; + private boolean swap_tail; + private double a; + private double la; + private double pp; + private double qq; + private double r; + private double t; + private double tx; + private double u_n; + private double xinbta; + private double u; + private boolean warned; + private double acu; + private double y; + private double w; + private boolean log_; // or u < log_q_cut below + private double p_; + private double u0; + private double s; + private double h; + boolean bad_u; + boolean bad_init; + private double g; + private double D; + + /** + * + * @param alpha + * @param p + * @param q + * @param lower_tail + * @param log_p + * @param swap_01 {true, NA, false}: if NA, algorithm decides swap_tail + * @param log_q_cut if == Inf: return Math.log(qbeta(..)); otherwise, if finite: the bound + * for switching to Math.log(x)-scale; see use_log_x + * @param n_N number of "unconstrained" Newton steps before switching to constrained + * @param qb The result will be saved to this 2 dimensional array = qb[0:1] = { qbeta(), 1 - + * qbeta() }. + */ + @TruffleBoundary + private void qbeta_raw(double alpha, double p, double q, boolean lower_tail, boolean log_p, + int swap_01, + double log_q_cut, + int n_N, + double[] qb) { + give_log_q = (log_q_cut == Double.POSITIVE_INFINITY); + use_log_x = give_log_q; + add_N_step = true; + y = -1.; + + // Assuming p >= 0, q >= 0 here ... + + // Deal with boundary cases here: + if (alpha == DPQ.rdt0(lower_tail, log_p)) { + returnQ0(qb, give_log_q); + return; + } + if (alpha == DPQ.rdt1(lower_tail, log_p)) { + returnQ1(qb, give_log_q); + return; + } + + // check alpha {*before* transformation which may all accuracy}: + if ((log_p && alpha > 0) || + (!log_p && (alpha < 0 || alpha > 1))) { // alpha is outside + debugPrintf("qbeta(alpha=%g, %g, %g, .., log_p=%d): %s%s\n", + alpha, p, q, log_p, "alpha not in ", + log_p ? "[-Inf, 0]" : "[0,1]"); + // ML_ERR_return_NAN : + RMath.mlError(MLError.DOMAIN, ""); + qb[0] = qb[1] = ML_NAN; + return; + } + + // p==0, q==0, p = Inf, q = Inf <==> treat as one- or two-point mass + if (p == 0 || q == 0 || !Double.isFinite(p) || !Double.isFinite(q)) { + // We know 0 < T(alpha) < 1 : pbeta() is constant and trivial in {0, 1/2, 1} + debugPrintf( + "qbeta(%g, %g, %g, lower_t=%d, log_p=%d): (p,q)-boundary: trivial\n", + alpha, p, q, lower_tail, log_p); + if (p == 0 && q == 0) { // point mass 1/2 at each of {0,1} : + if (alpha < DPQ.rdhalf(log_p)) { + returnQ0(qb, give_log_q); + } else if (alpha > DPQ.rdhalf(log_p)) { + returnQ1(qb, give_log_q); + } else { + returnQHalf(qb, give_log_q); + } + return; + } else if (p == 0 || p / q == 0) { // point mass 1 at 0 - "flipped around" + returnQ0(qb, give_log_q); + } else if (q == 0 || q / p == 0) { // point mass 1 at 0 - "flipped around" + returnQ1(qb, give_log_q); + } else { + // else: p = q = Inf : point mass 1 at 1/2 + returnQHalf(qb, give_log_q); + } + return; + } + + p_ = DPQ.rdtqiv(alpha, lower_tail, log_p); + logbeta = lbeta(p, q); + boolean swap_choose = (swap_01 == MLOGICAL_NA); + swap_tail = swap_choose ? (p_ > 0.5) : swap_01 != 0; + if (swap_tail) { /* change tail, swap p <-> q : */ + a = DPQ.rdtciv(alpha, lower_tail, log_p); // = 1 - p_ < 1/2 + /* la := log(a), but without numerical cancellation: */ + la = DPQ.rdtclog(alpha, lower_tail, log_p); + pp = q; + qq = p; + } else { + a = p_; + la = DPQ.rdtlog(alpha, lower_tail, log_p); + pp = p; + qq = q; + } + + /* calculate the initial approximation */ + + /* + * Desired accuracy for Newton iterations (below) should depend on (a,p) This is from + * Remark .. on AS 109, adapted. However, it's not clear if this is "optimal" for IEEE + * double prec. + * + * acu = fmax2(acu_min, pow(10., -25. - 5./(pp * pp) - 1./(a * a))); + * + * NEW: 'acu' accuracy NOT for squared adjustment, but simple; ---- i.e., "new acu" = + * sqrt(old acu) + */ + acu = Math.max(acu_min, Math.pow(10., -13. - 2.5 / (pp * pp) - 0.5 / (a * a))); + // try to catch "extreme left tail" early + u0 = (la + Math.log(pp) + logbeta) / pp; // = log(x_0) + r = pp * (1. - qq) / (pp + 1.); + t = 0.2; + + debugPrintf( + "qbeta(%g, %g, %g, lower_t=%d, log_p=%d):%s\n" + + " swap_tail=%d, la=%g, u0=%g (bnd: %g (%g)) ", + alpha, p, q, lower_tail, log_p, + (log_p && (p_ == 0. || p_ == 1.)) ? (p_ == 0. ? " p_=0" : " p_=1") : "", + swap_tail, la, u0, + (t * log_eps_c - Math.log(Math.abs(pp * (1. - qq) * (2. - qq) / (2. * (pp + 2.))))) / 2., + t * log_eps_c - Math.log(Math.abs(r))); + + tx = 0.; + if (M_LN2 * DBL_MIN_EXP < u0 && // cannot allow exp(u0) = 0 ==> exp(u1) = exp(u0) = 0 + u0 < -0.01 && // (must: u0 < 0, but too close to 0 <==> x = exp(u0) = + // 0.99..) + // qq <= 2 && // <--- "arbitrary" + // u0 < t*log_eps_c - log(fabs(r)) && + u0 < (t * log_eps_c - Math.log(Math.abs(pp * (1. - qq) * (2. - qq) / (2. * (pp + 2.))))) / 2.) { + // TODO: maybe jump here from below, when initial u "fails" ? + // L_tail_u: + // MM's one-step correction (cheaper than 1 Newton!) + r = r * Math.exp(u0); // = r*x0 + if (r > -1.) { + u = u0 - RMath.log1p(r) / pp; + debugPrintf("u1-u0=%9.3g --> choosing u = u1\n", u - u0); + } else { + u = u0; + debugPrintf("cannot cheaply improve u0\n"); + } + tx = xinbta = Math.exp(u); + use_log_x = true; // or (u < log_q_cut) ?? + newton(n_N, log_p, qb); + return; + } + + // y := y_\alpha in AS 64 := Hastings(1955) approximation of qnorm(1 - a) : + r = Math.sqrt(-2 * la); + y = r - (const1 + const2 * r) / (1. + (const3 + const4 * r) * r); + + if (pp > 1 && qq > 1) { // use Carter(1947), see AS 109, remark '5.' + r = (y * y - 3.) / 6.; + s = 1. / (pp + pp - 1.); + t = 1. / (qq + qq - 1.); + h = 2. / (s + t); + w = y * Math.sqrt(h + r) / h - (t - s) * (r + 5. / 6. - 2. / (3. * h)); + debugPrintf("p,q > 1 => w=%g", w); + if (w > 300) { // Math.exp(w+w) is huge or overflows + t = w + w + Math.log(qq) - Math.log(pp); // = argument of log1pMath.exp(.) + u = // Math.log(xinbta) = - log1p(qq/pp * Math.exp(w+w)) = -Math.log(1 + + // Math.exp(t)) + (t <= 18) ? -RMath.log1p(Math.exp(t)) : -t - Math.exp(-t); + xinbta = Math.exp(u); + } else { + xinbta = pp / (pp + qq * Math.exp(w + w)); + u = // Math.log(xinbta) + -RMath.log1p(qq / pp * Math.exp(w + w)); + } + } else { // use the original AS 64 proposal, Scheffé-Tukey (1944) and Wilson-Hilferty + r = qq + qq; + /* + * A slightly more stable version of t := \chi^2_{alpha} of AS 64 t = 1. / (9. * + * qq); t = r * R_pow_di(1. - t + y * Math.sqrt(t), 3); + */ + t = 1. / (3. * Math.sqrt(qq)); + t = r * powDi(1. + t * (-t + y), 3); // = \chi^2_{alpha} of AS 64 + s = 4. * pp + r - 2.; // 4p + 2q - 2 = numerator of new t = (...) / chi^2 + debugPrintf("min(p,q) <= 1: t=%g", t); + if (t == 0 || (t < 0. && s >= t)) { // cannot use chisq approx + // x0 = 1 - { (1-a)*q*B(p,q) } ^{1/q} {AS 65} + // xinbta = 1. - Math.exp((Math.log(1-a)+ Math.log(qq) + logbeta) / qq); + double l1ma; /* + * := Math.log(1-a), directly from alpha (as 'la' above): FIXME: + * not worth it? log1p(-a) always the same ?? + */ + if (swap_tail) { + l1ma = DPQ.rdtlog(alpha, lower_tail, log_p); + } else { + l1ma = DPQ.rdtclog(alpha, lower_tail, log_p); + } + debugPrintf(" t <= 0 : log1p(-a)=%.15g, better l1ma=%.15g\n", RMath.log1p(-a), l1ma); + double xx = (l1ma + Math.log(qq) + logbeta) / qq; + if (xx <= 0.) { + xinbta = -RMath.expm1(xx); + u = DPQ.rlog1exp(xx); // = Math.log(xinbta) = Math.log(1 - + // Math.exp(...A...)) + } else { // xx > 0 ==> 1 - e^xx < 0 .. is nonsense + debugPrintf(" xx=%g > 0: xinbta:= 1-e^xx < 0\n", xx); + xinbta = 0; + u = Double.NEGATIVE_INFINITY; /// FIXME can do better? + } + } else { + t = s / t; + debugPrintf(" t > 0 or s < t < 0: new t = %g ( > 1 ?)\n", t); + if (t <= 1.) { // cannot use chisq, either + u = (la + Math.log(pp) + logbeta) / pp; + xinbta = Math.exp(u); + } else { // (1+x0)/(1-x0) = t, solved for x0 : + xinbta = 1. - 2. / (t + 1.); + u = RMath.log1p(-2. / (t + 1.)); + } + } + } + + // Problem: If initial u is completely wrong, we make a wrong decision here + if (swap_choose && + ((swap_tail && u >= -Math.exp(log_q_cut)) || // ==> "swap back" + (!swap_tail && u >= -Math.exp(4 * log_q_cut) && pp / qq < 1000.))) { // ==> + // "swap + // now" + // (much + // less + // easily) + // "revert swap" -- and use_log_x + swap_tail = !swap_tail; + debugPrintf(" u = %g (e^u = xinbta = %.16g) ==> ", u, xinbta); + if (swap_tail) { + a = DPQ.rdtciv(alpha, lower_tail, log_p); // needed ? + la = DPQ.rdtclog(alpha, lower_tail, log_p); + pp = q; + qq = p; + } else { + a = p_; + la = DPQ.rdtlog(alpha, lower_tail, log_p); + pp = p; + qq = q; + } + debugPrintf("\"%s\"; la = %g\n", + (swap_tail ? "swap now" : "swap back"), la); + // we could redo computations above, but this should be stable + u = DPQ.rlog1exp(u); + xinbta = Math.exp(u); + + /* + * Careful: "swap now" should not fail if 1) the above initial xinbta is + * "completely wrong" 2) The correction step can go outside (u_n > 0 ==> e^u > 1 is + * illegal) e.g., for qbeta(0.2066, 0.143891, 0.05) + */ + } + + if (!use_log_x) { + use_log_x = (u < log_q_cut); // (per default) <==> xinbta = e^u < 4.54e-5 + } + bad_u = !Double.isFinite(u); + bad_init = bad_u || xinbta > p_hi; + + debugPrintf(" -> u = %g, e^u = xinbta = %.16g, (Newton acu=%g%s)\n", + u, xinbta, acu, + (bad_u ? ", ** bad u **" : (use_log_x ? ", on u = Math.log(x) scale" : ""))); + + u_n = 1.; + tx = xinbta; // keeping "original initial x" (for now) + + if (bad_u || u < log_q_cut) { /* + * e.g. qbeta(0.21, .001, 0.05) try "left border" quickly, + * i.e., try at smallest positive number: + */ + w = pbetaRaw(DBL_very_MIN, pp, qq, true, log_p); + if (w > (log_p ? la : a)) { + debugPrintf(" quantile is left of smallest positive number; \"convergence\"\n"); + if (log_p || Math.abs(w - a) < Math.abs(0 - a)) { // DBL_very_MIN is better than + // 0 + tx = DBL_very_MIN; + u_n = DBL_log_v_MIN; // = Math.log(DBL_very_MIN) + } else { + tx = 0.; + u_n = Double.NEGATIVE_INFINITY; + } + use_log_x = log_p; + add_N_step = false; + finalStep(log_p, qb); + return; + } else { + debugPrintf(" pbeta(smallest pos.) = %g <= %g --> continuing\n", + w, (log_p ? la : a)); + if (u < DBL_log_v_MIN) { + u = DBL_log_v_MIN; // = Math.log(DBL_very_MIN) + xinbta = DBL_very_MIN; + } + } + } + + /* Sometimes the approximation is negative (and == 0 is also not "ok") */ + if (bad_init && !(use_log_x && tx > 0)) { + if (u == Double.NEGATIVE_INFINITY) { + debugPrintf(" u = -Inf;"); + u = M_LN2 * DBL_MIN_EXP; + xinbta = Double.MIN_VALUE; + } else { + debugPrintf(" bad_init: u=%g, xinbta=%g;", u, xinbta); + xinbta = (xinbta > 1.1) // i.e. "way off" + ? 0.5 // otherwise, keep the respective boundary: + : ((xinbta < p_lo) ? Math.exp(u) : p_hi); + if (bad_u) { + u = Math.log(xinbta); + } + // otherwise: not changing "potentially better" u than the above + } + debugPrintf(" -> (partly)new u=%g, xinbta=%g\n", u, xinbta); + } + + newton(n_N, log_p, qb); + // note: newton calls converged which calls finalStep + } + + private void newton(int n_N, boolean log_p, double[] qb) { + /* + * -------------------------------------------------------------------- + * + * Solve for x by a modified Newton-Raphson method, using pbeta_raw() + */ + r = 1 - pp; + t = 1 - qq; + double wprev = 0.; + double prev = 1.; + double adj = 1.; + + if (use_log_x) { // find Math.log(xinbta) -- work in u := Math.log(x) scale + // if (bad_init && tx > 0) { xinbta = tx; }// may have been better + for (int i_pb = 0; i_pb < 1000; i_pb++) { + // using log_p == true unconditionally here + // FIXME: if Math.exp(u) = xinbta underflows to 0, like different formula + // pbeta_Math.log(u, *) + y = pbetaRaw(xinbta, pp, qq, /* lower_tail = */ true, true); + + /* + * w := Newton step size for L(u) = log F(e^u) =!= 0; u := Math.log(x) = (L(.) - + * la) / L'(.); L'(u)= (F'(e^u) * e^u ) / F(e^u) = (L(.) - la)*F(.) / {F'(e^u) * + * e^u } = = (L(.) - la) * e^L(.) * e^{-log F'(e^u) - u} = ( y - la) * e^{ y - u + * -log F'(e^u)} and -log F'(x)= -log f(x) = + logbeta + (1-p) Math.log(x) + + * (1-q) Math.log(1-x) = logbeta + (1-p) u + (1-q) Math.log(1-e^u) + */ + w = (y == Double.NEGATIVE_INFINITY) // y = -Inf well possible: we are on + // log scale! + ? 0. : (y - la) * Math.exp(y - u + logbeta + r * u + t * DPQ.rlog1exp(u)); + if (!Double.isFinite(w)) { + break; + } + if (i_pb >= n_N && w * wprev <= 0.) { + prev = RMath.fmax2(Math.abs(adj), fpu); + } + debugPrintf("N(i=%2d): u=%#20.16g, pb(e^u)=%#12.6g, w=%#15.9g, %s prev=%11g,", + i_pb, u, y, w, (w * wprev <= 0.) ? "new" : "old", prev); + g = 1; + int i_inn; + for (i_inn = 0; i_inn < 1000; i_inn++) { + adj = g * w; + // take full Newton steps at the beginning; only then safe guard: + if (i_pb < n_N || Math.abs(adj) < prev) { + u_n = u - adj; // u_{n+1} = u_n - g*w + if (u_n <= 0.) { // <==> 0 < xinbta := e^u <= 1 + if (prev <= acu || Math.abs(w) <= acu) { + /* R_ifDEBUG_printf(" -adj=%g, %s <= acu ==> convergence\n", */ + /* -adj, (prev <= acu) ? "prev" : "|w|"); */ + debugPrintf(" it{in}=%d, -adj=%g, %s <= acu ==> convergence\n", + i_inn, -adj, (prev <= acu) ? "prev" : "|w|"); + converged(log_p, qb); + return; + } + // if (u_n != Double.NEGATIVE_INFINITY && u_n != 1) + break; + } + } + g /= 3; + } + // (cancellation in (u_n -u) => may differ from adj: + D = RMath.fmin2(Math.abs(adj), Math.abs(u_n - u)); + /* R_ifDEBUG_printf(" delta(u)=%g\n", u_n - u); */ + debugPrintf(" it{in}=%d, delta(u)=%9.3g, D/|.|=%.3g\n", + i_inn, u_n - u, D / Math.abs(u_n + u)); + if (D <= 4e-16 * Math.abs(u_n + u)) { + converged(log_p, qb); + return; + } + u = u_n; + xinbta = Math.exp(u); + wprev = w; + } // for(i ) + + } else { + for (int i_pb = 0; i_pb < 1000; i_pb++) { + y = pbetaRaw(xinbta, pp, qq, /* lower_tail = */ true, log_p); + // delta{y} : d_y = y - (log_p ? la : a); + + if (!Double.isFinite(y) && !(log_p && y == Double.NEGATIVE_INFINITY)) { // y = + // -Inf + // is ok if + // (log_p) + RMath.mlError(MLError.DOMAIN, ""); + qb[0] = qb[1] = ML_NAN; + return; + } + + /* + * w := Newton step size (F(.) - a) / F'(.) or, -- log: (lF - la) / (F' / F) = + * Math.exp(lF) * (lF - la) / F' + */ + w = log_p + ? (y - la) * Math.exp(y + logbeta + r * Math.log(xinbta) + t * Math.log1p(-xinbta)) + : (y - a) * Math.exp(logbeta + r * Math.log(xinbta) + t * Math.log1p(-xinbta)); + if (i_pb >= n_N && w * wprev <= 0.) + prev = RMath.fmax2(Math.abs(adj), fpu); + debugPrintf("N(i=%2d): x0=%#17.15g, pb(x0)=%#17.15g, w=%#17.15g, %s prev=%g,", + i_pb, xinbta, y, w, (w * wprev <= 0.) ? "new" : "old", prev); + g = 1; + int i_inn; + for (i_inn = 0; i_inn < 1000; i_inn++) { + adj = g * w; + // take full Newton steps at the beginning; only then safe guard: + if (i_pb < n_N || Math.abs(adj) < prev) { + tx = xinbta - adj; // x_{n+1} = x_n - g*w + if (0. <= tx && tx <= 1.) { + if (prev <= acu || Math.abs(w) <= acu) { + debugPrintf(" it{in}=%d, delta(x)=%g, %s <= acu ==> convergence\n", + i_inn, -adj, (prev <= acu) ? "prev" : "|w|"); + converged(log_p, qb); + return; + } + if (tx != 0. && tx != 1) { + break; + } + } + } + g /= 3; + } + debugPrintf(" it{in}=%d, delta(x)=%g\n", i_inn, tx - xinbta); + if (Math.abs(tx - xinbta) <= 4e-16 * (tx + xinbta)) { // "<=" : (.) == 0 + converged(log_p, qb); + return; + } + xinbta = tx; + if (tx == 0) { // "we have lost" + break; + } + wprev = w; + } + } + + /*-- NOT converged: Iteration count --*/ + warned = true; + RMath.mlError(MLError.PRECISION, "qbeta"); + + converged(log_p, qb); + } + + private void converged(boolean log_p, double[] qb) { + log_ = log_p || use_log_x; // only for printing + debugPrintf(" %s: Final delta(y) = %g%s\n", + warned ? "_NO_ convergence" : "converged", + y - (log_ ? la : a), (log_ ? " (log_)" : "")); + if ((log_ && y == Double.NEGATIVE_INFINITY) || (!log_ && y == 0)) { + // stuck at left, try if smallest positive number is "better" + w = pbetaRaw(DBL_very_MIN, pp, qq, true, log_); + if (log_ || Math.abs(w - a) <= Math.abs(y - a)) { + tx = DBL_very_MIN; + u_n = DBL_log_v_MIN; // = Math.log(DBL_very_MIN) + } + add_N_step = false; // not trying to do better anymore + } else if (!warned && (log_ ? Math.abs(y - la) > 3 : Math.abs(y - a) > 1e-4)) { + if (!(log_ && y == Double.NEGATIVE_INFINITY && + // e.g. qbeta(-1e-10, .2, .03, log=true) cannot get accurate ==> do + // NOT + // warn + pbetaRaw(DBL_1__eps, // = 1 - eps + pp, qq, true, true) > la + 2)) { + RMath.mlWarning(Message.QBETA_ACURACY_WARNING, (log_ ? ", log_" : ""), Math.abs(y - (log_ ? la : a))); + } + } + + finalStep(log_p, qb); + } + + /** + * Represents a block of code that is labelled "L_return" in the original source, should be + * followed by a return. + */ + private void finalStep(boolean log_p, double[] qb) { + if (give_log_q) { // ==> use_log_x , too + if (!use_log_x) { // (see if claim above is true) + RMath.mlWarning(Message.GENERIC, + "qbeta() L_return, u_n=%g; give_log_q=true but use_log_x=false -- please report!", + u_n); + } + + double rr = DPQ.rlog1exp(u_n); + swapTail(qb, swap_tail, u_n, rr); + } else { + if (use_log_x) { + if (add_N_step) { + /* + * add one last Newton step on original x scale, e.g., for qbeta(2^-98, + * 0.125, 2^-96) + */ + double tmpXinbta = Math.exp(u_n); + y = pbetaRaw(tmpXinbta, pp, qq, /* lower_tail = */ true, log_p); + w = log_p + ? (y - la) * Math.exp(y + logbeta + r * Math.log(tmpXinbta) + t * RMath.log1p(-tmpXinbta)) + : (y - a) * Math.exp(logbeta + r * Math.log(tmpXinbta) + t * RMath.log1p(-tmpXinbta)); + tx = tmpXinbta - w; + debugPrintf( + "Final Newton correction(non-log scale): xinbta=%.16g, y=%g, w=%g. => new tx=%.16g\n", + tmpXinbta, y, w, tx); + } else { + swapTail(qb, swap_tail, Math.exp(u_n), -RMath.expm1(u_n)); + return; + } + } + swapTail(qb, swap_tail, tx, 1 - tx); + } + } + + private static void swapTail(double[] qb, boolean swap_tail, double val0, double val1) { + if (swap_tail) { + qb[0] = val1; + qb[1] = val0; + } else { + qb[0] = val0; + qb[1] = val1; + } + } + + private static void returnQ0(double[] qb, boolean give_log_q) { + qb[0] = DPQ.rd0(give_log_q); + qb[1] = DPQ.rd1(give_log_q); + } + + private static void returnQ1(double[] qb, boolean give_log_q) { + qb[0] = DPQ.rd1(give_log_q); + qb[1] = DPQ.rd0(give_log_q); + } + + private static void returnQHalf(double[] qb, boolean give_log_q) { + qb[0] = DPQ.rdhalf(give_log_q); + qb[1] = DPQ.rdhalf(give_log_q); + } + } +} diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/QPois.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/QPois.java new file mode 100644 index 0000000000000000000000000000000000000000..9803bad38d700b70793e0902bf7337a0729aa209 --- /dev/null +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/QPois.java @@ -0,0 +1,129 @@ +/* + * This material is distributed under the GNU General Public License + * Version 2. You may review the terms of this license at + * http://www.gnu.org/licenses/gpl-2.0.html + * + * Copyright (C) 1998 Ross Ihaka + * Copyright (c) 2000-2014, The R Core Team + * Copyright (c) 2016, Oracle and/or its affiliates + * + * All rights reserved. + */ +package com.oracle.truffle.r.library.stats; + +import static com.oracle.truffle.r.library.stats.MathConstants.DBL_EPSILON; + +import com.oracle.truffle.r.library.stats.DPQ.EarlyReturn; +import com.oracle.truffle.r.library.stats.StatsFunctions.Function2_2; + +public class QPois implements Function2_2 { + private final Qnorm qnorm = new Qnorm(); + private final PPois ppois = new PPois(); + + @Override + public double evaluate(double p, double lambda, boolean lowerTail, boolean logP) { + if (Double.isNaN(p) || Double.isNaN(lambda)) { + return p + lambda; + } + if (!Double.isFinite(lambda)) { + return RMath.mlError(); + } + if (lambda < 0) { + return RMath.mlError(); + } + if (lambda == 0) { + return 0; + } + + try { + DPQ.rqp01boundaries(p, 0, Double.POSITIVE_INFINITY, lowerTail, logP); + } catch (EarlyReturn e) { + return e.result; + } + + double mu = lambda; + double sigma = Math.sqrt(lambda); + /* gamma = sigma; PR#8058 should be kurtosis which is mu^-0.5 */ + double gamma = 1.0 / sigma; + + /* + * Note : "same" code in qpois.c, qbinom.c, qnbinom.c -- FIXME: This is far from optimal + * [cancellation for p ~= 1, etc]: + */ + if (!lowerTail || logP) { + p = DPQ.rdtqiv(p, lowerTail, logP); /* need check again (cancellation!): */ + if (p == 0.) { + return 0; + } + if (p == 1.) { + return Double.POSITIVE_INFINITY; + } + } + /* temporary hack --- FIXME --- */ + if (p + 1.01 * DBL_EPSILON >= 1.) { + return Double.POSITIVE_INFINITY; + } + + /* y := approx.value (Cornish-Fisher expansion) : */ + double z = qnorm.evaluate(p, 0., 1., /* lower_tail */true, /* log_p */false); + // #ifdef HAVE_NEARBYINT + // y = nearbyint(mu + sigma * (z + gamma * (z*z - 1) / 6)); + // #else + double y = Math.round(mu + sigma * (z + gamma * (z * z - 1) / 6)); + + z = ppois.evaluate(y, lambda, /* lower_tail */true, /* log_p */false); + + /* fuzz to ensure left continuity; 1 - 1e-7 may lose too much : */ + p *= 1 - 64 * DBL_EPSILON; + + /* If the mean is not too large a simple search is OK */ + if (lambda < 1e5) { + return search(y, z, p, lambda, 1).y; + } else { + /* Otherwise be a bit cleverer in the search */ + double incr = Math.floor(y * 0.001); + double oldincr; + do { + oldincr = incr; + SearchResult searchResult = search(y, z, p, lambda, incr); + y = searchResult.y; + z = searchResult.z; + incr = RMath.fmax2(1, Math.floor(incr / 100)); + } while (oldincr > 1 && incr > lambda * 1e-15); + return y; + } + } + + private SearchResult search(double yIn, double zIn, double p, double lambda, double incr) { + if (zIn >= p) { + /* search to the left */ + double y = yIn; + for (;;) { + double z = zIn; + if (y == 0 || (z = ppois.evaluate(y - incr, lambda, /* l._t. */true, /* log_p */false)) < p) { + return new SearchResult(y, z); + } + y = RMath.fmax2(0, y - incr); + } + } else { /* search to the right */ + double y = yIn; + for (;;) { + y = y + incr; + double z = zIn; + if ((z = ppois.evaluate(y, lambda, /* l._t. */true, /* log_p */false)) >= p) { + return new SearchResult(y, z); + } + } + } + } + + private static final class SearchResult { + final double y; + final double z; + + SearchResult(double y, double z) { + this.y = y; + this.z = z; + } + } +} diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Qf.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Qf.java new file mode 100644 index 0000000000000000000000000000000000000000..18488ebd3a267a99aeab1e5b8e81f2bcfd9063b5 --- /dev/null +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Qf.java @@ -0,0 +1,60 @@ +/* + * This material is distributed under the GNU General Public License + * Version 2. You may review the terms of this license at + * http://www.gnu.org/licenses/gpl-2.0.html + * + * Copyright (C) 1998 Ross Ihaka + * Copyright (c) 2000--2015, The R Core Team + * Copyright (c) 2005, The R Foundation + * Copyright (c) 2016, Oracle and/or its affiliates + * + * All rights reserved. + */ +package com.oracle.truffle.r.library.stats; + +import com.oracle.truffle.r.library.stats.Chisq.QChisq; +import com.oracle.truffle.r.library.stats.DPQ.EarlyReturn; +import com.oracle.truffle.r.library.stats.StatsFunctions.Function3_2; + +public final class Qf implements Function3_2 { + private final QBeta qbeta = new QBeta(); + private final QChisq qchisq = new QChisq(); + + @Override + public double evaluate(double p, double df1, double df2, boolean lowerTail, boolean logP) { + + if (Double.isNaN(p) || Double.isNaN(df1) || Double.isNaN(df2)) { + return p + df1 + df2; + } + + if (df1 <= 0. || df2 <= 0.) { + return RMath.mlError(); + } + + try { + DPQ.rqp01boundaries(p, 0, Double.POSITIVE_INFINITY, lowerTail, logP); + } catch (EarlyReturn e) { + return e.result; + } + + /* + * fudge the extreme DF cases -- qbeta doesn't do this well. But we still need to fudge the + * infinite ones. + */ + + if (df1 <= df2 && df2 > 4e5) { + if (!Double.isFinite(df1)) { /* df1 == df2 == Inf : */ + return 1.; + } else { + return qchisq.evaluate(p, df1, lowerTail, logP) / df1; + } + } + if (df1 > 4e5) { /* and so df2 < df1 */ + return df2 / qchisq.evaluate(p, df2, !lowerTail, logP); + } + + // FIXME: (1/qb - 1) = (1 - qb)/qb; if we know qb ~= 1, should use other tail + p = (1. / qbeta.evaluate(p, df2 / 2, df1 / 2, !lowerTail, logP) - 1.) * (df2 / df1); + return RMath.mlValid(p) ? p : Double.NaN; + } +} diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Qt.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Qt.java new file mode 100644 index 0000000000000000000000000000000000000000..34877af66f383ec492baf37c72669d231e473044 --- /dev/null +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Qt.java @@ -0,0 +1,216 @@ +/* + * This material is distributed under the GNU General Public License + * Version 2. You may review the terms of this license at + * http://www.gnu.org/licenses/gpl-2.0.html + * + * Copyright (C) 1998 Ross Ihaka + * Copyright (c) 2000-2013, The R Core Team + * Copyright (c) 2003-2013, The R Foundation + * Copyright (c) 2016, Oracle and/or its affiliates + * + * All rights reserved. + */ +package com.oracle.truffle.r.library.stats; + +import static com.oracle.truffle.r.library.stats.MathConstants.DBL_EPSILON; +import static com.oracle.truffle.r.library.stats.MathConstants.DBL_MANT_DIG; +import static com.oracle.truffle.r.library.stats.MathConstants.M_1_PI; +import static com.oracle.truffle.r.library.stats.MathConstants.M_LN2; +import static com.oracle.truffle.r.library.stats.MathConstants.M_PI; +import static com.oracle.truffle.r.library.stats.MathConstants.M_PI_2; +import static com.oracle.truffle.r.library.stats.MathConstants.M_SQRT2; + +import com.oracle.truffle.r.library.stats.DPQ.EarlyReturn; +import com.oracle.truffle.r.library.stats.StatsFunctions.Function2_2; + +public class Qt implements Function2_2 { + private static final double eps = 1.e-12; + private static final double accu = 1e-13; + private static final double Eps = 1e-11; /* must be > accu */ + + private final Qnorm qnorm = new Qnorm(); + private final Dt dt = new Dt(); + private final Pt pt = new Pt(); + + @Override + public double evaluate(double p, double ndf, boolean lowerTail, boolean logP) { + + if (Double.isNaN(p) || Double.isNaN(ndf)) { + return p + ndf; + } + + try { + DPQ.rqp01boundaries(p, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, lowerTail, logP); + } catch (EarlyReturn earlyReturn) { + return earlyReturn.result; + } + + if (ndf <= 0) { + return RMath.mlError(); + } + + if (ndf < 1) { /* based on qnt */ + + int iter = 0; + + p = DPQ.rdtqiv(p, lowerTail, logP); + + /* + * Invert pt(.) : 1. finding an upper and lower bound + */ + if (p > 1 - DBL_EPSILON) { + return Double.POSITIVE_INFINITY; + } + double pp = RMath.fmin2(1 - DBL_EPSILON, p * (1 + Eps)); + double ux; + double lx; + ux = 1.; + while (ux < Double.MAX_VALUE && pt.evaluate(ux, ndf, true, false) < pp) { + ux *= 2; + } + pp = p * (1 - Eps); + lx = -1.; + while (lx > -Double.MAX_VALUE && pt.evaluate(lx, ndf, true, false) > pp) { + lx *= 2; + } + + /* + * 2. interval (lx,ux) halving regula falsi failed on qt(0.1, 0.1) + */ + double nx; + do { + nx = 0.5 * (lx + ux); + if (pt.evaluate(nx, ndf, true, false) > p) { + ux = nx; + } else { + lx = nx; + } + } while ((ux - lx) / Math.abs(nx) > accu && ++iter < 1000); + + if (iter >= 1000) { + return RMath.mlError(); + } + + return 0.5 * (lx + ux); + } + + if (ndf > 1e20) { + return qnorm.evaluate(p, 0., 1., lowerTail, logP); + } + + double capP = DPQ.rdqiv(p, logP); /* if Math.exp(p) underflows, we fix below */ + + boolean neg = (!lowerTail || capP < 0.5) && (lowerTail || capP > 0.5); + boolean isNegLower = (lowerTail == neg); /* both true or false == !xor */ + if (neg) { + capP = 2 * (logP ? (lowerTail ? capP : -RMath.expm1(p)) : DPQ.rdlval(p, lowerTail)); + } else { + capP = 2 * (logP ? (lowerTail ? -RMath.expm1(p) : capP) : DPQ.rdcval(p, lowerTail)); + } + /* 0 <= P <= 1 ; P = 2*min(P', 1 - P') in all cases */ + + double q; + if (Math.abs(ndf - 2) < eps) { /* df ~= 2 */ + if (capP > Double.MIN_VALUE) { + if (3 * capP < DBL_EPSILON) { /* P ~= 0 */ + q = 1 / Math.sqrt(capP); + } else if (capP > 0.9) { /* P ~= 1 */ + q = (1 - capP) * Math.sqrt(2 / (capP * (2 - capP))); + } else { /* eps/3 <= P <= 0.9 */ + q = Math.sqrt(2 / (capP * (2 - capP)) - 2); + } + } else { /* P << 1, q = 1/Math.sqrt(P) = ... */ + if (logP) { + q = isNegLower ? Math.exp(-p / 2) / M_SQRT2 : 1 / Math.sqrt(-RMath.expm1(p)); + } else { + q = Double.POSITIVE_INFINITY; + } + } + } else if (ndf < 1 + eps) { /* df ~= 1 (df < 1 excluded above): Cauchy */ + if (capP == 1.) { + q = 0; + } else if (capP > 0) { + // some versions of tanpi give Inf, some NaN + q = 1 / RMath.tanpi(capP / 2.); /* == - tan((P+1) * M_PI_2) -- suffers for P ~= 0 */ + } else { /* P = 0, but maybe = 2*Math.exp(p) ! */ + if (logP) { /* 1/tan(e) ~ 1/e */ + q = isNegLower ? M_1_PI * Math.exp(-p) : -1. / (M_PI * RMath.expm1(p)); + } else { + q = Double.POSITIVE_INFINITY; + } + } + } else { /*-- usual case; including, e.g., df = 1.1 */ + double x = 0.; + double y = 0; + double logP2 = 0.; + double a = 1 / (ndf - 0.5); + double b = 48 / (a * a); + double c = ((20700 * a / b - 98) * a - 16) * a + 96.36; + double d = ((94.5 / (b + c) - 3) / b + 1) * Math.sqrt(a * M_PI_2) * ndf; + + boolean pOk1 = capP > Double.MIN_VALUE || !logP; + boolean pOk = pOk1; + if (pOk1) { + y = Math.pow(d * capP, 2.0 / ndf); + pOk = (y >= DBL_EPSILON); + } + if (!pOk) { // log.p && P very.small || (d*P)^(2/df) =: y < eps_c + logP2 = isNegLower ? DPQ.rdlog(p, logP) : DPQ.rdlexp(p, logP); /* + * == Math.log(P / 2) + */ + x = (Math.log(d) + M_LN2 + logP2) / ndf; + y = Math.exp(2 * x); + } + + if ((ndf < 2.1 && capP > 0.5) || y > 0.05 + a) { /* P > P0(df) */ + /* Asymptotic inverse expansion about normal */ + if (pOk) { + x = qnorm.evaluate(0.5 * capP, 0., 1., /* lower_tail */true, /* log_p */false); + } else { /* log_p && P underflowed */ + x = qnorm.evaluate(logP2, 0., 1., lowerTail, /* log_p */ true); + } + + y = x * x; + if (ndf < 5) { + c += 0.3 * (ndf - 4.5) * (x + 0.6); + } + c = (((0.05 * d * x - 5) * x - 7) * x - 2) * x + b + c; + y = (((((0.4 * y + 6.3) * y + 36) * y + 94.5) / c - y - 3) / b + 1) * x; + y = RMath.expm1(a * y * y); + q = Math.sqrt(ndf * y); + } else if (!pOk && x < -M_LN2 * DBL_MANT_DIG) { /* 0.5* Math.log(DBL_EPSILON) */ + /* y above might have underflown */ + q = Math.sqrt(ndf) * Math.exp(-x); + } else { /* re-use 'y' from above */ + y = ((1 / (((ndf + 6) / (ndf * y) - 0.089 * d - 0.822) * (ndf + 2) * 3) + 0.5 / (ndf + 4)) * y - 1) * (ndf + 1) / (ndf + 2) + 1 / y; + q = Math.sqrt(ndf * y); + } + + /* + * Now apply 2-term Taylor expansion improvement (1-term = Newton): as by Hill (1981) + * [ref.above] + */ + + /* + * FIXME: This can be far from optimal when log_p = true but is still needed, e.g. for + * qt(-2, df=1.01, log=true). Probably also improvable when lower_tail = false + */ + + if (pOk1) { + int it = 0; + while (it++ < 10 && (y = dt.evaluate(q, ndf, false)) > 0 && + Double.isFinite(x = (pt.evaluate(q, ndf, false, false) - capP / 2) / y) && + Math.abs(x) > 1e-14 * Math.abs(q)) { + /* + * Newton (=Taylor 1 term): q += x; Taylor 2-term : + */ + q += x * (1. + x * q * (ndf + 1) / (2 * (q * q + ndf))); + } + } + } + if (neg) { + q = -q; + } + return q; + } +} diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RChisq.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RChisq.java deleted file mode 100644 index 975819f6bf3be065b8036f7c4c4aeb2b512db474..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RChisq.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * This material is distributed under the GNU General Public License - * Version 2. You may review the terms of this license at - * http://www.gnu.org/licenses/gpl-2.0.html - * - * Copyright (C) 1998 Ross Ihaka - * Copyright (c) 1998--2008, The R Core Team - * Copyright (c) 2016, 2016, Oracle and/or its affiliates - * - * All rights reserved. - */ -package com.oracle.truffle.r.library.stats; - -import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandFunction1_Double; -import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandomNumberProvider; - -public final class RChisq extends RandFunction1_Double { - public static double rchisq(double df, RandomNumberProvider rand) { - if (!Double.isFinite(df) || df < 0.0) { - return RMath.mlError(); - } - return new RGamma().execute(df / 2.0, 2.0, rand); - } - - @Override - public double execute(double a, RandomNumberProvider rand) { - return rchisq(a, rand); - } -} diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RMath.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RMath.java index 49fc18d2d6df471eb0afffc46633af0776b25037..644dff67b50c3d46d7608bb10c5401f973a6d665 100644 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RMath.java +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RMath.java @@ -16,6 +16,7 @@ import static com.oracle.truffle.r.library.stats.LBeta.lbeta; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RRuntime; /** @@ -26,13 +27,36 @@ import com.oracle.truffle.r.runtime.RRuntime; */ public class RMath { + public enum MLError { + DOMAIN, + RANGE, + NOCONV, + PRECISION, + UNDERFLOW + } + /** - * corresponds to macro {@code ML_ERR_return_NAN} in GnuR. + * Corresponds to macro {@code ML_ERR_return_NAN} in GnuR. */ public static double mlError() { + return mlError(MLError.DOMAIN, ""); + } + + /** + * Corresponds to macro {@code ML_ERR} in GnuR. TODO: raise corresponding warning + */ + public static double mlError(@SuppressWarnings("unused") MLError error, @SuppressWarnings("unused") String message) { return Double.NaN; } + public static void mlWarning(RError.Message message, Object... args) { + RError.warning(null, message, args); + } + + public static boolean mlValid(double d) { + return !Double.isNaN(d); + } + public static double lfastchoose(double n, double k) { return -Math.log(n + 1.) - lbeta(n - k + 1., k + 1.); } @@ -56,7 +80,7 @@ public class RMath { return ((y >= 0) ? TOMS708.fabs(x) : -TOMS708.fabs(x)); } - public static double fmod(double a, double b) { + private static double fmod(double a, double b) { double q = a / b; if (b != 0) { double tmp = a - Math.floor(q) * b; diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RNchisq.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RNchisq.java index 3b17100cc5cad25ce2b30d84993069af020931fc..12dc037c2c18aae629e67fe502c97dfe86cb35e3 100644 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RNchisq.java +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RNchisq.java @@ -30,7 +30,7 @@ public final class RNchisq extends RandFunction2_Double { } else { double r = RPois.rpois(lambda / 2., rand); if (r > 0.) { - r = RChisq.rchisq(2. * r, rand); + r = Chisq.RChisq.rchisq(2. * r, rand); } if (df > 0.) { r += rgamma.execute(df / 2., 2., rand); diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Rf.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Rf.java index c753f1777fe6e31adb429f4ae2779b1d951bea3c..be70cde936be8c393b14a9743bdce13d68366585 100644 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Rf.java +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Rf.java @@ -23,8 +23,8 @@ public final class Rf extends RandFunction2_Double { double v1; double v2; - v1 = Double.isFinite(n1) ? (RChisq.rchisq(n1, rand) / n1) : 1; - v2 = Double.isFinite(n2) ? (RChisq.rchisq(n2, rand) / n2) : 1; + v1 = Double.isFinite(n1) ? (Chisq.RChisq.rchisq(n1, rand) / n1) : 1; + v2 = Double.isFinite(n2) ? (Chisq.RChisq.rchisq(n2, rand) / n2) : 1; return v1 / v2; } } diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Rt.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Rt.java index 80c8ea59fc6e6b06560ceac696d508d192bb1d59..a319beed65cf78521fccb36b2b81070fbce797e3 100644 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Rt.java +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Rt.java @@ -11,7 +11,7 @@ */ package com.oracle.truffle.r.library.stats; -import static com.oracle.truffle.r.library.stats.RChisq.rchisq; +import static com.oracle.truffle.r.library.stats.Chisq.RChisq.rchisq; import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandFunction1_Double; import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandomNumberProvider; diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Runif.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Runif.java deleted file mode 100644 index d5729f4a3bd45aa8ad117e0f5ed3a2d3ef066886..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Runif.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.library.stats; - -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.profiles.ConditionProfile; -import com.oracle.truffle.api.profiles.ValueProfile; -import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandFunction2_Double; -import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandomNumberProvider; -import com.oracle.truffle.r.runtime.RRuntime; - -public final class Runif extends RandFunction2_Double { - private final BranchProfile errorProfile = BranchProfile.create(); - private final ConditionProfile minEqualsMaxProfile = ConditionProfile.createBinaryProfile(); - private final ValueProfile minValueProfile = ValueProfile.createEqualityProfile(); - private final ValueProfile maxValueProfile = ValueProfile.createEqualityProfile(); - - @Override - public double execute(double minIn, double maxIn, RandomNumberProvider rand) { - double min = minValueProfile.profile(minIn); - double max = maxValueProfile.profile(maxIn); - if (!RRuntime.isFinite(min) || !RRuntime.isFinite(max) || max < min) { - errorProfile.enter(); - return RMath.mlError(); - } - if (minEqualsMaxProfile.profile(min == max)) { - return min; - } - return min + rand.unifRand() * (max - min); - } -} diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Unif.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Unif.java new file mode 100644 index 0000000000000000000000000000000000000000..3110d7e227f8d096abbb6f4c72433963c0602524 --- /dev/null +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Unif.java @@ -0,0 +1,114 @@ +/* + * This material is distributed under the GNU General Public License + * Version 2. You may review the terms of this license at + * http://www.gnu.org/licenses/gpl-2.0.html + * + * Copyright (C) 1998 Ross Ihaka + * Copyright (c) 2000-2006, The R Core Team + * Copyright (c) 2013, 2016, Oracle and/or its affiliates + * + * All rights reserved. + */ +package com.oracle.truffle.r.library.stats; + +import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.ValueProfile; +import com.oracle.truffle.r.library.stats.DPQ.EarlyReturn; +import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandFunction2_Double; +import com.oracle.truffle.r.library.stats.RandGenerationFunctions.RandomNumberProvider; +import com.oracle.truffle.r.library.stats.StatsFunctions.Function3_1; +import com.oracle.truffle.r.library.stats.StatsFunctions.Function3_2; +import com.oracle.truffle.r.runtime.RRuntime; + +public final class Unif { + private Unif() { + // only static members + } + + public static final class Runif extends RandFunction2_Double { + private final BranchProfile errorProfile = BranchProfile.create(); + private final ConditionProfile minEqualsMaxProfile = ConditionProfile.createBinaryProfile(); + private final ValueProfile minValueProfile = ValueProfile.createEqualityProfile(); + private final ValueProfile maxValueProfile = ValueProfile.createEqualityProfile(); + + @Override + public double execute(double minIn, double maxIn, RandomNumberProvider rand) { + double min = minValueProfile.profile(minIn); + double max = maxValueProfile.profile(maxIn); + if (!RRuntime.isFinite(min) || !RRuntime.isFinite(max) || max < min) { + errorProfile.enter(); + return RMath.mlError(); + } + if (minEqualsMaxProfile.profile(min == max)) { + return min; + } + return min + rand.unifRand() * (max - min); + } + } + + public static final class PUnif implements Function3_2 { + @Override + public double evaluate(double x, double min, double max, boolean lowerTail, boolean logP) { + if (Double.isNaN(x) || Double.isNaN(min) || Double.isNaN(max)) { + return x + min + max; + } + if (max < min || !Double.isFinite(min) || !Double.isFinite(max)) { + return RMath.mlError(); + } + if (x >= max) { + return DPQ.rdt1(lowerTail, logP); + } + if (x <= min) { + return DPQ.rdt0(lowerTail, logP); + } + if (lowerTail) { + return DPQ.rdval((x - min) / (max - min), logP); + } else { + return DPQ.rdval((max - x) / (max - min), logP); + } + } + } + + public static final class DUnif implements Function3_1 { + @Override + public double evaluate(double x, double min, double max, boolean giveLog) { + if (Double.isNaN(x) || Double.isNaN(min) || Double.isNaN(max)) { + return x + min + max; + } + if (max <= min) { + return RMath.mlError(); + } + if (min <= x && x <= max) { + return giveLog ? -Math.log(max - min) : 1. / (max - min); + } + return DPQ.rd0(giveLog); + } + } + + public static final class QUnif implements Function3_2 { + + @Override + public double evaluate(double p, double min, double max, boolean lowerTail, boolean logP) { + if (Double.isNaN(p) || Double.isNaN(min) || Double.isNaN(max)) { + return p + min + max; + } + + try { + DPQ.rqp01check(p, logP); + } catch (EarlyReturn e) { + return e.result; + } + + if (max < min || !Double.isFinite(min) || !Double.isFinite(max)) { + return RMath.mlError(); + } + + if (max == min) { + return min; + } + + return min + DPQ.rdtqiv(p, lowerTail, logP) * (max - min); + } + } +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ConditionFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ConditionFunctions.java index 3957c5a02abfa8b64f6d1b8adc046841f4d07523..14d191a2e99094dd2e9296e8e1f546ed7a5c982d 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ConditionFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ConditionFunctions.java @@ -21,9 +21,14 @@ import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.INTERNAL; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.FrameSlot; +import com.oracle.truffle.api.frame.FrameSlotTypeException; +import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; +import com.oracle.truffle.r.nodes.function.FunctionDefinitionNode; import com.oracle.truffle.r.nodes.function.PromiseHelperNode; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RErrorHandling; @@ -67,15 +72,31 @@ public class ConditionFunctions { return getHandlerStack(); } + protected FrameSlot createHandlerFrameSlot(VirtualFrame frame) { + return ((FunctionDefinitionNode) getRootNode()).getHandlerFrameSlot(frame); + } + @Specialization - @TruffleBoundary - protected Object addCondHands(RAbstractStringVector classes, RList handlers, REnvironment parentEnv, Object target, byte calling) { + protected Object addCondHands(VirtualFrame frame, RAbstractStringVector classes, RList handlers, REnvironment parentEnv, Object target, byte calling, + @Cached("createHandlerFrameSlot(frame)") FrameSlot handlerFrameSlot) { if (classes.getLength() != handlers.getLength()) { + CompilerDirectives.transferToInterpreter(); throw RError.error(this, RError.Message.BAD_HANDLER_DATA); } - return RErrorHandling.createHandlers(classes, handlers, parentEnv, target, calling); + try { + if (!frame.isObject(handlerFrameSlot) || frame.getObject(handlerFrameSlot) == null) { + frame.setObject(handlerFrameSlot, RErrorHandling.getHandlerStack()); + } + } catch (FrameSlotTypeException e) { + throw RInternalError.shouldNotReachHere(); + } + return createHandlers(classes, handlers, parentEnv, target, calling); } + @TruffleBoundary + private static Object createHandlers(RAbstractStringVector classes, RList handlers, REnvironment parentEnv, Object target, byte calling) { + return RErrorHandling.createHandlers(classes, handlers, parentEnv, target, calling); + } } @RBuiltin(name = ".resetCondHands", visibility = OFF, kind = INTERNAL, parameterNames = {"stack"}, behavior = COMPLEX) @@ -108,9 +129,21 @@ public class ConditionFunctions { restart(casts); } + protected FrameSlot createRestartFrameSlot(VirtualFrame frame) { + return ((FunctionDefinitionNode) getRootNode()).getRestartFrameSlot(frame); + } + @Specialization - protected Object addRestart(RList restart) { + protected Object addRestart(VirtualFrame frame, RList restart, + @Cached("createRestartFrameSlot(frame)") FrameSlot restartFrameSlot) { checkLength(restart); + try { + if (!frame.isObject(restartFrameSlot) || frame.getObject(restartFrameSlot) == null) { + frame.setObject(restartFrameSlot, RErrorHandling.getRestartStack()); + } + } catch (FrameSlotTypeException e) { + throw RInternalError.shouldNotReachHere(); + } RErrorHandling.addRestart(restart); return RNull.instance; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/foreign/CallAndExternalFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/foreign/CallAndExternalFunctions.java index 001e0440002ff3c513dbe4e066a3ec45cfaa76e5..af77f17ef2cb353ab1e94c2eabf828b99a15bb7a 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/foreign/CallAndExternalFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/foreign/CallAndExternalFunctions.java @@ -46,6 +46,7 @@ import com.oracle.truffle.r.library.stats.Cauchy.PCauchy; import com.oracle.truffle.r.library.stats.Cauchy.RCauchy; import com.oracle.truffle.r.library.stats.CdistNodeGen; import com.oracle.truffle.r.library.stats.Chisq; +import com.oracle.truffle.r.library.stats.Chisq.RChisq; import com.oracle.truffle.r.library.stats.CompleteCases; import com.oracle.truffle.r.library.stats.CovcorNodeGen; import com.oracle.truffle.r.library.stats.CutreeNodeGen; @@ -71,14 +72,19 @@ import com.oracle.truffle.r.library.stats.LogNormal.QLNorm; import com.oracle.truffle.r.library.stats.Logis; import com.oracle.truffle.r.library.stats.Logis.DLogis; import com.oracle.truffle.r.library.stats.Logis.RLogis; +import com.oracle.truffle.r.library.stats.PPois; import com.oracle.truffle.r.library.stats.Pbeta; import com.oracle.truffle.r.library.stats.Pbinom; import com.oracle.truffle.r.library.stats.Pf; import com.oracle.truffle.r.library.stats.Pnorm; +import com.oracle.truffle.r.library.stats.Pt; +import com.oracle.truffle.r.library.stats.QBeta; +import com.oracle.truffle.r.library.stats.QPois; import com.oracle.truffle.r.library.stats.Qbinom; +import com.oracle.truffle.r.library.stats.Qf; import com.oracle.truffle.r.library.stats.Qnorm; +import com.oracle.truffle.r.library.stats.Qt; import com.oracle.truffle.r.library.stats.RBeta; -import com.oracle.truffle.r.library.stats.RChisq; import com.oracle.truffle.r.library.stats.RGamma; import com.oracle.truffle.r.library.stats.RHyper; import com.oracle.truffle.r.library.stats.RMultinomNodeGen; @@ -94,11 +100,14 @@ import com.oracle.truffle.r.library.stats.Rbinom; import com.oracle.truffle.r.library.stats.Rf; import com.oracle.truffle.r.library.stats.Rnorm; import com.oracle.truffle.r.library.stats.Rt; -import com.oracle.truffle.r.library.stats.Runif; import com.oracle.truffle.r.library.stats.Signrank.RSignrank; import com.oracle.truffle.r.library.stats.SplineFunctionsFactory.SplineCoefNodeGen; import com.oracle.truffle.r.library.stats.SplineFunctionsFactory.SplineEvalNodeGen; import com.oracle.truffle.r.library.stats.StatsFunctionsFactory; +import com.oracle.truffle.r.library.stats.Unif.DUnif; +import com.oracle.truffle.r.library.stats.Unif.PUnif; +import com.oracle.truffle.r.library.stats.Unif.QUnif; +import com.oracle.truffle.r.library.stats.Unif.Runif; import com.oracle.truffle.r.library.stats.Wilcox.RWilcox; import com.oracle.truffle.r.library.tools.C_ParseRdNodeGen; import com.oracle.truffle.r.library.tools.DirChmodNodeGen; @@ -144,7 +153,7 @@ import com.oracle.truffle.r.runtime.ffi.RFFIFactory; public class CallAndExternalFunctions { @TruffleBoundary - protected static Object encodeArgumentPairList(RArgsValuesAndNames args, String symbolName) { + private static Object encodeArgumentPairList(RArgsValuesAndNames args, String symbolName) { Object list = RNull.instance; for (int i = args.getLength() - 1; i >= 0; i--) { String name = args.getSignature().getName(i); @@ -154,8 +163,8 @@ public class CallAndExternalFunctions { return list; } - protected abstract static class CallRFFIAdapter extends LookupAdapter { - @Child protected CallRFFI.CallRFFINode callRFFINode = RFFIFactory.getRFFI().getCallRFFI().createCallRFFINode(); + abstract static class CallRFFIAdapter extends LookupAdapter { + @Child CallRFFI.CallRFFINode callRFFINode = RFFIFactory.getRFFI().getCallRFFI().createCallRFFINode(); } /** @@ -288,18 +297,34 @@ public class CallAndExternalFunctions { return RandFunction1Node.createInt(new RSignrank()); case "rhyper": return RandFunction3Node.createInt(new RHyper()); + case "qt": + return StatsFunctionsFactory.Function2_2NodeGen.create(new Qt()); + case "pt": + return StatsFunctionsFactory.Function2_2NodeGen.create(new Pt()); case "qgamma": return StatsFunctionsFactory.Function3_2NodeGen.create(new QgammaFunc()); case "dbinom": return StatsFunctionsFactory.Function3_1NodeGen.create(new Dbinom()); case "qbinom": return StatsFunctionsFactory.Function3_2NodeGen.create(new Qbinom()); + case "punif": + return StatsFunctionsFactory.Function3_2NodeGen.create(new PUnif()); + case "dunif": + return StatsFunctionsFactory.Function3_1NodeGen.create(new DUnif()); + case "qunif": + return StatsFunctionsFactory.Function3_2NodeGen.create(new QUnif()); + case "ppois": + return StatsFunctionsFactory.Function2_2NodeGen.create(new PPois()); + case "qpois": + return StatsFunctionsFactory.Function2_2NodeGen.create(new QPois()); case "rbinom": return RandFunction2Node.createInt(new Rbinom()); case "pbinom": return StatsFunctionsFactory.Function3_2NodeGen.create(new Pbinom()); case "pbeta": return StatsFunctionsFactory.Function3_2NodeGen.create(new Pbeta()); + case "qbeta": + return StatsFunctionsFactory.Function3_2NodeGen.create(new QBeta()); case "dcauchy": return StatsFunctionsFactory.Function3_1NodeGen.create(new DCauchy()); case "pcauchy": @@ -308,12 +333,16 @@ public class CallAndExternalFunctions { return StatsFunctionsFactory.Function3_2NodeGen.create(new Cauchy.QCauchy()); case "pf": return StatsFunctionsFactory.Function3_2NodeGen.create(new Pf()); + case "qf": + return StatsFunctionsFactory.Function3_2NodeGen.create(new Qf()); case "df": return StatsFunctionsFactory.Function3_1NodeGen.create(new Df()); case "dgamma": return StatsFunctionsFactory.Function3_1NodeGen.create(new DGamma()); case "dchisq": return StatsFunctionsFactory.Function2_1NodeGen.create(new Chisq.DChisq()); + case "qchisq": + return StatsFunctionsFactory.Function2_2NodeGen.create(new Chisq.QChisq()); case "qgeom": return StatsFunctionsFactory.Function2_2NodeGen.create(new Geom.QGeom()); case "pchisq": @@ -346,6 +375,8 @@ public class CallAndExternalFunctions { return StatsFunctionsFactory.Function3_2NodeGen.create(new Logis.QLogis()); case "plogis": return StatsFunctionsFactory.Function3_2NodeGen.create(new Logis.PLogis()); + case "pgeom": + return StatsFunctionsFactory.Function2_2NodeGen.create(new Geom.PGeom()); case "rmultinom": return RMultinomNodeGen.create(); case "Approx": diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/SpecialsUtils.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/SpecialsUtils.java index 75434227a58a3c0020057ee730bb540531d91534..971e6e19765f800c98f1d7d9f958ceacecb3440b 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/SpecialsUtils.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/SpecialsUtils.java @@ -107,8 +107,8 @@ class SpecialsUtils { /** * Checks whether the given (1-based) indexes are valid for the given matrix. */ - protected static boolean isValidIndex(RAbstractVector vector, int index1, int index2) { - int[] dimensions = vector.getDimensions(); + protected boolean isValidIndex(RAbstractVector vector, int index1, int index2) { + int[] dimensions = getDimensions.getDimensions(vector); return dimensions != null && dimensions.length == 2 && index1 >= 1 && index1 <= dimensions[0] && index2 >= 1 && index2 <= dimensions[1]; } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RRootNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RRootNode.java index 78ecc50564b951552f85f89a4cb7e80022676f93..929e53938623402ab75e0db4ae3dfa7b0ab7a697 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RRootNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RRootNode.java @@ -105,4 +105,9 @@ public abstract class RRootNode extends RootNode implements HasSignature { public boolean isCloningAllowed() { return true; } + + @Override + public final String toString() { + return getName(); + } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RBuiltinRootNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RBuiltinRootNode.java index 1754b1a1f97c8ad86f5a963c4738aad8ad3e1b88..9e0044e2416661076963972c25b27bc29069cfbd 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RBuiltinRootNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RBuiltinRootNode.java @@ -89,7 +89,7 @@ public final class RBuiltinRootNode extends RRootNode { throw new RInternalError(e, "internal error"); } finally { visibility.execute(frame, factory.getVisibility()); - visibility.executeEndOfFunction(frame); + visibility.executeEndOfFunction(frame, this); } } @@ -121,9 +121,4 @@ public final class RBuiltinRootNode extends RRootNode { public String getName() { return "RBuiltin(" + builtin + ")"; } - - @Override - public String toString() { - return getName(); - } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionDefinitionNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionDefinitionNode.java index 5e212366e4b448a63e035630e0281012618a4181..e2019c4c78506fca390f3b711385e08ee8b1d999 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionDefinitionNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionDefinitionNode.java @@ -25,9 +25,11 @@ package com.oracle.truffle.r.nodes.function; import java.util.ArrayList; import java.util.List; +import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlot; import com.oracle.truffle.api.frame.FrameSlotKind; @@ -113,6 +115,11 @@ public final class FunctionDefinitionNode extends RRootNode implements RSyntaxNo @CompilationFinal private boolean containsDispatch; + private final Assumption noHandlerStackSlot = Truffle.getRuntime().createAssumption(); + private final Assumption noRestartStackSlot = Truffle.getRuntime().createAssumption(); + @CompilationFinal private FrameSlot handlerStackSlot; + @CompilationFinal private FrameSlot restartStackSlot; + /** * Profiling for catching {@link ReturnException}s. */ @@ -229,12 +236,6 @@ public final class FunctionDefinitionNode extends RRootNode implements RSyntaxNo @Override public Object execute(VirtualFrame frame) { - /* - * It might be possible to only record this iff a handler is installed, by using the - * RArguments array. - */ - Object handlerStack = RErrorHandling.getHandlerStack(); - Object restartStack = RErrorHandling.getRestartStack(); boolean runOnExitHandlers = true; try { verifyEnclosingAssumptions(frame); @@ -278,13 +279,27 @@ public final class FunctionDefinitionNode extends RRootNode implements RSyntaxNo * has no exit handlers (by fiat), so any exceptions from onExits handlers will be * caught above. */ - visibility.executeEndOfFunction(frame); + visibility.executeEndOfFunction(frame, this); if (argPostProcess != null) { resetArgs.enter(); argPostProcess.execute(frame); } if (runOnExitHandlers) { - RErrorHandling.restoreStacks(handlerStack, restartStack); + if (!noHandlerStackSlot.isValid() && frame.isObject(handlerStackSlot)) { + try { + RErrorHandling.restoreHandlerStack(frame.getObject(handlerStackSlot)); + } catch (FrameSlotTypeException e) { + throw RInternalError.shouldNotReachHere(); + } + } + if (!noRestartStackSlot.isValid() && frame.isObject(restartStackSlot)) { + try { + RErrorHandling.restoreRestartStack(frame.getObject(restartStackSlot)); + } catch (FrameSlotTypeException e) { + throw RInternalError.shouldNotReachHere(); + } + } + if (onExitProfile.profile(onExitSlot.hasValue(frame))) { if (onExitExpressionCache == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -406,11 +421,6 @@ public final class FunctionDefinitionNode extends RRootNode implements RSyntaxNo return name == null ? "<no source>" : name; } - @Override - public String toString() { - return getName(); - } - public void setName(String name) { this.name = name; } @@ -460,4 +470,24 @@ public final class FunctionDefinitionNode extends RRootNode implements RSyntaxNo public String getSyntaxDebugName() { return name; } + + public FrameSlot getRestartFrameSlot(VirtualFrame frame) { + if (noRestartStackSlot.isValid()) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + restartStackSlot = frame.getFrameDescriptor().findOrAddFrameSlot(RFrameSlot.RestartStack); + noRestartStackSlot.invalidate(); + } + assert restartStackSlot != null; + return restartStackSlot; + } + + public FrameSlot getHandlerFrameSlot(VirtualFrame frame) { + if (noHandlerStackSlot.isValid()) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + handlerStackSlot = frame.getFrameDescriptor().findOrAddFrameSlot(RFrameSlot.HandlerStack); + noHandlerStackSlot.invalidate(); + } + assert handlerStackSlot != null; + return handlerStackSlot; + } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionExpressionNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionExpressionNode.java index e0c9f9eb525f116bfd2cf38921a8320f3e12bfb0..cc6676d89f3499383915a05d82b9a91b50f5cb78 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionExpressionNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionExpressionNode.java @@ -32,6 +32,7 @@ import com.oracle.truffle.r.nodes.RASTUtils; import com.oracle.truffle.r.nodes.RRootNode; import com.oracle.truffle.r.nodes.function.PromiseHelperNode.PromiseDeoptimizeFrameNode; import com.oracle.truffle.r.nodes.function.opt.EagerEvalHelper; +import com.oracle.truffle.r.nodes.function.visibility.SetVisibilityNode; import com.oracle.truffle.r.nodes.instrumentation.RInstrumentation; import com.oracle.truffle.r.runtime.ArgumentsSignature; import com.oracle.truffle.r.runtime.builtins.FastPathFactory; @@ -49,6 +50,8 @@ public final class FunctionExpressionNode extends RSourceSectionNode implements return new FunctionExpressionNode(src, callTarget); } + @Child private SetVisibilityNode visibility = SetVisibilityNode.create(); + @CompilationFinal private RootCallTarget callTarget; private final PromiseDeoptimizeFrameNode deoptFrameNode; @CompilationFinal private FastPathFactory fastPath; @@ -68,6 +71,7 @@ public final class FunctionExpressionNode extends RSourceSectionNode implements @Override public RFunction executeFunction(VirtualFrame frame) { + visibility.execute(frame, true); MaterializedFrame matFrame = frame.materialize(); if (deoptFrameNode != null) { // Deoptimize every promise which is now in this frame, as it might leave it's stack diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/visibility/SetVisibilityNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/visibility/SetVisibilityNode.java index c4946fcc9e09c23827fa6b4c357ee1f852024382..e5315d7410c862e2c6038a5a747fcf663aab322c 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/visibility/SetVisibilityNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/visibility/SetVisibilityNode.java @@ -22,6 +22,7 @@ */ package com.oracle.truffle.r.nodes.function.visibility; +import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.frame.Frame; @@ -32,6 +33,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.NodeInfo; +import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.r.runtime.RArguments; import com.oracle.truffle.r.runtime.RCaller; import com.oracle.truffle.r.runtime.RInternalError; @@ -86,12 +88,19 @@ public final class SetVisibilityNode extends Node { * Needs to be called at the end of each function, so that the visibility is transferred from * the current frame into the {@link RCaller}. */ - public void executeEndOfFunction(VirtualFrame frame) { + public void executeEndOfFunction(VirtualFrame frame, RootNode root) { ensureFrameSlot(frame); try { - Object visibility = frame.getBoolean(frameSlot); - if (visibility != null) { - RArguments.getCall(frame).setVisibility(visibility == Boolean.TRUE); + if (frame.isBoolean(frameSlot)) { + RArguments.getCall(frame).setVisibility(frame.getBoolean(frameSlot) == Boolean.TRUE); + } else { + CompilerDirectives.transferToInterpreter(); + /* + * Most likely the (only) builtin call in the function was configured to + * RVisibility.CUSTOM and didn't actually set the visibility. Another possible + * problem is a node that is created by RASTBuilder that does not set visibility. + */ + throw RInternalError.shouldNotReachHere("visibility not set at the end of " + root.getName()); } } catch (FrameSlotTypeException e) { throw RInternalError.shouldNotReachHere(e); @@ -102,6 +111,7 @@ public final class SetVisibilityNode extends Node { * Slow-path version of {@link #executeAfterCall(VirtualFrame, RCaller)}. */ public static void executeAfterCallSlowPath(Frame frame, RCaller caller) { + CompilerAsserts.neverPartOfCompilation(); frame.setBoolean(frame.getFrameDescriptor().findOrAddFrameSlot(RFrameSlot.Visibility, FrameSlotKind.Boolean), caller.getVisibility()); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastListNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastListNode.java index 14ea322f9f4f9e49447990349ea395b987d9f135..606b54d966886466339e13999070d035d9622b8c 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastListNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastListNode.java @@ -101,8 +101,8 @@ public abstract class CastListNode extends CastBaseNode { if (attr.getName().equals(RRuntime.CLASS_ATTR_KEY)) { if (setClassAttrNode == null) { - setClassAttrNode = insert(SetClassAttributeNode.create()); CompilerDirectives.transferToInterpreterAndInvalidate(); + setClassAttrNode = insert(SetClassAttributeNode.create()); } setClassAttrNode.execute(result, attr.getValue()); diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RError.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RError.java index 39504baf8e90020ba7d51c19460d27a600f91e3e..e61db9860abc7e1c0f104a9ab3636eca04da66f1 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RError.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RError.java @@ -527,6 +527,7 @@ public final class RError extends RuntimeException { NA_IN_PROB_VECTOR("NA in probability vector"), NEGATIVE_PROBABILITY("negative probability"), NO_POSITIVE_PROBABILITIES("no positive probabilities"), + QBETA_ACURACY_WARNING("qbeta(a, *) =: x0 with |pbeta(x0,*%s) - alpha| = %.5g is not accurate"), NON_POSITIVE_FILL("non-positive 'fill' argument will be ignored"), MUST_BE_ONE_BYTE("invalid %s: must be one byte"), INVALID_DECIMAL_SEP("invalid decimal separator"), diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RErrorHandling.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RErrorHandling.java index af99cbf6c7b6d7d62046e0d61ddd373c17a9866a..4b5b757cc622462911f7785b5707fdea6293530a 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RErrorHandling.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RErrorHandling.java @@ -215,6 +215,16 @@ public class RErrorHandling { errorHandlingState.restartStack = savedRestartStack; } + public static void restoreHandlerStack(Object savedHandlerStack) { + ContextStateImpl errorHandlingState = getRErrorHandlingState(); + errorHandlingState.handlerStack = savedHandlerStack; + } + + public static void restoreRestartStack(Object savedRestartStack) { + ContextStateImpl errorHandlingState = getRErrorHandlingState(); + errorHandlingState.restartStack = savedRestartStack; + } + public static Object createHandlers(RAbstractStringVector classes, RList handlers, REnvironment parentEnv, Object target, byte calling) { CompilerAsserts.neverPartOfCompilation(); Object oldStack = getRestartStack(); diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/RFrameSlot.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/RFrameSlot.java index 81e2536a03764a896477ce6218dd8856acaaa115..e303fac170654063244a601a7b1891c87fb7e9cb 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/RFrameSlot.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/RFrameSlot.java @@ -51,5 +51,13 @@ public enum RFrameSlot { * each call site, the value of {@link RCaller#getVisibility()} is extracted and stored into the * frame slot. */ - Visibility; + Visibility, + /** + * Used to save the handler stack in frames that modify it. + */ + HandlerStack, + /** + * Used to save the restart stack in frames that modify it. + */ + RestartStack } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test index 7d1c0b82915e91527f05397f483b5cc03c3fbfb5..bef395ff97c3f3532232a6fe9a6497723cbd4646 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test @@ -59326,6 +59326,11 @@ f first 1 #{f<-function(x){UseMethod("f")};f.logical<-function(x){print("logical")};f(TRUE)} [1] "logical" +##com.oracle.truffle.r.test.library.base.TestConditionHandling.testTryCatch# +#{ e <- simpleError("test error"); f <- function() { tryCatch(1, finally = print("Hello")); stop(e)}; f() } +[1] "Hello" +Error: test error + ##com.oracle.truffle.r.test.library.base.TestConditionHandling.testTryCatch# #{ e <- simpleError("test error"); tryCatch(stop(e), error = function(e) e, finally = print("Hello"))} [1] "Hello" @@ -59336,6 +59341,14 @@ f first 1 Error: test error [1] "Hello" +##com.oracle.truffle.r.test.library.base.TestConditionHandling.testTryCatch# +#{ f <- function() { tryCatch(1, error = function(e) print("Hello")); stop("fred")}; f() } +Error in f() : fred + +##com.oracle.truffle.r.test.library.base.TestConditionHandling.testTryCatch# +#{ f <- function() { tryCatch(stop("fred"), error = function(e) print("Hello"))}; f() } +[1] "Hello" + ##com.oracle.truffle.r.test.library.base.TestConditionHandling.testTryCatch# #{ tryCatch(1, finally = print("Hello")) } [1] "Hello" @@ -111519,6 +111532,157 @@ Error: 'x' is NULL #.Call(stats:::C_cov, c('1','2','3','4','5'), 1:5, 4, FALSE) [1] 2.5 +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(0.1, 0, 0, lower.tail=F, log.p=F) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(0.1, 0, 0, lower.tail=T, log.p=F) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(0.5, 0, 0, lower.tail=F, log.p=F) +[1] 0.5 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(0.5, 0, 0, lower.tail=T, log.p=F) +[1] 0.5 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(0.7, 0, 0, lower.tail=F, log.p=F) +[1] 1 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(0.7, 0, 0, lower.tail=T, log.p=F) +[1] 1 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(0.7, 0, 1/0, lower.tail=F, log.p=F) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(0.7, 0, 1/0, lower.tail=T, log.p=F) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(0.7, 1/0, 0, lower.tail=F, log.p=F) +[1] 1 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(0.7, 1/0, 0, lower.tail=T, log.p=F) +[1] 1 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta#Output.MayIgnoreWarningContext# +#qbeta(log(0), -1, 3, lower.tail=T, log.p=T) +[1] NaN +Warning message: +In qbeta(log(0), -1, 3, lower.tail = T, log.p = T) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(log(0), 0.1, 3, lower.tail=T, log.p=T) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta#Output.MayIgnoreWarningContext# +#qbeta(log(0.1), -1, 3, lower.tail=T, log.p=T) +[1] NaN +Warning message: +In qbeta(log(0.1), -1, 3, lower.tail = T, log.p = T) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(log(0.1), 0, 0, lower.tail=F, log.p=T) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(log(0.1), 0, 0, lower.tail=T, log.p=T) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(log(0.1), 0.1, 3, lower.tail=T, log.p=T) +[1] 2.366901e-11 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta#Output.MayIgnoreWarningContext# +#qbeta(log(0.5), -1, 3, lower.tail=T, log.p=T) +[1] NaN +Warning message: +In qbeta(log(0.5), -1, 3, lower.tail = T, log.p = T) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(log(0.5), 0, 0, lower.tail=F, log.p=T) +[1] 0.5 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(log(0.5), 0, 0, lower.tail=T, log.p=T) +[1] 0.5 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(log(0.5), 0.1, 3, lower.tail=T, log.p=T) +[1] 0.0002312399 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta#Output.MayIgnoreWarningContext# +#qbeta(log(0.7), -1, 3, lower.tail=T, log.p=T) +[1] NaN +Warning message: +In qbeta(log(0.7), -1, 3, lower.tail = T, log.p = T) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(log(0.7), 0, 0, lower.tail=F, log.p=T) +[1] 1 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(log(0.7), 0, 0, lower.tail=T, log.p=T) +[1] 1 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(log(0.7), 0, 1/0, lower.tail=F, log.p=T) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(log(0.7), 0, 1/0, lower.tail=T, log.p=T) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(log(0.7), 0.1, 3, lower.tail=T, log.p=T) +[1] 0.006768603 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(log(0.7), 1/0, 0, lower.tail=F, log.p=T) +[1] 1 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(log(0.7), 1/0, 0, lower.tail=T, log.p=T) +[1] 1 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta#Output.MayIgnoreWarningContext# +#qbeta(log(1), -1, 3, lower.tail=T, log.p=T) +[1] NaN +Warning message: +In qbeta(log(1), -1, 3, lower.tail = T, log.p = T) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(log(1), 0.1, 3, lower.tail=T, log.p=T) +[1] 1 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta#Output.MayIgnoreWarningContext# +#qbeta(log(1-42e-80), -1, 3, lower.tail=T, log.p=T) +[1] NaN +Warning message: +In qbeta(log(1 - 4.2e-79), -1, 3, lower.tail = T, log.p = T) : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(log(1-42e-80), 0.1, 3, lower.tail=T, log.p=T) +[1] 1 + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta#Output.MayIgnoreWarningContext# +#qbeta(log(42e-80), -1, 3, lower.tail=T, log.p=T) +[1] NaN +Warning message: +In qbeta(log(4.2e-79), -1, 3, lower.tail = T, log.p = T) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestExternal_qbeta.testQBeta# +#qbeta(log(42e-80), 0.1, 3, lower.tail=T, log.p=T) +[1] 1.112537e-308 + ##com.oracle.truffle.r.test.library.stats.TestExternal_qgamma.testQgamma# #qgamma(0, 1) [1] 0 @@ -114880,6 +115044,389 @@ In pexp(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5)) : NaNs produced #set.seed(1); pexp(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) [1] NA 0 NaN 1 0 NA 0 NaN 1 -Inf NA 0 NaN 0 -Inf +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pgeom(0, 10, lower.tail=FALSE, log.p=FALSE) +[1] NaN +Warning message: +In pgeom(0, 10, lower.tail = FALSE, log.p = FALSE) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pgeom(0, 10, lower.tail=FALSE, log.p=TRUE) +[1] NaN +Warning message: +In pgeom(0, 10, lower.tail = FALSE, log.p = TRUE) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pgeom(0, 10, lower.tail=TRUE, log.p=FALSE) +[1] NaN +Warning message: +In pgeom(0, 10, lower.tail = TRUE, log.p = FALSE) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pgeom(0, 10, lower.tail=TRUE, log.p=TRUE) +[1] NaN +Warning message: +In pgeom(0, 10, lower.tail = TRUE, log.p = TRUE) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pgeom(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=FALSE, log.p=FALSE) +[1] 0.934700 0.999877 1.000000 NaN NaN NaN NaN +Warning message: +In pgeom(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pgeom(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=FALSE, log.p=TRUE) +[1] -6.752966e-02 -1.230076e-04 -3.200000e-79 NaN NaN +[6] NaN NaN +Warning message: +In pgeom(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pgeom(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=TRUE, log.p=FALSE) +[1] 6.53e-02 1.23e-04 3.20e-79 NaN NaN NaN NaN +Warning message: +In pgeom(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pgeom(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=TRUE, log.p=TRUE) +[1] -2.728763 -9.003326 -180.741072 NaN NaN NaN +[7] NaN +Warning message: +In pgeom(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pgeom(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=FALSE, log.p=FALSE) + [1] NaN NaN 0.900 0.001 NaN NaN NaN 0.729 1.000 NaN NaN NaN +[13] 1.000 0.100 NaN NaN NaN 0.900 0.100 NaN +Warning message: +In pgeom(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = FALSE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pgeom(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=FALSE, log.p=TRUE) + [1] NaN NaN -0.1053605 -6.9077553 NaN NaN + [7] NaN -0.3160815 0.0000000 NaN NaN NaN +[13] 0.0000000 -2.3025851 NaN NaN NaN -0.1053605 +[19] -2.3025851 NaN +Warning message: +In pgeom(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = FALSE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pgeom(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=TRUE, log.p=FALSE) + [1] NaN NaN 0.100 0.999 NaN NaN NaN 0.271 0.000 NaN NaN NaN +[13] 0.000 0.900 NaN NaN NaN 0.100 0.900 NaN +Warning message: +In pgeom(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = TRUE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pgeom(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=TRUE, log.p=TRUE) + [1] NaN NaN -2.3025851 -0.0010005 NaN NaN + [7] NaN -1.3056365 -Inf NaN NaN NaN +[13] -Inf -0.1053605 NaN NaN NaN -2.3025851 +[19] -0.1053605 NaN +Warning message: +In pgeom(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = TRUE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pgeom(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5)) + [1] NA NaN NaN 1.0 NaN NA 1.0 NaN 1.0 0.0 NA 0.1 NaN NaN 0.0 +Warning message: +In pgeom(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5)) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pgeom(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) + [1] NA NaN NaN NaN NaN NA NaN NaN NaN NaN NA NaN NaN NaN NaN +Warning message: +In pgeom(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); ppois(0, 10, lower.tail=FALSE, log.p=FALSE) +[1] 0.9999546 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); ppois(0, 10, lower.tail=FALSE, log.p=TRUE) +[1] -4.540096e-05 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); ppois(0, 10, lower.tail=TRUE, log.p=FALSE) +[1] 4.539993e-05 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); ppois(0, 10, lower.tail=TRUE, log.p=TRUE) +[1] -10 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); ppois(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=FALSE, log.p=FALSE) +[1] 6.321361e-02 1.229924e-04 3.200000e-79 1.000000e+00 1.000000e+00 +[6] 0.000000e+00 NaN +Warning message: +In ppois(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); ppois(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=FALSE, log.p=TRUE) +[1] -2.761236 -9.003388 -180.741072 0.000000 0.000000 -Inf +[7] NaN +Warning message: +In ppois(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); ppois(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=TRUE, log.p=FALSE) +[1] 0.9367864 0.9998770 1.0000000 0.0000000 0.0000000 1.0000000 NaN +Warning message: +In ppois(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); ppois(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=TRUE, log.p=TRUE) +[1] -6.530e-02 -1.230e-04 -3.200e-79 -8.833e+03 -7.900e+71 0.000e+00 NaN +Warning message: +In ppois(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); ppois(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=FALSE, log.p=FALSE) + [1] NaN 0.0000000000 0.0951625820 0.0628569343 1.0000000000 + [6] NaN 0.0000000000 0.0001546531 1.0000000000 0.9502129316 +[11] NaN 0.0000000000 1.0000000000 0.5934303403 0.9502129316 +[16] NaN 1.0000000000 0.0951625820 0.5934303403 0.5768099189 +Warning message: +In ppois(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = FALSE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); ppois(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=FALSE, log.p=TRUE) + [1] NaN -Inf -2.35216846 -2.76689402 0.00000000 NaN + [7] -Inf -8.77432621 0.00000000 -0.05106918 NaN -Inf +[13] 0.00000000 -0.52183544 -0.05106918 NaN 0.00000000 -2.35216846 +[19] -0.52183544 -0.55024250 +Warning message: +In ppois(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = FALSE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); ppois(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=TRUE, log.p=FALSE) + [1] NaN 1.00000000 0.90483742 0.93714307 0.00000000 NaN + [7] 1.00000000 0.99984535 0.00000000 0.04978707 NaN 1.00000000 +[13] 0.00000000 0.40656966 0.04978707 NaN 0.00000000 0.90483742 +[19] 0.40656966 0.42319008 +Warning message: +In ppois(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = TRUE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); ppois(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=TRUE, log.p=TRUE) + [1] NaN 0.000000000 -0.100000000 -0.064919324 -Inf + [6] NaN 0.000000000 -0.000154665 -Inf -3.000000000 +[11] NaN 0.000000000 -Inf -0.900000000 -3.000000000 +[16] NaN -Inf -0.100000000 -0.900000000 -0.859933837 +Warning message: +In ppois(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = TRUE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); ppois(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5)) + [1] NA 1.0000000 NaN 1.0000000 0.0000000 NA 0.3678794 + [8] NaN 1.0000000 0.0000000 NA 0.9048374 NaN 1.0000000 +[15] 0.0000000 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); ppois(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) + [1] NA 1 NaN 0 NaN NA 1 NaN 0 NaN NA 1 NaN 0 NaN +Warning message: +In ppois(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pt(0, 10, lower.tail=FALSE, log.p=FALSE) +[1] 0.5 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pt(0, 10, lower.tail=FALSE, log.p=TRUE) +[1] -0.6931472 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pt(0, 10, lower.tail=TRUE, log.p=FALSE) +[1] 0.5 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pt(0, 10, lower.tail=TRUE, log.p=TRUE) +[1] -0.6931472 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pt(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=FALSE, log.p=FALSE) +[1] 0.5 0.5 0.5 0.5 0.5 NaN NaN +Warning message: +In pt(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), lower.tail = FALSE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pt(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=FALSE, log.p=TRUE) +[1] -0.6931472 -0.6931472 -0.6931472 -0.6931472 -0.6931472 NaN NaN +Warning message: +In pt(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), lower.tail = FALSE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pt(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=TRUE, log.p=FALSE) +[1] 0.5 0.5 0.5 0.5 0.5 NaN NaN +Warning message: +In pt(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), lower.tail = TRUE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pt(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=TRUE, log.p=TRUE) +[1] -0.6931472 -0.6931472 -0.6931472 -0.6931472 -0.6931472 NaN NaN +Warning message: +In pt(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), lower.tail = TRUE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pt(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=FALSE, log.p=FALSE) + [1] NaN NaN 0.47222678 0.15801721 0.80449889 NaN + [7] NaN 0.38917711 0.74287641 0.50000000 NaN NaN +[13] 0.58367176 0.50000000 0.42713516 NaN NaN 0.50000000 +[19] 0.43852072 0.06966298 +Warning message: +In pt(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = FALSE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pt(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=FALSE, log.p=TRUE) + [1] NaN NaN -0.7502959 -1.8450513 -0.2175357 NaN + [7] NaN -0.9437207 -0.2972256 -0.6931472 NaN NaN +[13] -0.5384165 -0.6931472 -0.8506548 NaN NaN -0.6931472 +[19] -0.8243482 -2.6640862 +Warning message: +In pt(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = FALSE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pt(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=TRUE, log.p=FALSE) + [1] NaN NaN 0.5277732 0.8419828 0.1955011 NaN NaN + [8] 0.6108229 0.2571236 0.5000000 NaN NaN 0.4163282 0.5000000 +[15] 0.5728648 NaN NaN 0.5000000 0.5614793 0.9303370 +Warning message: +In pt(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = TRUE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pt(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=TRUE, log.p=TRUE) + [1] NaN NaN -0.63908859 -0.17199570 -1.63218922 NaN + [7] NaN -0.49294824 -1.35819841 -0.69314718 NaN NaN +[13] -0.87628129 -0.69314718 -0.55710548 NaN NaN -0.69314718 +[19] -0.57718041 -0.07220838 +Warning message: +In pt(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = TRUE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pt(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5)) + [1] NA NaN NaN 1.0 NaN NA 0.5 NaN 1.0 0.0 NA 0.5 NaN NaN 0.0 +Warning message: +In pt(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5)) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); pt(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) + [1] NA NaN NaN 0.8413447 NaN NA NaN + [8] NaN 0.5398278 NaN NA NaN NaN 0.5000000 +[15] NaN +Warning message: +In pt(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qchisq(0, 10, lower.tail=FALSE, log.p=FALSE) +[1] Inf + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qchisq(0, 10, lower.tail=FALSE, log.p=TRUE) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qchisq(0, 10, lower.tail=TRUE, log.p=FALSE) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qchisq(0, 10, lower.tail=TRUE, log.p=TRUE) +[1] Inf + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qchisq(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=FALSE, log.p=FALSE) +[1] Inf Inf Inf Inf Inf Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qchisq(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=FALSE, log.p=TRUE) +[1] 0 0 0 0 0 0 0 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qchisq(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=TRUE, log.p=FALSE) +[1] 0 0 0 0 0 0 0 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qchisq(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=TRUE, log.p=TRUE) +[1] Inf Inf Inf Inf Inf Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qchisq(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=FALSE, log.p=FALSE) + [1] NaN Inf 0.013564 NaN NaN Inf 0.000000 NaN + [9] NaN Inf NaN NaN NaN Inf 4.641628 NaN +[17] NaN Inf 1.468957 NaN +Warning message: +In qchisq(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = FALSE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qchisq(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=FALSE, log.p=TRUE) + [1] NaN 0.000000000 NaN NaN 3.158142952 0.000000000 + [7] NaN NaN 0.691572992 0.000000000 NaN NaN +[13] 0.000121286 0.000000000 NaN NaN 0.000000000 0.000000000 +[19] NaN NaN +Warning message: +In qchisq(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = FALSE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qchisq(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=TRUE, log.p=FALSE) + [1] NaN 0.000000e+00 1.225708e-14 NaN NaN + [6] 0.000000e+00 0.000000e+00 NaN NaN 0.000000e+00 +[11] NaN NaN NaN 0.000000e+00 1.005174e+00 +[16] NaN NaN 0.000000e+00 4.335644e-02 NaN +Warning message: +In qchisq(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = TRUE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qchisq(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=TRUE, log.p=TRUE) + [1] NaN Inf NaN NaN 1.721698e+00 + [6] Inf NaN NaN 1.756852e-01 Inf +[11] NaN NaN 2.409337e-09 Inf NaN +[16] NaN 0.000000e+00 Inf NaN NaN +Warning message: +In qchisq(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = TRUE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qchisq(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5)) + [1] NA 0 NaN NaN NaN NA 0 NaN NaN NaN NA 0 NaN NaN NaN +Warning message: +In qchisq(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5)) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qchisq(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) + [1] NA 0 NaN Inf 0 NA Inf NaN Inf Inf NA 0 NaN 0 NaN +Warning messages: +1: In qchisq(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) : + value out of range in 'lgamma' +2: In qchisq(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) : + NaNs produced + ##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# #set.seed(1); qexp(0, 10, lower.tail=FALSE, log.p=FALSE) [1] Inf @@ -115071,6 +115618,179 @@ In qgeom(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5)) : NaNs produced Warning message: In qgeom(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) : NaNs produced +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qpois(0, 10, lower.tail=FALSE, log.p=FALSE) +[1] Inf + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qpois(0, 10, lower.tail=FALSE, log.p=TRUE) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qpois(0, 10, lower.tail=TRUE, log.p=FALSE) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qpois(0, 10, lower.tail=TRUE, log.p=TRUE) +[1] Inf + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qpois(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=FALSE, log.p=FALSE) +[1] Inf Inf Inf Inf Inf 0 NaN +Warning message: +In qpois(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qpois(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=FALSE, log.p=TRUE) +[1] 0 0 0 0 0 0 NaN +Warning message: +In qpois(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qpois(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=TRUE, log.p=FALSE) +[1] 0 0 0 0 0 0 NaN +Warning message: +In qpois(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qpois(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=TRUE, log.p=TRUE) +[1] Inf Inf Inf Inf Inf 0 NaN +Warning message: +In qpois(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qpois(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=FALSE, log.p=FALSE) + [1] NaN 0 0 NaN NaN NaN 0 NaN NaN Inf NaN 0 NaN Inf 4 NaN 0 Inf 2 +[20] NaN +Warning message: +In qpois(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = FALSE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qpois(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=FALSE, log.p=TRUE) + [1] NaN 0 NaN NaN 3 NaN 0 NaN 1 0 NaN 0 0 0 NaN NaN 0 0 NaN +[20] NaN +Warning message: +In qpois(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = FALSE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qpois(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=TRUE, log.p=FALSE) + [1] NaN 0 0 NaN NaN NaN 0 NaN NaN 0 NaN 0 NaN 0 2 NaN 0 0 0 +[20] NaN +Warning message: +In qpois(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = TRUE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qpois(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=TRUE, log.p=TRUE) + [1] NaN 0 NaN NaN 2 NaN 0 NaN 0 Inf NaN 0 0 Inf NaN NaN 0 Inf NaN +[20] NaN +Warning message: +In qpois(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = TRUE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qpois(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5)) + [1] NA 0 NaN NaN 0 NA 0 NaN NaN NaN NA 0 NaN 0 NaN +Warning message: +In qpois(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5)) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qpois(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) + [1] NA 0 NaN NaN NaN NA 0 NaN NaN NaN NA 0 NaN NaN NaN +Warning message: +In qpois(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qt(0, 10, lower.tail=FALSE, log.p=FALSE) +[1] Inf + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qt(0, 10, lower.tail=FALSE, log.p=TRUE) +[1] -Inf + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qt(0, 10, lower.tail=TRUE, log.p=FALSE) +[1] -Inf + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qt(0, 10, lower.tail=TRUE, log.p=TRUE) +[1] Inf + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qt(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=FALSE, log.p=FALSE) +[1] Inf Inf Inf Inf Inf Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qt(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=FALSE, log.p=TRUE) +[1] -Inf -Inf -Inf -Inf -Inf -Inf -Inf + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qt(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=TRUE, log.p=FALSE) +[1] -Inf -Inf -Inf -Inf -Inf -Inf -Inf + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qt(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), lower.tail=TRUE, log.p=TRUE) +[1] Inf Inf Inf Inf Inf Inf Inf + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qt(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=FALSE, log.p=FALSE) + [1] NaN Inf 1566.8219615 NaN NaN + [6] Inf NaN NaN NaN Inf +[11] NaN NaN NaN Inf 0.9784723 +[16] NaN NaN Inf 1.4638968 NaN +Warning message: +In qt(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = FALSE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qt(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=FALSE, log.p=TRUE) + [1] NaN -Inf NaN NaN 0.3702990 -Inf NaN + [8] NaN 0.4528167 -Inf NaN NaN 3.5265712 -Inf +[15] NaN NaN NaN -Inf NaN NaN +Warning message: +In qt(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = FALSE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qt(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=TRUE, log.p=FALSE) + [1] NaN -Inf -1566.8219615 NaN NaN + [6] -Inf NaN NaN NaN -Inf +[11] NaN NaN NaN -Inf -0.9784723 +[16] NaN NaN -Inf -1.4638968 NaN +Warning message: +In qt(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = TRUE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qt(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail=TRUE, log.p=TRUE) + [1] NaN Inf NaN NaN -0.3702990 Inf + [7] NaN NaN -0.4528167 Inf NaN NaN +[13] -3.5265712 Inf NaN NaN NaN Inf +[19] NaN NaN +Warning message: +In qt(c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4), lower.tail = TRUE, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qt(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5)) + [1] NA -Inf NaN NaN NaN NA -Inf NaN NaN NaN NA -Inf NaN NaN NaN +Warning message: +In qt(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5)) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions22#Output.IgnoreWhitespace# +#set.seed(1); qt(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) + [1] NA -Inf NaN Inf -Inf NA Inf + [8] NaN -1.281552 Inf NA NaN NaN -Inf +[15] NaN +Warning message: +In qt(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) : NaNs produced + ##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions31#Output.IgnoreWhitespace# #set.seed(1); dbeta(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70), c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), log=FALSE) [1] Inf Inf Inf 0 0 0 NaN @@ -115360,6 +116080,70 @@ In dlogis(c(-1, 0, 1), c(-1, 0, 0.2, 2:5), rep(c(-1, 0, 0.1, 0.9, : #set.seed(1); dlogis(c(NA, NaN, 1/0, -1/0), 2, 2, log=FALSE) [1] NA NaN 0 0 +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions31#Output.IgnoreWhitespace# +#set.seed(1); dunif(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70), c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), log=FALSE) +[1] NaN NaN NaN NaN NaN NaN NaN +Warning message: +In dunif(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71), c(0.0653, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions31#Output.IgnoreWhitespace# +#set.seed(1); dunif(0, c(NA, 0, NaN, 1/0, -1/0), c(NaN, NaN, NA, 0, 1/0, -1/0), log=FALSE) +[1] NA NaN NA NaN 0 NA +Warning message: +In dunif(0, c(NA, 0, NaN, 1/0, -1/0), c(NaN, NaN, NA, 0, 1/0, -1/0), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions31#Output.IgnoreWhitespace# +#set.seed(1); dunif(10, 10, 10, log=TRUE) +[1] NaN +Warning message: +In dunif(10, 10, 10, log = TRUE) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions31#Output.IgnoreWhitespace# +#set.seed(1); dunif(3, 3, 3, log=FALSE) +[1] NaN +Warning message: +In dunif(3, 3, 3, log = FALSE) : NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions31#Output.IgnoreWhitespace# +#set.seed(1); dunif(c(-1, 0, 1), c(-1, 0, 0.2, 2:5), rep(c(-1, 0, 0.1, 0.9, 3), 12), log=FALSE) + [1] NaN NaN NaN NaN NaN NaN + [7] NaN 0.9090909 0.0000000 0.0000000 NaN NaN +[13] NaN NaN 0.2500000 NaN NaN NaN +[19] NaN NaN NaN 1.0000000 10.0000000 0.0000000 +[25] 0.0000000 NaN NaN NaN 0.5263158 0.3333333 +[31] NaN NaN NaN NaN NaN NaN +[37] NaN NaN NaN NaN NaN NaN +[43] 0.9090909 1.1111111 0.3571429 NaN NaN NaN +[49] NaN 0.2500000 NaN NaN NaN NaN +[55] NaN NaN 0.0000000 0.0000000 0.0000000 0.0000000 +Warning message: +In dunif(c(-1, 0, 1), c(-1, 0, 0.2, 2:5), rep(c(-1, 0, 0.1, 0.9, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions31#Output.IgnoreWhitespace# +#set.seed(1); dunif(c(-1, 0, 1), c(-1, 0, 0.2, 2:5), rep(c(-1, 0, 0.1, 0.9, 3), 12), log=TRUE) + [1] NaN NaN NaN NaN NaN NaN + [7] NaN -0.09531018 -Inf -Inf NaN NaN +[13] NaN NaN -1.38629436 NaN NaN NaN +[19] NaN NaN NaN 0.00000000 2.30258509 -Inf +[25] -Inf NaN NaN NaN -0.64185389 -1.09861229 +[31] NaN NaN NaN NaN NaN NaN +[37] NaN NaN NaN NaN NaN NaN +[43] -0.09531018 0.10536052 -1.02961942 NaN NaN NaN +[49] NaN -1.38629436 NaN NaN NaN NaN +[55] NaN NaN -Inf -Inf -Inf -Inf +Warning message: +In dunif(c(-1, 0, 1), c(-1, 0, 0.2, 2:5), rep(c(-1, 0, 0.1, 0.9, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions31#Output.IgnoreWhitespace# +#set.seed(1); dunif(c(NA, NaN, 1/0, -1/0), 2, 2, log=FALSE) +[1] NA NaN NaN NaN +Warning message: +In dunif(c(NA, NaN, 1/0, -1/0), 2, 2, log = FALSE) : NaNs produced + ##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# #set.seed(1); pbeta(0, 10, 10, lower.tail=FALSE, log.p=FALSE) [1] 1 @@ -116666,6 +117450,377 @@ Warning message: In pnorm(rep(c(1, 0, 0.1), 5), rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, : NaNs produced +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); punif(0, 10, 10, lower.tail=FALSE, log.p=FALSE) +[1] 1 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); punif(0, 10, 10, lower.tail=FALSE, log.p=TRUE) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); punif(0, 10, 10, lower.tail=TRUE, log.p=FALSE) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); punif(0, 10, 10, lower.tail=TRUE, log.p=TRUE) +[1] -Inf + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); punif(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), rep(c(0.0653, 0.000123, 32e-80, 8833, 79e70), 7), lower.tail=FALSE, log.p=FALSE) + [1] 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 + [6] 1.000000e+00 1.229849e-04 NaN 1.000000e+00 1.000000e+00 +[11] NaN NaN 1.000000e+00 9.998868e-01 1.000000e+00 +[16] 1.000000e+00 1.000000e+00 NaN NaN 1.000000e+00 +[21] 6.129729e-02 NaN NaN 1.000000e+00 1.000000e+00 +[26] NaN 1.000000e+00 3.200000e-79 1.000000e+00 1.000000e+00 +[31] 1.000000e+00 NaN NaN 1.000000e+00 1.000000e+00 +Warning message: +In punif(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); punif(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), rep(c(0.0653, 0.000123, 32e-80, 8833, 79e70), 7), lower.tail=FALSE, log.p=TRUE) + [1] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 + [6] 0.000000e+00 -9.003449e+00 NaN 0.000000e+00 0.000000e+00 +[11] NaN NaN 0.000000e+00 -1.132054e-04 0.000000e+00 +[16] 0.000000e+00 0.000000e+00 NaN NaN 0.000000e+00 +[21] -2.792020e+00 NaN NaN 0.000000e+00 0.000000e+00 +[26] NaN 0.000000e+00 -1.807411e+02 0.000000e+00 0.000000e+00 +[31] 0.000000e+00 NaN NaN 0.000000e+00 0.000000e+00 +Warning message: +In punif(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); punif(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), rep(c(0.0653, 0.000123, 32e-80, 8833, 79e70), 7), lower.tail=TRUE, log.p=FALSE) + [1] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 + [6] 0.000000e+00 9.998770e-01 NaN 0.000000e+00 0.000000e+00 +[11] NaN NaN 0.000000e+00 1.131990e-04 0.000000e+00 +[16] 0.000000e+00 0.000000e+00 NaN NaN 0.000000e+00 +[21] 9.387027e-01 NaN NaN 0.000000e+00 0.000000e+00 +[26] NaN 0.000000e+00 1.000000e+00 0.000000e+00 0.000000e+00 +[31] 0.000000e+00 NaN NaN 0.000000e+00 1.265823e-72 +Warning message: +In punif(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); punif(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), rep(c(0.0653, 0.000123, 32e-80, 8833, 79e70), 7), lower.tail=TRUE, log.p=TRUE) + [1] -Inf -Inf -Inf -Inf -Inf + [6] -Inf -1.229924e-04 NaN -Inf -Inf +[11] NaN NaN -Inf -9.086363e+00 -Inf +[16] -Inf -Inf NaN NaN -Inf +[21] -6.325645e-02 NaN NaN -Inf -Inf +[26] NaN -Inf 0.000000e+00 -Inf -Inf +[31] -Inf NaN NaN -Inf -1.655504e+02 +Warning message: +In punif(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); punif(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, -0.1, 0.0001), 20), lower.tail=FALSE, log.p=FALSE) + [1] 0.00000000 0.00000000 0.88888889 NaN NaN 0.00009999 + [7] NaN NaN 1.00000000 NaN 0.00000000 0.00000000 + [13] NaN NaN NaN 0.00000000 NaN NaN + [19] NaN NaN 1.00000000 1.00000000 NaN NaN + [25] NaN 0.00000000 0.80000000 0.00000000 NaN NaN + [31] 0.00000000 0.00000000 1.00000000 NaN NaN 0.00000000 + [37] NaN NaN 1.00000000 NaN 1.00000000 1.00000000 + [43] NaN NaN NaN 0.09090909 NaN NaN + [49] NaN NaN 0.40000000 0.00000000 NaN NaN + [55] NaN 0.00000000 1.00000000 1.00000000 NaN NaN + [61] 0.00000000 0.00000000 0.88888889 NaN NaN 0.00009999 + [67] NaN NaN 1.00000000 NaN 0.00000000 0.00000000 + [73] NaN NaN NaN 0.00000000 NaN NaN + [79] NaN NaN 1.00000000 1.00000000 NaN NaN + [85] NaN 0.00000000 0.80000000 0.00000000 NaN NaN + [91] 0.00000000 0.00000000 1.00000000 NaN NaN 0.00000000 + [97] NaN NaN 1.00000000 NaN 1.00000000 1.00000000 +[103] NaN NaN NaN 0.09090909 NaN NaN +[109] NaN NaN 0.40000000 0.00000000 NaN NaN +[115] NaN 0.00000000 1.00000000 1.00000000 NaN NaN +Warning message: +In punif(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); punif(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, -0.1, 0.0001), 20), lower.tail=FALSE, log.p=TRUE) + [1] -Inf -Inf -0.1177830 NaN NaN -9.2104404 + [7] NaN NaN 0.0000000 NaN -Inf -Inf + [13] NaN NaN NaN -Inf NaN NaN + [19] NaN NaN 0.0000000 0.0000000 NaN NaN + [25] NaN -Inf -0.2231436 -Inf NaN NaN + [31] -Inf -Inf 0.0000000 NaN NaN -Inf + [37] NaN NaN 0.0000000 NaN 0.0000000 0.0000000 + [43] NaN NaN NaN -2.3978953 NaN NaN + [49] NaN NaN -0.9162907 -Inf NaN NaN + [55] NaN -Inf 0.0000000 0.0000000 NaN NaN + [61] -Inf -Inf -0.1177830 NaN NaN -9.2104404 + [67] NaN NaN 0.0000000 NaN -Inf -Inf + [73] NaN NaN NaN -Inf NaN NaN + [79] NaN NaN 0.0000000 0.0000000 NaN NaN + [85] NaN -Inf -0.2231436 -Inf NaN NaN + [91] -Inf -Inf 0.0000000 NaN NaN -Inf + [97] NaN NaN 0.0000000 NaN 0.0000000 0.0000000 +[103] NaN NaN NaN -2.3978953 NaN NaN +[109] NaN NaN -0.9162907 -Inf NaN NaN +[115] NaN -Inf 0.0000000 0.0000000 NaN NaN +Warning message: +In punif(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); punif(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, -0.1, 0.0001), 20), lower.tail=TRUE, log.p=FALSE) + [1] 1.0000000 1.0000000 0.1111111 NaN NaN 0.9999000 NaN + [8] NaN 0.0000000 NaN 1.0000000 1.0000000 NaN NaN + [15] NaN 1.0000000 NaN NaN NaN NaN 0.0000000 + [22] 0.0000000 NaN NaN NaN 1.0000000 0.2000000 1.0000000 + [29] NaN NaN 1.0000000 1.0000000 0.0000000 NaN NaN + [36] 1.0000000 NaN NaN 0.0000000 NaN 0.0000000 0.0000000 + [43] NaN NaN NaN 0.9090909 NaN NaN NaN + [50] NaN 0.6000000 1.0000000 NaN NaN NaN 1.0000000 + [57] 0.0000000 0.0000000 NaN NaN 1.0000000 1.0000000 0.1111111 + [64] NaN NaN 0.9999000 NaN NaN 0.0000000 NaN + [71] 1.0000000 1.0000000 NaN NaN NaN 1.0000000 NaN + [78] NaN NaN NaN 0.0000000 0.0000000 NaN NaN + [85] NaN 1.0000000 0.2000000 1.0000000 NaN NaN 1.0000000 + [92] 1.0000000 0.0000000 NaN NaN 1.0000000 NaN NaN + [99] 0.0000000 NaN 0.0000000 0.0000000 NaN NaN NaN +[106] 0.9090909 NaN NaN NaN NaN 0.6000000 1.0000000 +[113] NaN NaN NaN 1.0000000 0.0000000 0.0000000 NaN +[120] NaN +Warning message: +In punif(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); punif(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, -0.1, 0.0001), 20), lower.tail=TRUE, log.p=TRUE) + [1] 0.000000000 0.000000000 -2.197224577 NaN NaN + [6] -0.000099995 NaN NaN -Inf NaN + [11] 0.000000000 0.000000000 NaN NaN NaN + [16] 0.000000000 NaN NaN NaN NaN + [21] -Inf -Inf NaN NaN NaN + [26] 0.000000000 -1.609437912 0.000000000 NaN NaN + [31] 0.000000000 0.000000000 -Inf NaN NaN + [36] 0.000000000 NaN NaN -Inf NaN + [41] -Inf -Inf NaN NaN NaN + [46] -0.095310180 NaN NaN NaN NaN + [51] -0.510825624 0.000000000 NaN NaN NaN + [56] 0.000000000 -Inf -Inf NaN NaN + [61] 0.000000000 0.000000000 -2.197224577 NaN NaN + [66] -0.000099995 NaN NaN -Inf NaN + [71] 0.000000000 0.000000000 NaN NaN NaN + [76] 0.000000000 NaN NaN NaN NaN + [81] -Inf -Inf NaN NaN NaN + [86] 0.000000000 -1.609437912 0.000000000 NaN NaN + [91] 0.000000000 0.000000000 -Inf NaN NaN + [96] 0.000000000 NaN NaN -Inf NaN +[101] -Inf -Inf NaN NaN NaN +[106] -0.095310180 NaN NaN NaN NaN +[111] -0.510825624 0.000000000 NaN NaN NaN +[116] 0.000000000 -Inf -Inf NaN NaN +Warning message: +In punif(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); punif(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5), rep(c(1, 0, 0.1), 5)) + [1] NA 1 NaN 1 0 NA 0 NaN 1 0 NA 0 NaN 1 0 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); punif(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5)) + [1] NA 1 NaN NaN NaN NA 1 NaN NaN NaN NA 1 NaN NaN NaN +Warning message: +In punif(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0), rep(c(1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); punif(rep(c(1, 0, 0.1), 5), rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) + [1] NA 1 NaN NaN NaN NA NaN NaN NaN NaN NA NaN NaN NaN NaN +Warning message: +In punif(rep(c(1, 0, 0.1), 5), rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qbeta(0, 10, 10, lower.tail=FALSE, log.p=FALSE) +[1] 1 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qbeta(0, 10, 10, lower.tail=FALSE, log.p=TRUE) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qbeta(0, 10, 10, lower.tail=TRUE, log.p=FALSE) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qbeta(0, 10, 10, lower.tail=TRUE, log.p=TRUE) +[1] 1 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qbeta(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), rep(c(0.0653, 0.000123, 32e-80, 8833, 79e70), 7), lower.tail=FALSE, log.p=FALSE) + [1] 1 1 1 1 1 1 NaN 1 1 1 1 1 1 NaN 1 1 1 1 1 +[20] 1 NaN 1 1 1 1 1 1 NaN 1 1 1 1 1 1 NaN +Warning message: +In qbeta(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qbeta(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), rep(c(0.0653, 0.000123, 32e-80, 8833, 79e70), 7), lower.tail=FALSE, log.p=TRUE) + [1] 0 0 0 0 0 0 NaN 0 0 0 0 0 0 NaN 0 0 0 0 0 +[20] 0 NaN 0 0 0 0 0 0 NaN 0 0 0 0 0 0 NaN +Warning message: +In qbeta(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qbeta(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), rep(c(0.0653, 0.000123, 32e-80, 8833, 79e70), 7), lower.tail=TRUE, log.p=FALSE) + [1] 0 0 0 0 0 0 NaN 0 0 0 0 0 0 NaN 0 0 0 0 0 +[20] 0 NaN 0 0 0 0 0 0 NaN 0 0 0 0 0 0 NaN +Warning message: +In qbeta(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qbeta(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), rep(c(0.0653, 0.000123, 32e-80, 8833, 79e70), 7), lower.tail=TRUE, log.p=TRUE) + [1] 1 1 1 1 1 1 NaN 1 1 1 1 1 1 NaN 1 1 1 1 1 +[20] 1 NaN 1 1 1 1 1 1 NaN 1 1 1 1 1 1 NaN +Warning message: +In qbeta(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qbeta(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, -0.1, 0.0001), 20), lower.tail=FALSE, log.p=FALSE) + [1] NaN 1.0000000 0.1073742 NaN NaN NaN NaN + [8] NaN NaN 1.0000000 NaN NaN NaN 1.0000000 + [15] 0.9283178 NaN NaN 1.0000000 NaN NaN NaN + [22] 1.0000000 NaN NaN NaN NaN 0.0000000 NaN + [29] NaN 1.0000000 NaN NaN NaN 1.0000000 NaN + [36] NaN NaN 1.0000000 0.7804089 NaN NaN 1.0000000 + [43] NaN NaN NaN NaN NaN NaN NaN + [50] 1.0000000 NaN NaN NaN 1.0000000 NaN NaN + [57] NaN 1.0000000 NaN NaN NaN 1.0000000 0.1073742 + [64] NaN NaN NaN NaN NaN NaN 1.0000000 + [71] NaN NaN NaN 1.0000000 0.9283178 NaN NaN + [78] 1.0000000 NaN NaN NaN 1.0000000 NaN NaN + [85] NaN NaN 0.0000000 NaN NaN 1.0000000 NaN + [92] NaN NaN 1.0000000 NaN NaN NaN 1.0000000 + [99] 0.7804089 NaN NaN 1.0000000 NaN NaN NaN +[106] NaN NaN NaN NaN 1.0000000 NaN NaN +[113] NaN 1.0000000 NaN NaN NaN 1.0000000 NaN +[120] NaN +Warning message: +In qbeta(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qbeta(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, -0.1, 0.0001), 20), lower.tail=FALSE, log.p=TRUE) + [1] NaN 0.00000000 NaN NaN NaN NaN + [7] NaN NaN 0.60071237 0.00000000 NaN NaN + [13] NaN 0.00000000 NaN NaN NaN 0.00000000 + [19] NaN NaN NaN 0.00000000 NaN NaN + [25] NaN NaN NaN NaN NaN 0.00000000 + [31] NaN NaN 0.01018589 0.00000000 NaN NaN + [37] NaN 0.00000000 NaN NaN NaN 0.00000000 + [43] NaN NaN 0.85822265 NaN NaN NaN + [49] NaN 0.00000000 NaN NaN NaN 0.00000000 + [55] NaN NaN 0.00000000 0.00000000 NaN NaN + [61] NaN 0.00000000 NaN NaN NaN NaN + [67] NaN NaN 0.60071237 0.00000000 NaN NaN + [73] NaN 0.00000000 NaN NaN NaN 0.00000000 + [79] NaN NaN NaN 0.00000000 NaN NaN + [85] NaN NaN NaN NaN NaN 0.00000000 + [91] NaN NaN 0.01018589 0.00000000 NaN NaN + [97] NaN 0.00000000 NaN NaN NaN 0.00000000 +[103] NaN NaN 0.85822265 NaN NaN NaN +[109] NaN 0.00000000 NaN NaN NaN 0.00000000 +[115] NaN NaN 0.00000000 0.00000000 NaN NaN +Warning message: +In qbeta(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qbeta(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, -0.1, 0.0001), 20), lower.tail=TRUE, log.p=FALSE) + [1] NaN 0.0000000000 0.0000001024 NaN NaN + [6] NaN NaN NaN NaN 0.0000000000 + [11] NaN NaN NaN 0.0000000000 0.5848035476 + [16] NaN NaN 0.0000000000 NaN NaN + [21] NaN 0.0000000000 NaN NaN NaN + [26] NaN 0.0000000000 NaN NaN 0.0000000000 + [31] NaN NaN NaN 0.0000000000 NaN + [36] NaN NaN 0.0000000000 0.1672502062 NaN + [41] NaN 0.0000000000 NaN NaN NaN + [46] NaN NaN NaN NaN 0.0000000000 + [51] NaN NaN NaN 0.0000000000 NaN + [56] NaN NaN 0.0000000000 NaN NaN + [61] NaN 0.0000000000 0.0000001024 NaN NaN + [66] NaN NaN NaN NaN 0.0000000000 + [71] NaN NaN NaN 0.0000000000 0.5848035476 + [76] NaN NaN 0.0000000000 NaN NaN + [81] NaN 0.0000000000 NaN NaN NaN + [86] NaN 0.0000000000 NaN NaN 0.0000000000 + [91] NaN NaN NaN 0.0000000000 NaN + [96] NaN NaN 0.0000000000 0.1672502062 NaN +[101] NaN 0.0000000000 NaN NaN NaN +[106] NaN NaN NaN NaN 0.0000000000 +[111] NaN NaN NaN 0.0000000000 NaN +[116] NaN NaN 0.0000000000 NaN NaN +Warning message: +In qbeta(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qbeta(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, -0.1, 0.0001), 20), lower.tail=TRUE, log.p=TRUE) + [1] NaN 1.000000e+00 NaN NaN NaN + [6] NaN NaN NaN 3.291930e-01 1.000000e+00 + [11] NaN NaN NaN 1.000000e+00 NaN + [16] NaN NaN 1.000000e+00 NaN NaN + [21] NaN 1.000000e+00 NaN NaN NaN + [26] NaN NaN NaN NaN 1.000000e+00 + [31] NaN NaN 4.539993e-05 1.000000e+00 NaN + [36] NaN NaN 1.000000e+00 NaN NaN + [41] NaN 1.000000e+00 NaN NaN 7.165313e-01 + [46] NaN NaN NaN NaN 1.000000e+00 + [51] NaN NaN NaN 1.000000e+00 NaN + [56] NaN 0.000000e+00 1.000000e+00 NaN NaN + [61] NaN 1.000000e+00 NaN NaN NaN + [66] NaN NaN NaN 3.291930e-01 1.000000e+00 + [71] NaN NaN NaN 1.000000e+00 NaN + [76] NaN NaN 1.000000e+00 NaN NaN + [81] NaN 1.000000e+00 NaN NaN NaN + [86] NaN NaN NaN NaN 1.000000e+00 + [91] NaN NaN 4.539993e-05 1.000000e+00 NaN + [96] NaN NaN 1.000000e+00 NaN NaN +[101] NaN 1.000000e+00 NaN NaN 7.165313e-01 +[106] NaN NaN NaN NaN 1.000000e+00 +[111] NaN NaN NaN 1.000000e+00 NaN +[116] NaN 0.000000e+00 1.000000e+00 NaN NaN +Warning message: +In qbeta(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qbeta(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5), rep(c(1, 0, 0.1), 5)) + [1] NA 0 NaN NaN NaN NA 0 NaN NaN NaN NA 0 NaN NaN NaN +Warning message: +In qbeta(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5), rep(c(1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qbeta(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5)) + [1] NA 0 NaN 1 NaN NA 1 NaN 1 NaN NA 0 NaN 0 NaN +Warning message: +In qbeta(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0), rep(c(1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qbeta(rep(c(1, 0, 0.1), 5), rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) + [1] NA 0 NaN 1 NaN NA 1 NaN 0 NaN NA 1 NaN 0 NaN +Warning message: +In qbeta(rep(c(1, 0, 0.1), 5), rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, : + NaNs produced + ##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# #set.seed(1); qbinom(0, 10, 10, lower.tail=FALSE, log.p=FALSE) [1] NaN @@ -116966,6 +118121,190 @@ Warning message: In qcauchy(rep(c(1, 0, 0.1), 5), rep(c(1, 0, 0.1), 5), c(NA, 0, : NaNs produced +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qf(0, 10, 10, lower.tail=FALSE, log.p=FALSE) +[1] Inf + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qf(0, 10, 10, lower.tail=FALSE, log.p=TRUE) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qf(0, 10, 10, lower.tail=TRUE, log.p=FALSE) +[1] 0 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qf(0, 10, 10, lower.tail=TRUE, log.p=TRUE) +[1] Inf + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qf(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), rep(c(0.0653, 0.000123, 32e-80, 8833, 79e70), 7), lower.tail=FALSE, log.p=FALSE) + [1] Inf Inf Inf Inf Inf NaN NaN Inf Inf Inf Inf Inf NaN NaN Inf Inf Inf Inf Inf +[20] NaN NaN Inf Inf Inf Inf Inf NaN NaN Inf Inf Inf Inf Inf NaN NaN +Warning message: +In qf(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), rep(c(0.0653, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qf(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), rep(c(0.0653, 0.000123, 32e-80, 8833, 79e70), 7), lower.tail=FALSE, log.p=TRUE) + [1] 0 0 0 0 0 NaN NaN 0 0 0 0 0 NaN NaN 0 0 0 0 0 +[20] NaN NaN 0 0 0 0 0 NaN NaN 0 0 0 0 0 NaN NaN +Warning message: +In qf(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), rep(c(0.0653, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qf(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), rep(c(0.0653, 0.000123, 32e-80, 8833, 79e70), 7), lower.tail=TRUE, log.p=FALSE) + [1] 0 0 0 0 0 NaN NaN 0 0 0 0 0 NaN NaN 0 0 0 0 0 +[20] NaN NaN 0 0 0 0 0 NaN NaN 0 0 0 0 0 NaN NaN +Warning message: +In qf(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), rep(c(0.0653, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qf(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), rep(c(0.0653, 0.000123, 32e-80, 8833, 79e70), 7), lower.tail=TRUE, log.p=TRUE) + [1] Inf Inf Inf Inf Inf NaN NaN Inf Inf Inf Inf Inf NaN NaN Inf Inf Inf Inf Inf +[20] NaN NaN Inf Inf Inf Inf Inf NaN NaN Inf Inf Inf Inf Inf NaN NaN +Warning message: +In qf(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), rep(c(0.0653, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qf(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, -0.1, 0.0001), 20), lower.tail=FALSE, log.p=FALSE) + [1] NaN NaN 0.4368535 NaN NaN NaN + [7] NaN NaN NaN Inf NaN NaN + [13] NaN NaN 13.0639281 NaN NaN Inf + [19] NaN NaN NaN NaN NaN NaN + [25] NaN NaN NaN NaN NaN Inf + [31] NaN NaN NaN Inf NaN NaN + [37] NaN NaN 9.0192419 NaN NaN NaN + [43] NaN NaN NaN NaN NaN NaN + [49] NaN NaN NaN NaN NaN Inf + [55] NaN NaN NaN Inf NaN NaN + [61] NaN NaN 0.4368535 NaN NaN NaN + [67] NaN NaN NaN Inf NaN NaN + [73] NaN NaN 13.0639281 NaN NaN Inf + [79] NaN NaN NaN NaN NaN NaN + [85] NaN NaN NaN NaN NaN Inf + [91] NaN NaN NaN Inf NaN NaN + [97] NaN NaN 9.0192419 NaN NaN NaN +[103] NaN NaN NaN NaN NaN NaN +[109] NaN NaN NaN NaN NaN Inf +[115] NaN NaN NaN Inf NaN NaN +Warning message: +In qf(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qf(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, -0.1, 0.0001), 20), lower.tail=FALSE, log.p=TRUE) + [1] NaN NaN NaN NaN NaN NaN + [7] NaN NaN 2.19885391 0.00000000 NaN NaN + [13] NaN NaN NaN NaN NaN 0.00000000 + [19] NaN NaN NaN NaN NaN NaN + [25] NaN NaN NaN NaN NaN 0.00000000 + [31] NaN NaN 0.00384456 0.00000000 NaN NaN + [37] NaN NaN NaN NaN NaN NaN + [43] NaN NaN 3.54447244 NaN NaN NaN + [49] NaN NaN NaN NaN NaN 0.00000000 + [55] NaN NaN NaN 0.00000000 NaN NaN + [61] NaN NaN NaN NaN NaN NaN + [67] NaN NaN 2.19885391 0.00000000 NaN NaN + [73] NaN NaN NaN NaN NaN 0.00000000 + [79] NaN NaN NaN NaN NaN NaN + [85] NaN NaN NaN NaN NaN 0.00000000 + [91] NaN NaN 0.00384456 0.00000000 NaN NaN + [97] NaN NaN NaN NaN NaN NaN +[103] NaN NaN 3.54447244 NaN NaN NaN +[109] NaN NaN NaN NaN NaN 0.00000000 +[115] NaN NaN NaN 0.00000000 NaN NaN +Warning message: +In qf(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qf(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, -0.1, 0.0001), 20), lower.tail=TRUE, log.p=FALSE) + [1] NaN NaN 3.885781e-13 NaN NaN + [6] NaN NaN NaN NaN 0.000000e+00 + [11] NaN NaN NaN NaN 3.728274e-01 + [16] NaN NaN 0.000000e+00 NaN NaN + [21] NaN NaN NaN NaN NaN + [26] NaN NaN NaN NaN 0.000000e+00 + [31] NaN NaN NaN 0.000000e+00 NaN + [36] NaN NaN NaN 8.286649e-02 NaN + [41] NaN NaN NaN NaN NaN + [46] NaN NaN NaN NaN NaN + [51] NaN NaN NaN 0.000000e+00 NaN + [56] NaN NaN 0.000000e+00 NaN NaN + [61] NaN NaN 3.885781e-13 NaN NaN + [66] NaN NaN NaN NaN 0.000000e+00 + [71] NaN NaN NaN NaN 3.728274e-01 + [76] NaN NaN 0.000000e+00 NaN NaN + [81] NaN NaN NaN NaN NaN + [86] NaN NaN NaN NaN 0.000000e+00 + [91] NaN NaN NaN 0.000000e+00 NaN + [96] NaN NaN NaN 8.286649e-02 NaN +[101] NaN NaN NaN NaN NaN +[106] NaN NaN NaN NaN NaN +[111] NaN NaN NaN 0.000000e+00 NaN +[116] NaN NaN 0.000000e+00 NaN NaN +Warning message: +In qf(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qf(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, -0.1, 0.0001), 20), lower.tail=TRUE, log.p=TRUE) + [1] NaN NaN NaN NaN NaN + [6] NaN NaN NaN 3.712400e-01 Inf + [11] NaN NaN NaN NaN NaN + [16] NaN NaN Inf NaN NaN + [21] NaN NaN NaN NaN NaN + [26] NaN NaN NaN NaN Inf + [31] NaN NaN 7.636093e-08 Inf NaN + [36] NaN NaN NaN NaN NaN + [41] NaN NaN NaN NaN 8.941077e-01 + [46] NaN NaN NaN NaN NaN + [51] NaN NaN NaN Inf NaN + [56] NaN NaN Inf NaN NaN + [61] NaN NaN NaN NaN NaN + [66] NaN NaN NaN 3.712400e-01 Inf + [71] NaN NaN NaN NaN NaN + [76] NaN NaN Inf NaN NaN + [81] NaN NaN NaN NaN NaN + [86] NaN NaN NaN NaN Inf + [91] NaN NaN 7.636093e-08 Inf NaN + [96] NaN NaN NaN NaN NaN +[101] NaN NaN NaN NaN 8.941077e-01 +[106] NaN NaN NaN NaN NaN +[111] NaN NaN NaN Inf NaN +[116] NaN NaN Inf NaN NaN +Warning message: +In qf(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qf(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5), rep(c(1, 0, 0.1), 5)) + [1] NA NaN NaN NaN NaN NA 0 NaN NaN NaN NA 0 NaN NaN NaN +Warning message: +In qf(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5), rep(c(1, 0, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qf(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5)) + [1] NA NaN NaN Inf NaN NA NaN NaN + [9] 0.655161 NaN NA NaN NaN NaN NaN +Warning message: +In qf(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qf(rep(c(1, 0, 0.1), 5), rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) + [1] NA NaN NaN Inf NaN + [6] NA NaN NaN 1.168926e-19 NaN +[11] NA NaN NaN NaN NaN +Warning message: +In qf(rep(c(1, 0, 0.1), 5), rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, : + NaNs produced + ##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# #set.seed(1); qlnorm(0, 10, 10, lower.tail=FALSE, log.p=FALSE) [1] Inf @@ -117441,6 +118780,177 @@ Warning message: In qnorm(rep(c(1, 0, 0.1), 5), rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, : NaNs produced +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qunif(0, 10, 10, lower.tail=FALSE, log.p=FALSE) +[1] 10 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qunif(0, 10, 10, lower.tail=FALSE, log.p=TRUE) +[1] 10 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qunif(0, 10, 10, lower.tail=TRUE, log.p=FALSE) +[1] 10 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qunif(0, 10, 10, lower.tail=TRUE, log.p=TRUE) +[1] 10 + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qunif(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), rep(c(0.0653, 0.000123, 32e-80, 8833, 79e70), 7), lower.tail=FALSE, log.p=FALSE) + [1] 6.530e-02 1.230e-04 3.200e-79 8.833e+03 7.900e+71 6.530e-02 1.230e-04 + [8] NaN 8.833e+03 7.900e+71 NaN NaN 3.200e-79 8.833e+03 +[15] 7.900e+71 6.530e-02 1.230e-04 NaN NaN 7.900e+71 6.530e-02 +[22] NaN NaN 8.833e+03 7.900e+71 NaN 1.230e-04 0.000e+00 +[29] 8.833e+03 7.900e+71 6.530e-02 NaN NaN 8.833e+03 7.900e+71 +Warning message: +In qunif(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qunif(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), rep(c(0.0653, 0.000123, 32e-80, 8833, 79e70), 7), lower.tail=FALSE, log.p=TRUE) + [1] 6.530e-02 1.230e-04 3.200e-79 8.833e+03 7.900e+71 0.000e+00 + [7] -1.000e+00 NaN 1.230e-04 3.200e-79 NaN NaN +[13] 0.000e+00 -1.000e+00 6.530e-02 1.230e-04 3.200e-79 NaN +[19] NaN 0.000e+00 -1.000e+00 NaN NaN 3.200e-79 +[25] 8.833e+03 NaN 0.000e+00 -1.000e+00 6.530e-02 1.230e-04 +[31] 3.200e-79 NaN NaN 0.000e+00 -1.000e+00 +Warning message: +In qunif(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qunif(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), rep(c(0.0653, 0.000123, 32e-80, 8833, 79e70), 7), lower.tail=TRUE, log.p=FALSE) + [1] 6.530e-02 1.230e-04 3.200e-79 8.833e+03 7.900e+71 0.000e+00 + [7] -1.000e+00 NaN 1.230e-04 3.200e-79 NaN NaN +[13] 0.000e+00 -1.000e+00 6.530e-02 1.230e-04 3.200e-79 NaN +[19] NaN 0.000e+00 -1.000e+00 NaN NaN 3.200e-79 +[25] 8.833e+03 NaN 0.000e+00 -1.000e+00 6.530e-02 1.230e-04 +[31] 3.200e-79 NaN NaN 0.000e+00 -1.000e+00 +Warning message: +In qunif(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qunif(0, c(0.0653, 0.000123, 32e-80, 8833, 79e70, 0, -1), rep(c(0.0653, 0.000123, 32e-80, 8833, 79e70), 7), lower.tail=TRUE, log.p=TRUE) + [1] 6.530e-02 1.230e-04 3.200e-79 8.833e+03 7.900e+71 6.530e-02 1.230e-04 + [8] NaN 8.833e+03 7.900e+71 NaN NaN 3.200e-79 8.833e+03 +[15] 7.900e+71 6.530e-02 1.230e-04 NaN NaN 7.900e+71 6.530e-02 +[22] NaN NaN 8.833e+03 7.900e+71 NaN 1.230e-04 0.000e+00 +[29] 8.833e+03 7.900e+71 6.530e-02 NaN NaN 8.833e+03 7.900e+71 +Warning message: +In qunif(0, c(0.0653, 0.000123, 3.2e-79, 8833, 7.9e+71, 0, -1), : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qunif(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, -0.1, 0.0001), 20), lower.tail=FALSE, log.p=FALSE) + [1] NaN 0.0000 0.8200 NaN NaN 0.0001 NaN NaN NaN + [10] NaN -0.2800 NaN NaN NaN NaN NaN NaN NaN + [19] NaN NaN NaN 0.1000 NaN NaN NaN 0.0000 0.8000 + [28] NaN NaN NaN -1.0000 NaN NaN NaN NaN NaN + [37] NaN NaN 0.9800 NaN NaN 0.0001 NaN NaN NaN + [46] 0.1000 NaN NaN NaN NaN 0.6000 NaN NaN NaN + [55] NaN NaN NaN 0.1000 NaN NaN NaN 0.0000 0.8200 + [64] NaN NaN 0.0001 NaN NaN NaN NaN -0.2800 NaN + [73] NaN NaN NaN NaN NaN NaN NaN NaN NaN + [82] 0.1000 NaN NaN NaN 0.0000 0.8000 NaN NaN NaN + [91] -1.0000 NaN NaN NaN NaN NaN NaN NaN 0.9800 +[100] NaN NaN 0.0001 NaN NaN NaN 0.1000 NaN NaN +[109] NaN NaN 0.6000 NaN NaN NaN NaN NaN NaN +[118] 0.1000 NaN NaN +Warning message: +In qunif(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qunif(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, -0.1, 0.0001), 20), lower.tail=FALSE, log.p=TRUE) + [1] -1.0000000 0.0000000 NaN NaN NaN -1.0000000 + [7] NaN NaN 0.9632121 NaN NaN NaN + [13] NaN NaN NaN NaN NaN NaN + [19] NaN NaN 0.2642411 0.0000000 NaN NaN + [25] NaN -1.0000000 NaN NaN NaN NaN + [31] NaN NaN 0.6689085 NaN NaN NaN + [37] NaN NaN NaN NaN -0.4310915 0.0000000 + [43] NaN NaN NaN -1.0000000 NaN NaN + [49] NaN NaN NaN NaN NaN NaN + [55] NaN NaN 0.6321206 0.1000000 NaN NaN + [61] -1.0000000 0.0000000 NaN NaN NaN -1.0000000 + [67] NaN NaN 0.9632121 NaN NaN NaN + [73] NaN NaN NaN NaN NaN NaN + [79] NaN NaN 0.2642411 0.0000000 NaN NaN + [85] NaN -1.0000000 NaN NaN NaN NaN + [91] NaN NaN 0.6689085 NaN NaN NaN + [97] NaN NaN NaN NaN -0.4310915 0.0000000 +[103] NaN NaN NaN -1.0000000 NaN NaN +[109] NaN NaN NaN NaN NaN NaN +[115] NaN NaN 0.6321206 0.1000000 NaN NaN +Warning message: +In qunif(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qunif(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, -0.1, 0.0001), 20), lower.tail=TRUE, log.p=FALSE) + [1] NaN 0.00 0.28 NaN NaN -1.00 NaN NaN NaN NaN -0.82 NaN + [13] NaN NaN NaN NaN NaN NaN NaN NaN NaN 0.00 NaN NaN + [25] NaN -1.00 0.20 NaN NaN NaN -1.00 NaN NaN NaN NaN NaN + [37] NaN NaN 0.92 NaN NaN 0.00 NaN NaN NaN -1.00 NaN NaN + [49] NaN NaN -0.60 NaN NaN NaN NaN NaN NaN 0.10 NaN NaN + [61] NaN 0.00 0.28 NaN NaN -1.00 NaN NaN NaN NaN -0.82 NaN + [73] NaN NaN NaN NaN NaN NaN NaN NaN NaN 0.00 NaN NaN + [85] NaN -1.00 0.20 NaN NaN NaN -1.00 NaN NaN NaN NaN NaN + [97] NaN NaN 0.92 NaN NaN 0.00 NaN NaN NaN -1.00 NaN NaN +[109] NaN NaN -0.60 NaN NaN NaN NaN NaN NaN 0.10 NaN NaN +Warning message: +In qunif(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qunif(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, -0.1, 0.0001), 20), lower.tail=TRUE, log.p=TRUE) + [1] -1.0000000 0.0000000 NaN NaN NaN 0.0001000 + [7] NaN NaN 0.9367879 NaN NaN NaN + [13] NaN NaN NaN NaN NaN NaN + [19] NaN NaN -0.2642411 0.1000000 NaN NaN + [25] NaN 0.0000000 NaN NaN NaN NaN + [31] NaN NaN 0.4310915 NaN NaN NaN + [37] NaN NaN NaN NaN -0.6689085 0.0001000 + [43] NaN NaN NaN 0.1000000 NaN NaN + [49] NaN NaN NaN NaN NaN NaN + [55] NaN NaN 0.3678794 0.1000000 NaN NaN + [61] -1.0000000 0.0000000 NaN NaN NaN 0.0001000 + [67] NaN NaN 0.9367879 NaN NaN NaN + [73] NaN NaN NaN NaN NaN NaN + [79] NaN NaN -0.2642411 0.1000000 NaN NaN + [85] NaN 0.0000000 NaN NaN NaN NaN + [91] NaN NaN 0.4310915 NaN NaN NaN + [97] NaN NaN NaN NaN -0.6689085 0.0001000 +[103] NaN NaN NaN 0.1000000 NaN NaN +[109] NaN NaN NaN NaN NaN NaN +[115] NaN NaN 0.3678794 0.1000000 NaN NaN +Warning message: +In qunif(c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qunif(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5), rep(c(1, 0, 0.1), 5)) + [1] NA 0.0 NaN NaN NaN NA 1.0 NaN NaN NaN NA 0.1 NaN NaN NaN +Warning message: +In qunif(c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5), rep(c(1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qunif(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0), rep(c(1, 0, 0.1), 5)) + [1] NA 0.00 NaN NaN NaN NA 1.00 NaN NaN NaN NA 0.01 NaN NaN NaN +Warning message: +In qunif(rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0), rep(c(1, : + NaNs produced + +##com.oracle.truffle.r.test.library.stats.TestStatFunctions.testFunctions32#Output.MayIgnoreWarningContext# +#set.seed(1); qunif(rep(c(1, 0, 0.1), 5), rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)) + [1] NA 0 NaN NaN NaN NA NaN NaN NaN NaN NA NaN NaN NaN NaN +Warning message: +In qunif(rep(c(1, 0, 0.1), 5), rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, : + NaNs produced + ##com.oracle.truffle.r.test.library.stats.TestStats.testCor# #{ as.integer(cor(c(1,2,3),c(1,2,5))*10000000) } [1] 9607689 diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestConditionHandling.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestConditionHandling.java index 938ca47fe03c098ecc428a49f5514d0877a01ebd..2aff030fb231737e9ef235ccda7fe76c4f3a44f8 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestConditionHandling.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestConditionHandling.java @@ -32,8 +32,11 @@ public class TestConditionHandling extends TestBase { public void testTryCatch() { assertEval("{ tryCatch(1, finally = print(\"Hello\")) }"); assertEval("{ e <- simpleError(\"test error\"); tryCatch(stop(e), finally = print(\"Hello\")) }"); + assertEval("{ e <- simpleError(\"test error\"); f <- function() { tryCatch(1, finally = print(\"Hello\")); stop(e)}; f() }"); assertEval(Output.IgnoreErrorContext, "{ tryCatch(stop(\"fred\"), finally = print(\"Hello\")) }"); assertEval("{ e <- simpleError(\"test error\"); tryCatch(stop(e), error = function(e) e, finally = print(\"Hello\"))}"); assertEval(Ignored.Unknown, "{ tryCatch(stop(\"fred\"), error = function(e) e, finally = print(\"Hello\"))}"); + assertEval("{ f <- function() { tryCatch(1, error = function(e) print(\"Hello\")); stop(\"fred\")}; f() }"); + assertEval("{ f <- function() { tryCatch(stop(\"fred\"), error = function(e) print(\"Hello\"))}; f() }"); } } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestExternal_qbeta.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestExternal_qbeta.java new file mode 100644 index 0000000000000000000000000000000000000000..742c7170856fede28c45fb7a453b5594720982a1 --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestExternal_qbeta.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.oracle.truffle.r.test.library.stats; + +import static com.oracle.truffle.r.test.library.stats.TestStatFunctions.PROBABILITIES; + +import org.junit.Test; + +import com.oracle.truffle.r.test.TestBase; + +/** + * Additional tests on the top of {@link TestStatFunctions}. + */ +public class TestExternal_qbeta extends TestBase { + private static final String[] BOOL_VALUES = new String[]{"T", "F"}; + + @Test + public void testQBeta() { + // check if in qbeta_raw with comment "p==0, q==0, p = Inf, q = Inf <==> treat as one- or + // two-point mass" + assertEval(template("qbeta(0.7, 0, 1/0, lower.tail=%0, log.p=F)", BOOL_VALUES)); + assertEval(template("qbeta(log(0.7), 0, 1/0, lower.tail=%0, log.p=T)", BOOL_VALUES)); + assertEval(template("qbeta(0.7, 1/0, 0, lower.tail=%0, log.p=F)", BOOL_VALUES)); + assertEval(template("qbeta(log(0.7), 1/0, 0, lower.tail=%0, log.p=T)", BOOL_VALUES)); + assertEval(template("qbeta(%0, 0, 0, lower.tail=%1, log.p=F)", new String[]{"0.1", "0.5", "0.7"}, BOOL_VALUES)); + assertEval(template("qbeta(log(%0), 0, 0, lower.tail=%1, log.p=T)", new String[]{"0.1", "0.5", "0.7"}, BOOL_VALUES)); + // checks swap_tail = (p_ > 0.5) where for lower.tail = log.p = TRUE is p_ = exp(p) + // exp(0.1) = 1.10.... + assertEval(template("qbeta(log(%0), 0.1, 3, lower.tail=T, log.p=T)", PROBABILITIES)); + // exp(-1) = 0.36... + assertEval(Output.MayIgnoreWarningContext, template("qbeta(log(%0), -1, 3, lower.tail=T, log.p=T)", PROBABILITIES)); + } +} diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestStatFunctions.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestStatFunctions.java index ffb14be2324ee9ec21996cf87158224635f0a134..c51783a3d07446236e11bddd69ca31c5544d4f74 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestStatFunctions.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/stats/TestStatFunctions.java @@ -30,7 +30,9 @@ import com.oracle.truffle.r.test.TestBase; * Common tests for functions implemented using {@code StatsFunctions} infrastructure. */ public class TestStatFunctions extends TestBase { - private static final String[] FUNCTION3_1_NAMES = {"dgamma", "dbeta", "dcauchy", "dlnorm", "dlogis"}; + public static final String[] PROBABILITIES = new String[]{"0", "42e-80", "0.1", "0.5", "0.7", "1-42e-80", "1"}; + + private static final String[] FUNCTION3_1_NAMES = {"dgamma", "dbeta", "dcauchy", "dlnorm", "dlogis", "dunif"}; private static final String[] FUNCTION3_1_PARAMS = { "10, 10, 10, log=TRUE", "3, 3, 3, log=FALSE", @@ -61,7 +63,7 @@ public class TestStatFunctions extends TestBase { assertEval(Output.IgnoreWhitespace, template("set.seed(1); %0(%1)", FUNCTION2_1_NAMES, FUNCTION2_1_PARAMS)); } - private static final String[] FUNCTION2_2_NAMES = {"pchisq", "pexp", "qexp", "qgeom"}; + private static final String[] FUNCTION2_2_NAMES = {"pchisq", "pexp", "qexp", "qgeom", "pgeom", "qt", "pt", "qpois", "ppois", "qchisq"}; private static final String[] FUNCTION2_2_PARAMS = { "0, 10", "c(-1, 0, 0.2, 2), rep(c(-1, 0, 0.1, 0.9, 3), 4)", @@ -80,7 +82,8 @@ public class TestStatFunctions extends TestBase { assertEval(Output.IgnoreWhitespace, template("set.seed(1); %0(%1)", FUNCTION2_2_NAMES, new String[]{"rep(c(1, 0, 0.1), 5), c(NA, 0, NaN, 1/0, -1/0)"})); } - private static final String[] FUNCTION3_2_NAMES = {"pbeta", "pcauchy", "qcauchy", "qlnorm", "plnorm", "qbinom", "pnorm", "qnorm", "qlogis", "pf", "pbinom", "plogis"}; + private static final String[] FUNCTION3_2_NAMES = {"pbeta", "pcauchy", "qcauchy", "qlnorm", "plnorm", "qbinom", "pnorm", "qnorm", "qlogis", "pf", "pbinom", "plogis", "punif", "qunif", "qbeta", + "qf"}; private static final String[] FUNCTION3_2_PARAMS = { "0, 10, 10", "c(-1, 0, 0.2, 2), c(-1, 0, 0.1, 0.9, 3), rep(c(-1, 0, 1, 0.1, -0.1, 0.0001), 20)", diff --git a/mx.fastr/copyrights/gnu_r_ihaka.copyright.star.regex b/mx.fastr/copyrights/gnu_r_ihaka.copyright.star.regex index f501f18d94af207fdf7bdb31d6ed504d3fe2713b..6d4963665815e19001d415014c005f60e8bfa49b 100644 --- a/mx.fastr/copyrights/gnu_r_ihaka.copyright.star.regex +++ b/mx.fastr/copyrights/gnu_r_ihaka.copyright.star.regex @@ -1 +1 @@ -/\*\n \* This material is distributed under the GNU General Public License\n \* Version 2. You may review the terms of this license at\n \* http://www.gnu.org/licenses/gpl-2.0.html\n \*\n \* Copyright \(C\) 1998 Ross Ihaka\n \* Copyright \(c\) (?:[1-2][09][0-9][0-9]--)?[1-2][09][0-9][0-9], The R Core Team\n \* Copyright \(c\) (?:[1-2][09][0-9][0-9]--)?[1-2][09][0-9][0-9], The R Foundation\n \* Copyright \(c\) (?:(20[0-9][0-9]), )?(20[0-9][0-9]), Oracle and/or its affiliates\n \*\n \* All rights reserved.\n \*/\n.* +/\*\n \* This material is distributed under the GNU General Public License\n \* Version 2. You may review the terms of this license at\n \* http://www.gnu.org/licenses/gpl-2.0.html\n \*\n \* Copyright \(C\) 1998 Ross Ihaka\n \* Copyright \(c\) (?:[1-2][09][0-9][0-9]--?)?[1-2][09][0-9][0-9], The R Core Team\n \* Copyright \(c\) (?:[1-2][09][0-9][0-9]--?)?[1-2][09][0-9][0-9], The R Foundation\n \* Copyright \(c\) (?:(20[0-9][0-9]), )?(20[0-9][0-9]), Oracle and/or its affiliates\n \*\n \* All rights reserved.\n \*/\n.* diff --git a/mx.fastr/copyrights/gnu_r_ihaka_core.copyright.star.regex b/mx.fastr/copyrights/gnu_r_ihaka_core.copyright.star.regex index f6aa3d2ffea7b64fd737bf54fc193fdb726a58e0..1bc53ecfd3018063d32ee5abccbcc45d2f7d5a89 100644 --- a/mx.fastr/copyrights/gnu_r_ihaka_core.copyright.star.regex +++ b/mx.fastr/copyrights/gnu_r_ihaka_core.copyright.star.regex @@ -1 +1 @@ -/\*\n \* This material is distributed under the GNU General Public License\n \* Version 2. You may review the terms of this license at\n \* http://www.gnu.org/licenses/gpl-2.0.html\n \*\n \* Copyright \(C\) 1998 Ross Ihaka\n \* Copyright \(c\) (?:[1-2][09][0-9][0-9]--)?[1-2][09][0-9][0-9], The R Core Team\n \* Copyright \(c\) (?:(20[0-9][0-9]), )?(20[0-9][0-9]), Oracle and/or its affiliates\n \*\n \* All rights reserved.\n \*/\n.* +/\*\n \* This material is distributed under the GNU General Public License\n \* Version 2. You may review the terms of this license at\n \* http://www.gnu.org/licenses/gpl-2.0.html\n \*\n \* Copyright \(C\) 1998 Ross Ihaka\n \* Copyright \(c\) (?:[1-2][09][0-9][0-9]--?)?[1-2][09][0-9][0-9], The R Core Team\n \* Copyright \(c\) (?:(20[0-9][0-9]), )?(20[0-9][0-9]), Oracle and/or its affiliates\n \*\n \* All rights reserved.\n \*/\n.* diff --git a/mx.fastr/copyrights/gnu_r_scan.copyright.star.regex b/mx.fastr/copyrights/gnu_r_scan.copyright.star.regex index b8d748ad4e6d7a169aac923745c54b9e21dc5801..a2b6bd808f74cf4378eede05500ff8c8420bbe94 100644 --- a/mx.fastr/copyrights/gnu_r_scan.copyright.star.regex +++ b/mx.fastr/copyrights/gnu_r_scan.copyright.star.regex @@ -1 +1 @@ -/\*\n \* This material is distributed under the GNU General Public License\n \* Version 2. You may review the terms of this license at\n \* http://www.gnu.org/licenses/gpl-2.0.html\n \*\n \* Copyright \(c\) 1995, 1996, Robert Gentleman and Ross Ihaka\n \* Copyright \(c\) 1998-2013, The R Core Team\n \* Copyright \(c\) (?:(20[0-9][0-9]), )?(20[0-9][0-9]), Oracle and/or its affiliates\n \*\n \* All rights reserved.\n \*/\n.* +/\*\n \* This material is distributed under the GNU General Public License\n \* Version 2. You may review the terms of this license at\n \* http://www.gnu.org/licenses/gpl-2.0.html\n \*\n \* Copyright \(c\) 1995, 1996, Robert Gentleman and Ross Ihaka\n \* Copyright \(c\) (?:[1-2][09][0-9][0-9]--?)?[1-2][09][0-9][0-9], The R Core Team\n \* Copyright \(c\) (?:(20[0-9][0-9]), )?(20[0-9][0-9]), Oracle and/or its affiliates\n \*\n \* All rights reserved.\n \*/\n.* diff --git a/mx.fastr/copyrights/overrides b/mx.fastr/copyrights/overrides index 1c597c2f2f1ae8c7bb469cf56adab4d268d55181..e97b3e340fd5e5195744be34e14dc31c229adc27 100644 --- a/mx.fastr/copyrights/overrides +++ b/mx.fastr/copyrights/overrides @@ -43,6 +43,8 @@ com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/DPQ.java,gnu com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Rt.java,gnu_r_ihaka_core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/GammaFunctions.java,gnu_r_qgamma.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/QHyper.java,gnu_r_ihaka_core.copyright +com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Qt.java,gnu_r_ihaka.copyright +com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Pt.java,gnu_r_scan.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RHyper.java,gnu_r_ihaka.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/MathInit.java,gnu_r.core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Pbeta.java,gnu_r.core.copyright @@ -50,11 +52,16 @@ com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/LBeta.java,g com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Pbinom.java,gnu_r_ihaka.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Pf.java,gnu_r_ihaka_core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Pnorm.java,gnu_r_ihaka.copyright +com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/PPois.java,gnu_r_ihaka_core.copyright +com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/QPois.java,gnu_r_ihaka_core.copyright +com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/QBeta.java,gnu_r_scan.copyright +com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Qf.java,gnu_r_ihaka.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Qbinom.java,gnu_r_ihaka.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Qnorm.java,gnu_r_ihaka.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Random2.java,gnu_r.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RPois.java,gnu_r_ihaka_core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Rbinom.java,gnu_r_ihaka.copyright +com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Unif.java,gnu_r_ihaka_core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Rnorm.java,gnu_r.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Chisq.java,gnu_r_ihaka_core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/SplineFunctions.java,gnu_r_splines.copyright @@ -70,7 +77,6 @@ com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RGamma.java, com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RNbinomMu.java,gnu_r_ihaka_core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Logis.java,gnu_r_ihaka_core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Rf.java,gnu_r_ihaka_core.copyright -com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RChisq.java,gnu_r_ihaka_core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Exp.java,gnu_r_ihaka_core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Geom.java,gnu_r_ihaka_core.copyright com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/Dt.java,gnu_r.core.copyright