<commit_before>double form_volume(double rpolar, double requatorial);
double Iq(double q, double sld, double solvent_sld, double rpolar, double requatorial);
double Iqxy(double qx, double qy, double sld, double solvent_sld,
    double rpolar, double requatorial, double theta, double phi);

double _ellipsoid_kernel(double q, double rpolar, double requatorial, double cos_alpha);
double _ellipsoid_kernel(double q, double rpolar, double requatorial, double cos_alpha)
{
    double sn, cn;
    double ratio = rpolar/requatorial;
    const double u = q*requatorial*sqrt(1.0
                   + cos_alpha*cos_alpha*(ratio*ratio - 1.0));
    SINCOS(u, sn, cn);
    //const double f = ( u==0.0 ? 1.0 : 3.0*(sn-u*cn)/(u*u*u) );
    const double usq = u*u;
    const double f = (u < 1.e-1)
        ? 1.0 + usq*(-3./30. + usq*(3./840. + usq*(-3./45360.)))// + qrsq*(3./3991680.))))
        : 3.0*(sn/u - cn)/usq;
    return f*f;
}

double form_volume(double rpolar, double requatorial)
{
    return 1.333333333333333*M_PI*rpolar*requatorial*requatorial;
}

double Iq(double q,
    double sld,
    double solvent_sld,
    double rpolar,
    double requatorial)
{
    //const double lower = 0.0;
    //const double upper = 1.0;
    double total = 0.0;
    for (int i=0;i<76;i++) {
        //const double cos_alpha = (Gauss76Z[i]*(upper-lower) + upper + lower)/2;
        const double cos_alpha = 0.5*(Gauss76Z[i] + 1.0);
        total += Gauss76Wt[i] * _ellipsoid_kernel(q, rpolar, requatorial, cos_alpha);
    }
    //const double form = (upper-lower)/2*total;
    const double form = 0.5*total;
    const double s = (sld - solvent_sld) * form_volume(rpolar, requatorial);
    return 1.0e-4 * form * s * s;
}

double Iqxy(double qx, double qy,
    double sld,
    double solvent_sld,
    double rpolar,
    double requatorial,
    double theta,
    double phi)
{
    double sn, cn;

    const double q = sqrt(qx*qx + qy*qy);
    SINCOS(theta*M_PI_180, sn, cn);
    const double cos_alpha = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q);
    const double form = _ellipsoid_kernel(q, rpolar, requatorial, cos_alpha);
    const double s = (sld - solvent_sld) * form_volume(rpolar, requatorial);

    return 1.0e-4 * form * s * s;
}
<commit_msg>code cleanup<commit_after>double form_volume(double rpolar, double requatorial);
double Iq(double q, double sld, double solvent_sld, double rpolar, double requatorial);
double Iqxy(double qx, double qy, double sld, double solvent_sld,
    double rpolar, double requatorial, double theta, double phi);

double _ellipsoid_kernel(double q, double rpolar, double requatorial, double sin_alpha);
double _ellipsoid_kernel(double q, double rpolar, double requatorial, double sin_alpha)
{
    double sn, cn;
    double ratio = rpolar/requatorial;
    const double u = q*requatorial*sqrt(1.0
                   + sin_alpha*sin_alpha*(ratio*ratio - 1.0));
    SINCOS(u, sn, cn);
    //const double f = ( u==0.0 ? 1.0 : 3.0*(sn-u*cn)/(u*u*u) );
    const double usq = u*u;
    const double f = (u < 1.e-1)
        ? 1.0 + usq*(-3./30. + usq*(3./840. + usq*(-3./45360.)))// + qrsq*(3./3991680.))))
        : 3.0*(sn/u - cn)/usq;
    return f*f;
}

double form_volume(double rpolar, double requatorial)
{
    return 1.333333333333333*M_PI*rpolar*requatorial*requatorial;
}

double Iq(double q,
    double sld,
    double solvent_sld,
    double rpolar,
    double requatorial)
{
    //const double lower = 0.0;
    //const double upper = 1.0;
    double total = 0.0;
    for (int i=0;i<76;i++) {
        //const double sin_alpha = (Gauss76Z[i]*(upper-lower) + upper + lower)/2;
        const double sin_alpha = 0.5*(Gauss76Z[i] + 1.0);
        total += Gauss76Wt[i] * _ellipsoid_kernel(q, rpolar, requatorial, sin_alpha);
    }
    //const double form = (upper-lower)/2*total;
    const double form = 0.5*total;
    const double s = (sld - solvent_sld) * form_volume(rpolar, requatorial);
    return 1.0e-4 * form * s * s;
}

double Iqxy(double qx, double qy,
    double sld,
    double solvent_sld,
    double rpolar,
    double requatorial,
    double theta,
    double phi)
{
    double sn, cn;

    const double q = sqrt(qx*qx + qy*qy);
    SINCOS(theta*M_PI_180, sn, cn);
    // TODO: check if this is actually sin(alpha), not cos(alpha)
    const double cos_alpha = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q);
    const double form = _ellipsoid_kernel(q, rpolar, requatorial, cos_alpha);
    const double s = (sld - solvent_sld) * form_volume(rpolar, requatorial);

    return 1.0e-4 * form * s * s;
}

{'fraction_non_alphanumeric': 0.13941137419783137, 'fraction_numerical': 0.03894666961717194, 'mean_word_length': 3.124087591240876, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2334371', 'n_tokens_mistral': 1875, 'n_tokens_neox': 1688, 'n_words': 432}