Compute and return factor f0 - see equation (5), 6th term, p. 2191.
495679
def _compute_f0_factor(self, rrup):
        
        # f0 = max(log10(R0/rrup),0)
        f0 = np.log10(self.COEFFS_IMT_INDEPENDENT['R0'] / rrup)
        f0[f0 < 0] = 0.0

        return f0
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
672882
private static function _getMorphed($n, $f1, $f2, $f5) {
        $n  = abs($n) % 100;
        $n1 = $n % 10;
        if ($n > 10 && $n < 20) return $f5;
        if ($n1 > 1 && $n1 < 5) return $f2;
        if ($n1 == 1) return $f1;

        return $f5;
    }
172139
def _F(x, gam):
        
        beta = np.sqrt(1 - gam ** -2)
        B = 1 + 0.5 * (gam ** 2 - 1)
        C = 10 * x * gam * beta * (2 + gam * beta)
        C /= 1 + x ** 2 * (gam ** 2 - 1)

        F_1 = (17 - 3 * x ** 2 / (2 - x) ** 2 - C) * np.sqrt(1 - x)
        F_2 = 12 * (2 - x) - 7 * x ** 2 / (2 - x) - 3 * x ** 4 / (2 - x) ** 3
        F_3 = np.log((1 + np.sqrt(1 - x)) / np.sqrt(x))

        return B * F_1 + F_2 * F_3
868044
def cal_p_bm3(v, k, p_ref=0.0):
    
    vvr = v / k[0]
    p = (p_ref - 0.5 * (3. * k[1] - 5. * p_ref) * (1. - vvr**(-2. / 3.)) +
         9. / 8. * k[1] * (k[2] - 4. + 35. / 9. * p_ref / k[1]) *
         (1. - vvr**(-2. / 3.))**2.) * vvr**(-5. / 3.)
    return p
303135
def _call(self, x):
        """"""
        return (self.functional(x) +
                self.quadratic_coeff * x.inner(x) +
                x.inner(self.linear_term) + self.constant)
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))
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)
        )
44410
def CallUDFUNS(f, x):
    
    value = c_double()
    f(x, byref(value))
    return value.value
866793
def _compute_f1_factor(self, rrup):
        
        # f1 = min(log10(rrup),log10(R1))
        f1 = np.log10(rrup)
        logR1 = np.log10(self.COEFFS_IMT_INDEPENDENT['R1'])
        f1[f1 > logR1] = logR1

        return f1
670058
def Efn(Ms,eccs):
    """"""
    Ms = np.atleast_1d(Ms)
    eccs = np.atleast_1d(eccs)
    unit = np.floor(Ms / (2*np.pi))
    Es = EFN((Ms % (2*np.pi)),eccs)
    Es += unit*(2*np.pi)
    return Es
840578
def A(self):
        
        return fft(np.dstack([np.eye(self.m), -self.b]),
                   self.nfft * 2 - 1)[:, :, :self.nfft]
509618
private int precisionSum(List<UnitFactor> factors) {
    return factors.stream().map(f -> totalPrecision(f.rational())).reduce(0, Math::addExact);
  }
982399
private int calcTZeroDepth(int proposedK)
    {
        int d = -1;
        if ( (proposedK >= 0) && (proposedK < _t0_d.length) )
            d = _t0_d[proposedK];
        if (d < 0)
        {
            String x =
            "K Factor (" + proposedK + ") is invalid.\n" +
            "Valid K factors are: " + kFactorString() + ".";
            throw new IllegalArgumentException(x);
        }
        return d;
    }
381633
def nCr(n, r):
    
    f = math.factorial
    return int(f(n) / f(r) / f(n-r))
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))
1080397
function correctionFactor() {
    var args = Array.prototype.slice.call(arguments);
    return args.reduce(function (prev, next) {
      var mp = multiplier(prev),
        mn = multiplier(next);
      return mp > mn ? mp : mn;
    }, -Infinity);
  }