BFComplex *ComplexPower_bf(BFComplex *t, BFComplex *xx, BFComplex *yy)
{
    BFComplex tmp;
    bf_t e2x, siny, cosy;
    int saved;
    saved = save_stack();
    e2x  = alloc_stack(rbflength+2);
    siny = alloc_stack(rbflength+2);
    cosy = alloc_stack(rbflength+2);
    tmp.x = alloc_stack(rbflength+2);
    tmp.y = alloc_stack(rbflength+2);

    // 0 raised to anything is 0
    if (is_bf_zero(xx->x) && is_bf_zero(xx->y))
    {
        clear_bf(t->x);
        clear_bf(t->y);
        return (t);
    }

    cmplxlog_bf(t, xx);
    cplxmul_bf(&tmp, t, yy);
    exp_bf(e2x, tmp.x);
    sincos_bf(siny, cosy, tmp.y);
    mult_bf(t->x, e2x, cosy);
    mult_bf(t->y, e2x, siny);
    restore_stack(saved);
    return (t);
}
Beispiel #2
0
// Calculate function required for the approximation.
bigfloat AlgRemez::func(const bigfloat x) {

  bigfloat z = (bigfloat)power_num / (bigfloat)power_den;
  bigfloat y;

  if (x == (bigfloat)1.0) y = (bigfloat)1.0;
  else y = pow_bf(x,z);

  if (a_length > 0) {
    bigfloat sum = 0l;
    for (int j=0; j<a_length; j++) sum += a[j]*pow_bf(x,a_power[j]);
    return y * exp_bf(sum);
  } else {
    return y;
  }

}