int setAstronomyParameters(AstronomyParameters* ap, const BackgroundParameters* bgp)
{
    ap->alpha = bgp->alpha;
    ap->q     = bgp->q;

    ap->r0    = bgp->r0;
    ap->delta = bgp->delta;

    ap->q_inv = inv(ap->q);
    ap->q_inv_sqr = inv(sqr(ap->q));

    ap->aux_bg_profile = (bgp->a != 0.0) || (bgp->b != 0.0) || (bgp->c != 0.0);
    ap->bg_a = bgp->a;
    ap->bg_b = bgp->b;
    ap->bg_c = bgp->c;

    if (ap->convolve == 0 || ap->convolve > MAX_CONVOLVE || !mwEven(ap->convolve))
    {
        mw_printf("convolve (%u) must be > 0, <= 256 and even\n", ap->convolve);
        return 1;
    }

 //   ap->coeff = 1.0 / (stdev * SQRT_2PI);
    ap->alpha_delta3 = 3.0 - ap->alpha + ap->delta;

    ap->exp_background_weight = mw_exp(bgp->epsilon);
    //Check if we need to use fast or slow hernquist if we are not using Broken Power Law which doesn't care.
    if(ap->background_profile != BROKEN_POWER_LAW)
    {
    	if(ap->alpha == 1.0 && ap->delta == 1.0)
    	{
    		ap->background_profile = FAST_HERNQUIST;
    	}
    	else
    	{
    		ap->background_profile = SLOW_HERNQUIST;
    	}
    }

    ap->sun_r0 = const_sun_r0;
    ap->m_sun_r0 = -ap->sun_r0;

    return 0;
}
int setAstronomyParameters(AstronomyParameters* ap, const BackgroundParameters* bgp)
{
#ifdef ANDROID
    int armExt = mwDetectARMExt();
#endif

    ap->alpha = bgp->alpha;
    ap->q     = bgp->q;

    ap->r0    = bgp->r0;
    ap->delta = bgp->delta;

    ap->q_inv = inv(ap->q);
    ap->q_inv_sqr = inv(sqr(ap->q));

    ap->aux_bg_profile = (bgp->a != 0.0) || (bgp->b != 0.0) || (bgp->c != 0.0);
    ap->bg_a = bgp->a;
    ap->bg_b = bgp->b;
    ap->bg_c = bgp->c;
    
    if (ap->convolve == 0 || ap->convolve > 256 || !mwEven(ap->convolve))
    {
        warn("convolve (%u) must be > 0, <= 256 and even\n", ap->convolve);
        return 1;
    }

    ap->coeff = 1.0 / (stdev * SQRT_2PI);
    ap->alpha_delta3 = 3.0 - ap->alpha + ap->delta;

    ap->exp_background_weight = mw_exp(bgp->epsilon);
    ap->fast_h_prob = (ap->alpha == 1.0 && ap->delta == 1.0);

    ap->sun_r0 = const_sun_r0;
    ap->m_sun_r0 = -ap->sun_r0;

#ifdef ANDROID
    if (armExt==ARM_CPU_NOVFP && ap->fast_h_prob && ap->r0 < 0.0)
    {
        warn("IntFp Engine cant handle r0<0.0\n");
        return 1;
    }
#endif
    return 0;
}