This computes the term f2 in equation 32, page 1021
335082
def _compute_term2(self, C, mag, rrup):
        
        c78_factor = (C['c7'] * np.exp(C['c8'] * mag)) ** 2
        R = np.sqrt(rrup ** 2 + c78_factor)

        return C['c4'] * np.log(R) + (C['c5'] + C['c6'] * mag) * rrup
554770
def _compute_linear_magnitude_term(self, C, mag):
        
        if mag <= self.c1:
            # this is the second term in eq. (1a), p. 2981
            return C['a2'] * (mag - self.c1)
        else:
            # this is the second term in eq. (1b), p. 2982
            return C['a3'] * (mag - self.c1)
3386
def _n_2(self):
        """"""
        return (self._f(3, 1) * self._f(2, 1) +
                self._f(3, 0) * self._f(1, 3) * self._f(2, 1) +
                self._f(3, 0) * self._f(2, 0) * self._f(1, 2))
1320783
def _compute_term_4(self, C, mag, R):
        
        return (
            (C['a16'] + C['a17'] * mag + C['a18'] * np.power(mag, 2) +
             C['a19'] * np.power(mag, 3)) * np.power(R, 3)
        )
1020725
def compute_fwhm_1d_simple(Y, xc, X=None):
    """"""
    return compute_fw_at_frac_max_1d_simple(Y, xc, X=X, f=0.5)
302128
def powerlaw(f, log10_A=-16, gamma=5):
    

    fyr = 1 / 3.16e7
    return (10**log10_A)**2 / 12.0 / np.pi**2 * fyr**(gamma-3) * f**(-gamma)
1345243
function q_f(df1, df2, f) {
        var cos2, sin2, prob, temp, i;

        if (f <= 0.0) { return 1.0; }
        if (df1 % 2 !== 0 && df2 % 2 === 0) { return 1.0 - q_f(df2, df1, 1.0 / f); }

        cos2 = 1.0 / (1.0 + df1 * f / df2);
        sin2 = 1.0 - cos2;

        if (df1 % 2 === 0) {
            prob = Math.pow(cos2, (df2 / 2.0));
            temp = prob;

            i = 2;
            while (i < df1) {
                temp = temp * ((df2 + i - 2) * sin2 / i);
                prob = prob + temp;
                i = i + 2;
            }

            return prob;
        }

        prob = Math.atan(Math.sqrt(df2 / (df1 * f)));
        temp = Math.sqrt(sin2 * cos2);
        i = 3;
        while (i <= df1) {
            prob = prob + temp;
            temp = temp * ((i - 1) * sin2 / i);
            i = i + 2.0;
        }

        temp = temp * df1;
        i = 3;
        while (i <= df2) {
            prob = prob - temp;
            temp = temp * ((df1 + i - 2) * cos2 / i);
            i = i + 2;
        }

        return prob * 2.0 / Math.PI;
    }
1094826
def get_step_f(step_f, lR2, lS2):
    
    mu, tau = 10, 2
    if lR2 > mu*lS2:
        return step_f * tau
    elif lS2 > mu*lR2:
        return step_f / tau
    return step_f
843197
def _F(self, x, p):

        
        prefactor = 0.5 * (1 + p ** 2) ** -1 * p

        if isinstance(x, np.ndarray):

            inds0 = np.where(x * p == 1)
            inds1 = np.where(x * p < 1)
            inds2 = np.where(x * p > 1)

            func = np.ones_like(x)

            func[inds0] = self._u(x[inds0]) ** -1 * (np.pi + 2 * p * np.arctanh(self._u(x[inds0]) ** -1))

            func[inds1] = self._u(x[inds1]) ** -1 * (np.pi + 2 * p * np.arctanh(self._u(x[inds1]) ** -1)) - \
                          (2 * p * self._g(x[inds1], p) ** -1 * np.arctanh(self._g(x[inds1], p)))

            func[inds2] = self._u(x[inds2]) ** -1 * (np.pi + 2 * p * np.arctanh(self._u(x[inds2]) ** -1)) - \
                          (2 * p * self._f(x[inds2], p) ** -1 * np.arctan(self._f(x[inds2], p)))

            return prefactor * func

        else:

            if x * p == 1:
                func = self._u(x) ** -1 * (np.pi + 2 * p * np.arctanh(self._u(x) ** -1))
            elif x * p < 1:
                func = self._u(x) ** -1 * (np.pi + 2 * p * np.arctanh(self._u(x) ** -1)) - \
                       (2 * p * self._g(x, p) ** -1 * np.arctanh(self._g(x, p)))
            else:
                func = self._u(x) ** -1 * (np.pi + 2 * p * np.arctanh(self._u(x) ** -1)) - \
                       (2 * p * self._f(x, p) ** -1 * np.arctan(self._f(x, p)))

            return prefactor * func
170950
def _K_computations(self, X, X2=None):
        """"""
        self._lengthscales=self.mapping.f(X)
        self._lengthscales2=np.square(self._lengthscales)
        if X2==None:
            self._lengthscales_two = self._lengthscales
            self._lengthscales_two2 = self._lengthscales2
            Xsquare = np.square(X).sum(1)
            self._K_dist2 = -2.*tdot(X) + Xsquare[:, None] + Xsquare[None, :]
        else:
            self._lengthscales_two = self.mapping.f(X2)
            self._lengthscales_two2 = np.square(self._lengthscales_two)
            self._K_dist2 = -2.*np.dot(X, X2.T) + np.square(X).sum(1)[:, None] + np.square(X2).sum(1)[None, :]
        self._w2 = self._lengthscales2 + self._lengthscales_two2.T
        prod_length = self._lengthscales*self._lengthscales_two.T
        self._K_exponential = np.exp(-self._K_dist2/self._w2)
        self._K_dvar = np.sign(prod_length)*(2*np.abs(prod_length)/self._w2)**(self.input_dim/2.)*np.exp(-self._K_dist2/self._w2)
753585
def f(self, v, t):
        
        ret = np.zeros(8)
        ret[0] = v[4]
        ret[4] = (self.He1*self.ke1*(self.g1*self.S(v[1]-v[2]) + self.u_mean) -
                  2*self.ke1*v[4] - self.ke1*self.ke1*v[0])

        ret[1] = v[5]
        ret[5] = (self.He2*self.ke2*(self.g2*self.S(v[0]) + self.p_mean) -
                  2*self.ke2*v[5] - self.ke2*self.ke2*v[1])

        ret[2] = v[6]
        ret[6] = (self.Hi*self.ki*self.g4*self.S(v[3]) - 2*self.ki*v[6] -
                  self.ki*self.ki*v[2])

        ret[3] = v[7]
        ret[7] = (self.He3*self.ke3*self.g3*self.S(v[1]-v[2]) -
                  2*self.ke3*v[7] - self.ke3*self.ke3*v[3])
        return ret
601217
void pass_2(int fi, 
	      float in[],  int in0, int istride,
	      float out[], int out0, int ostride,
	      int sign, int product) {
    int k, k1;

    int factor = 2;
    int m = n / factor;
    int q = n / product;
    int product_1 = product / factor;

    int di = istride * m;
    int dj = ostride * product_1;
    int i = in0, j = out0;
    float x_real, x_imag;
    for (k = 0; k < q; k++) {
      float twids[] = twiddle[fi][k];
      float w_real =       twids[0];
      float w_imag = -sign*twids[1];

      for (k1 = 0; k1 < product_1; k1++) {
	float z0_real = in[i];
	float z0_imag = in[i+1];
	float z1_real = in[i+di];
	float z1_imag = in[i+di+1];
	i += istride;

	/* compute x = W(2) z */

	/* apply twiddle factors */
	  
	/* out0 = 1 * (z0 + z1) */
	out[j]   = z0_real + z1_real;
	out[j+1] = z0_imag + z1_imag;
	  
	/* out1 = w * (z0 - z1) */
	x_real = z0_real - z1_real;
	x_imag = z0_imag - z1_imag;
	out[j+dj]   = w_real * x_real - w_imag * x_imag;
	out[j+dj+1] = w_real * x_imag + w_imag * x_real;
	  
	j += ostride;
      }
      j += (factor-1)*dj;
    }}
10617
function f1(d, m, r) {
    const t = m + d;
    const I = (t << r) | (t >>> (32 - r));
    return ((sBox[0][I >>> 24] ^ sBox[1][(I >>> 16) & 255]) - sBox[2][(I >>> 8) & 255]) + sBox[3][I & 255];
  }
771954
def _f_A20(self, r_a, r_s):
        
        return r_a/(1+np.sqrt(1 + r_a**2)) - r_s/(1+np.sqrt(1 + r_s**2))
728130
def _compute_f5(self, C, pga_rock):
        
        return C['a10'] + C['a11'] * np.log(pga_rock + C['c5'])
382512
def _compute_magnitude_term(self, C, mag):
        
        fmag = C['c0'] + C['c1'] * mag
        if mag <= 5.5:
            return fmag
        elif mag > 6.5:
            return fmag + (C['c2'] * (mag - 5.5)) + (C['c3'] * (mag - 6.5))
        else:
            return fmag + (C['c2'] * (mag - 5.5))
1293581
def _func(a, p, r, v):
    
    # eq. 2.3
    f = a[0]*math.log(r-1.) + \
        a[1]*math.log(r-1.)**2 + \
        a[2]*math.log(r-1.)**3 + \
        a[3]*math.log(r-1.)**4

    # eq. 2.7 and 2.8 corrections
    if r == 3:
        f += -0.002 / (1. + 12. * _phi(p)**2)

        if v <= 4.364:
            f += 1./517. - 1./(312.*(v,1e38)[np.isinf(v)])
        else:
            f += 1./(191.*(v,1e38)[np.isinf(v)])

    return -f