Computes second derivative of the potential with respect to x.

    @param r:      relative radius vector (3 components)
    @param D:      instantaneous separation
    @param q:      mass ratio
    @param F:      synchronicity parameter
763774
def d2BinaryRochedx2(r, D, q, F):
    
    return (2*r[0]*r[0]-r[1]*r[1]-r[2]*r[2])/(r[0]*r[0]+r[1]*r[1]+r[2]*r[2])**2.5 +\
          q*(2*(r[0]-D)*(r[0]-D)-r[1]*r[1]-r[2]*r[2])/((r[0]-D)*(r[0]-D)+r[1]*r[1]+r[2]*r[2])**2.5 +\
          F*F*(1+q)
1059724
public static double KumarJohnsonDivergence(double[] p, double[] q) {
        double r = 0;
        for (int i = 0; i < p.length; i++) {
            if (p[i] != 0 && q[i] != 0) {
                r += Math.pow(p[i] * p[i] - q[i] * q[i], 2) / 2 * Math.pow(p[i] * q[i], 1.5);
            }
        }
        return r;
    }
291460
def _dD_dR(self, R):
        """"""
        HNn_R_sina = self._HNn / R / self._sin_alpha

        return HNn_R_sina * (0.3 * (HNn_R_sina + 0.3 * HNn_R_sina**2. + 1) / R / (0.3 * HNn_R_sina + 1)**2
                             - (1/R * (1 + 0.6 * HNn_R_sina) / (0.3 * HNn_R_sina + 1)))
1145937
@Override
    public DMatrixRMaj getR(DMatrixRMaj R, boolean compact) {
        if( R == null ) {
            if( compact ) {
                R = new DMatrixRMaj(minLength,numCols);
            } else
                R = new DMatrixRMaj(numRows,numCols);
        } else {
            if( compact ) {
                R.reshape(minLength,numCols);
            } else {
                R.reshape(numRows,numCols);
            }

            for( int i = 0; i < R.numRows; i++ ) {
                int min = Math.min(i,R.numCols);
                for( int j = 0; j < min; j++ ) {
                    R.set(i,j,0);
                }
            }
        }

        for( int i = 0; i < minLength; i++ ) {
            for( int j = i; j < numCols; j++ ) {
                double val = QR.get(i,j);
                R.set(i,j,val);
            }
        }

        return R;
    }
219356
public static double angularDifference (double a1, double a2) {
        double ma1 = mirrorAngle(a1), ma2 = mirrorAngle(a2);
        double diff = a1 - a2, mdiff = ma2 - ma1;
        return (Math.abs(diff) < Math.abs(mdiff)) ? diff : mdiff;
    }
1036613
def derivatives(self, x, y, n_sersic, R_sersic, k_eff, center_x=0, center_y=0):
        
        x_ = x - center_x
        y_ = y - center_y
        r = np.sqrt(x_**2 + y_**2)
        if isinstance(r, int) or isinstance(r, float):
            r = max(self._s, r)
        else:
            r[r < self._s] = self._s
        alpha = -self.alpha_abs(x, y, n_sersic, R_sersic, k_eff, center_x, center_y)
        f_x = alpha * x_ / r
        f_y = alpha * y_ / r
        return f_x, f_y
1102730
def _D(self, R):
        """"""
        return (0.3 * self._HNn**2 / self._sin_alpha / R
                + self._HNn + R * self._sin_alpha) / (0.3 * self._HNn + R * self._sin_alpha)
238305
def derivative(self, z, x, y, fase):
        """"""
        return deriv_G(self, z, x, y, fase)
637458
def derivative(self, z, x, y, fase):
        """"""
        return deriv_H(self, z, x, y, fase)
558106
public static double Minkowski(IntPoint p, IntPoint q, int r) {
        return Minkowski(p.x, p.y, q.x, q.y, r);
    }
828954
def mass_3d(self, R, Rs, rho0, r_trunc):
        

        x = R * Rs ** -1

        func = (r_trunc ** 2 * (-2 * x * (1 + r_trunc ** 2) + 4 * (1 + x) * r_trunc * np.arctan(x / r_trunc) -
                                2 * (1 + x) * (-1 + r_trunc ** 2) * np.log(Rs) + 2 * (1 + x) * (-1 + r_trunc ** 2) * np.log(Rs * (1 + x)) +
                                2 * (1 + x) * (-1 + r_trunc ** 2) * np.log(Rs * r_trunc) -
                                (1 + x) * (-1 + r_trunc ** 2) * np.log(Rs ** 2 * (x ** 2 + r_trunc ** 2)))) / (2. * (1 + x) * (1 + r_trunc ** 2) ** 2)

        m_3d = 4*np.pi*Rs ** 3 * rho0 * func
        return m_3d
128702
def fRD( a, M):
    """"""
    f = (lal.C_SI**3.0 / (2.0*lal.PI*lal.G_SI*M*lal.MSUN_SI)) * (1.5251 - 1.1568*(1.0-a)**0.1292)
    return f
1037189
def flux_r2(q_vars: List[fl.Var], i: int, j: int):
    """"""
    # Indices with the base of (x, y, z) for each body
    k0 = 3*i
    k1 = 3*j
    # The squared distance bewteen body i and j as a Fluxion instance
    return fl.square(q_vars[k1+0] - q_vars[k0+0]) + \
           fl.square(q_vars[k1+1] - q_vars[k0+1]) + \
           fl.square(q_vars[k1+2] - q_vars[k0+2])
282468
def derivatives(self, x, y, Rs, theta_Rs, center_x=0, center_y=0):
        
        rho0_input = self._alpha2rho0(theta_Rs=theta_Rs, Rs=Rs)
        if Rs < 0.0000001:
            Rs = 0.0000001
        x_ = x - center_x
        y_ = y - center_y
        R = np.sqrt(x_**2 + y_**2)
        f_x, f_y = self.nfwAlpha(R, Rs, rho0_input, x_, y_)
        return f_x, f_y
948225
def DebyeChain(q, Rg):
    
    a = (q * Rg) ** 2
    return 2 * (np.exp(-a) - 1 + a) / a ** 2
48284
def _phi2deriv(self,R,phi=0.,t=0.):
        
        return self._Pot.phi2deriv(R,0.,phi=phi,t=t,use_physical=False)
941112
def FD(self):
    
    if self.Verbose:
      print("Finite Difference Solution Technique")
    # Used to check for coeff_matrix here, but now doing so in self.bc_check()
    # called by f1d and f2d at the start
    # 
    # Define a stress-based qs = q0
    # But only if the latter has not already been defined
    # (e.g., by the getters and setters)
    try:
      self.qs
    except:
      self.qs = self.q0.copy()
      # Remove self.q0 to avoid issues with multiply-defined inputs
      # q0 is the parsable input to either a qs grid or contains (x,(y),q)
      del self.q0
    # Give it x and y dimensions for help with plotting tools
    # (not implemented internally, but a help with external methods)
    self.x = np.arange(self.dx/2., self.dx * self.qs.shape[0], self.dx)
    if self.dimension == 2:
      self.y = np.arange(self.dy/2., self.dy * self.qs.shape[1], self.dy)
    # Is there a solver defined
    try:
      self.Solver # See if it exists already
    except:
      # Well, will fail if it doesn't see this, maybe not the most reasonable
      # error message.
      if self.filename:
        self.Solver = self.configGet("string", "numerical", "Solver")
      else:
        sys.exit("No solver defined!")
    # Check consistency of size if coeff array was loaded
    if self.filename:
      # In the case that it is iterative, find the convergence criterion
      self.iterative_ConvergenceTolerance = self.configGet("float", "numerical", "ConvergenceTolerance")    
      # Try to import Te grid or scalar for the finite difference solution
      try:
        self.Te = self.configGet("float", "input", "ElasticThickness", optional=False)
        if self.Te is None:
          Tepath = self.configGet("string", "input", "ElasticThickness", optional=False)
          self.Te = Tepath
        else:
          Tepath = None
      except:
        Tepath = self.configGet("string", "input", "ElasticThickness", optional=False)
        self.Te = Tepath
      if self.Te is None:
        if self.coeff_matrix is not None:
          pass
        else:
          # Have to bring this out here in case it was discovered in the 
          # try statement that there is no value given
          sys.exit("No input elastic thickness or coefficient matrix supplied.")
    # or if getter/setter
    if type(self.Te) == str: 
      # Try to import Te grid or scalar for the finite difference solution
      Tepath = self.Te
    else:
      Tepath = None # in case no self.filename present (like for GRASS GIS)
    # If there is a Tepath, import Te
    # Assume that even if a coeff_matrix is defined
    # That the user wants Te if they gave the path
    if Tepath:
      self.Te = self.loadFile(self.Te, close_on_fail = False)
      if self.Te is None:
        print("Requested Te file is provided but cannot be located.")
        print("No scalar elastic thickness is provided in configuration file")
        print("(Typo in path to input Te grid?)")
        if self.coeff_matrix is not None:
          print("But a coefficient matrix has been found.")
          print("Calculations will be carried forward using it.")
        else:
          print("Exiting.")
          sys.exit()

      # Check that Te is the proper size if it was loaded
      # Will be array if it was loaded
      if self.Te.any():
        self.TeArraySizeCheck()