示例#1
0
complex_long_double               /*{ ret - Complex fraction       }*/
cdivd
(
  complex_long_double a,          /*{ (i) - Complex input `a`      }*/
  complex_long_double b           /*{ (i) - Complex input `b`      }*/
)
{
    complex_long_double    c;
    long double      fractio, denum;


    /*
       To prevent avoidable overflows, underflow or loss of precision,
       the following alternative algorithm is used:

       If |b.re| >= |b.im|
         c.re = (a.re + a.im * (b.im / b.re)) / (b.re + b.im * (b.im / b.re));
         c.im = (a.im - a.re * (b.im / b.re)) / (b.re + b.im * (b.im / b.re));

       Else    // |b.re| < |b.im|
         c.re = (a.re * (b.re / b.im) + a.im) / (b.re * (b.re / b.im) + b.im);
         c.im = (a.im * (b.re / b.im) - a.re) / (b.re * (b.re / b.im) + b.im);
     */

    if( (b.re == 0) && (b.im == 0) )
    {
       /* return +Inf */
       plus_inf.a[1] = 0x7FF00000;
       plus_inf.a[0] = 0x00000000;
       c.re = plus_inf.x;
       c.im = plus_inf.x;
    }
    else if (b.re == 0)
    {
       c.re =   a.im / b.im;
       c.im = -(a.re / b.im);
    }
    else if (b.im == 0)
    {
       c.re =   a.re / b.re;
       c.im =   a.im / b.re;
    }
    else if( fabsd(b.re) >= fabsd(b.im) )
    {
       fractio = b.im / b.re;
       denum   = 1.0L / (b.re + b.im * fractio);
       c.re    = (a.re + a.im * fractio) * denum;
       c.im    = (a.im - a.re * fractio) * denum;
    }
    else
    {
       fractio = b.re / b.im;
       denum   = 1.0L / (b.re * fractio + b.im);
       c.re    = (a.re * fractio + a.im) * denum;
       c.im    = (a.im * fractio - a.re) * denum;
    }

    return (c);
}
示例#2
0
void AdaptivePaddedAverage::sample(float new_sample) {
    // Compute new adaptive weighted average based on new sample.
    AdaptiveWeightedAverage::sample(new_sample);

    // Now update the deviation and the padded average.
    float new_avg = average();
    float new_dev = compute_adaptive_average(fabsd(new_sample - new_avg),
                    deviation());
    set_deviation(new_dev);
    set_padded_average(new_avg + padding() * new_dev);
    _last_sample = new_sample;
}
void AdaptivePaddedAverage::sample(double new_sample) {
  // Compute our parent classes sample information
  AdaptiveWeightedAverage::sample(new_sample);

  // Now compute the deviation and the new padded sample
  float new_avg = average();
  float new_dev = compute_adaptive_average(fabsd(new_sample - new_avg),
                                           deviation());
  set_deviation(new_dev);
  set_padded_average(new_avg + padding() * new_dev);
  _last_sample = new_sample;
}
示例#4
0
void AdaptivePaddedNoZeroDevAverage::sample(float new_sample) {
    // Compute our parent classes sample information
    AdaptiveWeightedAverage::sample(new_sample);

    float new_avg = average();
    if (new_sample != 0) {
        // We only create a new deviation if the sample is non-zero
        float new_dev = compute_adaptive_average(fabsd(new_sample - new_avg),
                        deviation());

        set_deviation(new_dev);
    }
    set_padded_average(new_avg + padding() * deviation());
    _last_sample = new_sample;
}
address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
  // rmethod: Method*
  // r13: sender sp
  // esp: args

  if (!InlineIntrinsics) return NULL; // Generate a vanilla entry

  // These don't need a safepoint check because they aren't virtually
  // callable. We won't enter these intrinsics from compiled code.
  // If in the future we added an intrinsic which was virtually callable
  // we'd have to worry about how to safepoint so that this code is used.

  // mathematical functions inlined by compiler
  // (interpreter must provide identical implementation
  // in order to avoid monotonicity bugs when switching
  // from interpreter to compiler in the middle of some
  // computation)
  //
  // stack:
  //        [ arg ] <-- esp
  //        [ arg ]
  // retaddr in lr

  address entry_point = NULL;
  Register continuation = lr;
  switch (kind) {
  case Interpreter::java_lang_math_abs:
    entry_point = __ pc();
    __ ldrd(v0, Address(esp));
    __ fabsd(v0, v0);
    __ mov(sp, r13); // Restore caller's SP
    break;
  case Interpreter::java_lang_math_sqrt:
    entry_point = __ pc();
    __ ldrd(v0, Address(esp));
    __ fsqrtd(v0, v0);
    __ mov(sp, r13);
    break;
  case Interpreter::java_lang_math_sin :
  case Interpreter::java_lang_math_cos :
  case Interpreter::java_lang_math_tan :
  case Interpreter::java_lang_math_log :
  case Interpreter::java_lang_math_log10 :
  case Interpreter::java_lang_math_exp :
    entry_point = __ pc();
    __ ldrd(v0, Address(esp));
    __ mov(sp, r13);
    __ mov(r19, lr);
    continuation = r19;  // The first callee-saved register
    generate_transcendental_entry(kind, 1);
    break;
  case Interpreter::java_lang_math_pow :
    entry_point = __ pc();
    __ mov(r19, lr);
    continuation = r19;
    __ ldrd(v0, Address(esp, 2 * Interpreter::stackElementSize));
    __ ldrd(v1, Address(esp));
    __ mov(sp, r13);
    generate_transcendental_entry(kind, 2);
    break;
  default:
    ;
  }
  if (entry_point) {
    __ br(continuation);
  }

  return entry_point;
}