public double execute(double in) throws DMLRuntimeException {
    switch (bFunc) {
      case SIN:
        return FASTMATH ? FastMath.sin(in) : Math.sin(in);
      case COS:
        return FASTMATH ? FastMath.cos(in) : Math.cos(in);
      case TAN:
        return FASTMATH ? FastMath.tan(in) : Math.tan(in);
      case ASIN:
        return FASTMATH ? FastMath.asin(in) : Math.asin(in);
      case ACOS:
        return FASTMATH ? FastMath.acos(in) : Math.acos(in);
      case ATAN:
        return Math.atan(in); // faster in Math
      case CEIL:
        return FASTMATH ? FastMath.ceil(in) : Math.ceil(in);
      case FLOOR:
        return FASTMATH ? FastMath.floor(in) : Math.floor(in);
      case LOG:
        return FASTMATH ? FastMath.log(in) : Math.log(in);
      case LOG_NZ:
        return (in == 0) ? 0 : FASTMATH ? FastMath.log(in) : Math.log(in);
      case ABS:
        return Math.abs(in); // no need for FastMath	
      case SIGN:
        return FASTMATH ? FastMath.signum(in) : Math.signum(in);
      case SQRT:
        return Math.sqrt(in); // faster in Math
      case EXP:
        return FASTMATH ? FastMath.exp(in) : Math.exp(in);
      case ROUND:
        return Math.round(in); // no need for FastMath

      case PLOGP:
        if (in == 0.0) return 0.0;
        else if (in < 0) return Double.NaN;
        else return (in * (FASTMATH ? FastMath.log(in) : Math.log(in)));

      case SPROP:
        // sample proportion: P*(1-P)
        return in * (1 - in);

      case SIGMOID:
        // sigmoid: 1/(1+exp(-x))
        return FASTMATH ? 1 / (1 + FastMath.exp(-in)) : 1 / (1 + Math.exp(-in));

      case SELP:
        // select positive: x*(x>0)
        return (in > 0) ? in : 0;

      default:
        throw new DMLRuntimeException("Builtin.execute(): Unknown operation: " + bFunc);
    }
  }
Example #2
0
 /**
  * {@inheritDoc}
  *
  * <p>Returns {@code Double.NEGATIVE_INFINITY} when {@code p == 0} and {@code
  * Double.POSITIVE_INFINITY} when {@code p == 1}.
  */
 @Override
 public double inverseCumulativeProbability(double p) throws OutOfRangeException {
   double ret;
   if (p < 0 || p > 1) {
     throw new OutOfRangeException(p, 0, 1);
   } else if (p == 0) {
     ret = Double.NEGATIVE_INFINITY;
   } else if (p == 1) {
     ret = Double.POSITIVE_INFINITY;
   } else {
     ret = median + scale * FastMath.tan(FastMath.PI * (p - .5));
   }
   return ret;
 }
  /**
   * Simple constructor.
   *
   * <p>The {@code applyBefore} parameter is mainly used when the differential effect is associated
   * with a maneuver. In this case, the parameter must be set to {@code false}.
   *
   * @param orbit0 original orbit at reference date
   * @param orbit1 shifted orbit at reference date
   * @param applyBefore if true, effect is applied both before and after reference date, if false it
   *     is only applied after reference date
   * @param referenceRadius reference radius of the Earth for the potential model (m)
   * @param mu central attraction coefficient (m³/s²)
   * @param j2 un-normalized zonal coefficient (about +1.08e-3 for Earth)
   */
  public J2DifferentialEffect(
      final Orbit orbit0,
      final Orbit orbit1,
      final boolean applyBefore,
      final double referenceRadius,
      final double mu,
      final double j2) {

    this.referenceDate = orbit0.getDate();
    this.applyBefore = applyBefore;

    // extract useful parameters
    final double a0 = orbit0.getA();
    final double e0 = orbit0.getE();
    final double i0 = orbit0.getI();
    final double a1 = orbit1.getA();
    final double e1 = orbit1.getE();
    final double i1 = orbit1.getI();

    // compute reference drifts
    final double oMe2 = 1 - e0 * e0;
    final double ratio = referenceRadius / (a0 * oMe2);
    final double cosI = FastMath.cos(i0);
    final double sinI = FastMath.sin(i0);
    final double n = FastMath.sqrt(mu / a0) / a0;
    final double c = ratio * ratio * n * j2;
    final double refPaDot = 0.75 * c * (4 - 5 * sinI * sinI);
    final double refRaanDot = -1.5 * c * cosI;

    // differential model on perigee argument drift
    final double dPaDotDa = -3.5 * refPaDot / a0;
    final double dPaDotDe = 4 * refPaDot * e0 / oMe2;
    final double dPaDotDi = -7.5 * c * sinI * cosI;
    dPaDot = dPaDotDa * (a1 - a0) + dPaDotDe * (e1 - e0) + dPaDotDi * (i1 - i0);

    // differential model on ascending node drift
    final double dRaanDotDa = -3.5 * refRaanDot / a0;
    final double dRaanDotDe = 4 * refRaanDot * e0 / oMe2;
    final double dRaanDotDi = -refRaanDot * FastMath.tan(i0);
    dRaanDot = dRaanDotDa * (a1 - a0) + dRaanDotDe * (e1 - e0) + dRaanDotDi * (i1 - i0);
  }