Computes a derivative of the potential with respect to z.

    @param r:      relative radius vector (3 components)
    @param D:      instantaneous separation
    @param q:      mass ratio
    @param F:      synchronicity parameter
555844
def  dBinaryRochedz(r, D, q, F):
    
    return -r[2]*(r[0]*r[0]+r[1]*r[1]+r[2]*r[2])**-1.5 -q*r[2]*((r[0]-D)*(r[0]-D)+r[1]*r[1]+r[2]*r[2])**-1.5
730721
public double horizontalForce(Double T, double d)
    {
        return AE*Math.sqrt(Math.pow(T/AE+1, 2)-2*w*d/AE)-AE;
    }
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;
    }
1266465
public static void divide(ComplexPolar_F64 a, ComplexPolar_F64 b, ComplexPolar_F64 result)
    {
        result.r = a.r/b.r;
        result.theta = a.theta - b.theta;
    }
397481
def dBinaryRochedx (r, D, q, F):
    
    return -r[0]*(r[0]*r[0]+r[1]*r[1]+r[2]*r[2])**-1.5 -q*(r[0]-D)*((r[0]-D)*(r[0]-D)+r[1]*r[1]+r[2]*r[2])**-1.5 -q/D/D + F*F*(1+q)*r[0]
367770
def derivatives(self, x, y, theta_E, s, q):
        
        if q >= 1:
            q = 0.999999
        psi = self._psi(x, y, q, s)
        f_x = theta_E / np.sqrt(1. - q ** 2) * np.arctan(np.sqrt(1. - q ** 2) * x / (psi+s))
        f_y = theta_E / np.sqrt(1. - q ** 2) * np.arctanh(np.sqrt(1. - q ** 2) * y / (psi + q**2*s))
        return f_x, f_y
908398
public static double getGradDotDirApprox(Function fn, IntDoubleVector x, IntDoubleVector d) {
        return getGradDotDirApprox(fn, x, d, getEpsilon(x, d));
    }
354810
def nb_r_deriv(r, data_row):
    
    n = len(data_row)
    d = sum(digamma(data_row + r)) - n*digamma(r) + n*np.log(r/(r+np.mean(data_row)))
    return d
1364948
def hessian(self, x, y, theta_E, s, q):
        
        alpha_ra, alpha_dec = self.derivatives(x, y, theta_E, s, q)
        diff = self._diff
        alpha_ra_dx, alpha_dec_dx = self.derivatives(x + diff, y, theta_E, s, q)
        alpha_ra_dy, alpha_dec_dy = self.derivatives(x, y + diff, theta_E, s, q)

        f_xx = (alpha_ra_dx - alpha_ra) / diff
        f_xy = (alpha_ra_dy - alpha_ra) / diff
        # f_yx = (alpha_dec_dx - alpha_dec)/diff
        f_yy = (alpha_dec_dy - alpha_dec) / diff
        return f_xx, f_yy, f_xy
81935
public static void DFT(ComplexNumber[] data, Direction direction) {
        int n = data.length;
        ComplexNumber[] c = new ComplexNumber[n];

        // for each destination element
        for (int i = 0; i < n; i++) {
            c[i] = new ComplexNumber(0, 0);
            double sumRe = 0;
            double sumIm = 0;
            double phim = 2 * Math.PI * i / n;

            // sum source elements
            for (int j = 0; j < n; j++) {
                double gRe = data[j].real;
                double gIm = data[j].imaginary;
                double cosw = Math.cos(phim * j);
                double sinw = Math.sin(phim * j);
                if (direction == Direction.Backward)
                    sinw = -sinw;

                sumRe += (gRe * cosw + data[j].imaginary * sinw);
                sumIm += (gIm * cosw - data[j].real * sinw);
            }

            c[i] = new ComplexNumber(sumRe, sumIm);
        }

        if (direction == Direction.Backward) {
            for (int i = 0; i < c.length; i++) {
                data[i].real = c[i].real / n;
                data[i].imaginary = c[i].imaginary / n;
            }
        } else {
            for (int i = 0; i < c.length; i++) {
                data[i].real = c[i].real;
                data[i].imaginary = c[i].imaginary;
            }
        }
    }
137007
public static double TopsoeDivergence(double[] p, double[] q) {
        double r = 0;
        for (int i = 0; i < p.length; i++) {
            if (p[i] != 0 && q[i] != 0) {
                double den = p[i] + q[i];
                r += p[i] * Math.log(2 * p[i] / den) + q[i] * Math.log(2 * q[i] / den);
            }
        }
        return r;
    }
1318570
public final void mul(Quaternion q1) {
		double x1, y1, w1; 

		w1 = this.w*q1.w - this.x*q1.x - this.y*q1.y - this.z*q1.z;
		x1 = this.w*q1.x + q1.w*this.x + this.y*q1.z - this.z*q1.y;
		y1 = this.w*q1.y + q1.w*this.y - this.x*q1.z + this.z*q1.x;
		this.z = this.w*q1.z + q1.w*this.z + this.x*q1.y - this.y*q1.x;
		this.w = w1;
		this.x = x1;
		this.y = y1;
	}
49317
def _Rforce(self,R,phi=0.,t=0.):
        
        return self._Pot.Rforce(R,0.,t=t,use_physical=False)
222751
def _force(self,z,t=0.):
        
        return self._Pot.zforce(self._R,z,phi=self._phi,t=t,use_physical=False)\
            -self._Pot.zforce(self._R,0.,phi=self._phi,t=t,use_physical=False)
917263
def d2_func(x, y, z):
    '''
    
    '''
    X, Y = np.meshgrid(x, y, copy=False)
    X = X.flatten()
    Y = Y.flatten()
    A = np.array([np.ones(len(X)), X, X**2, Y, Y**2, X*Y]).T
    Z = np.array(z)
    B = Z.flatten()
    # print(A.shape,B.shape)
    coeff, r, rank, s = np.linalg.lstsq(A, B, rcond=None)
    return -coeff[5]
1119990
public DMatrixRMaj getQ(DMatrixRMaj Q ) {
        Q = UtilDecompositons_DDRM.checkIdentity(Q,N,N);

        for( int j = N-2; j >= 0; j-- ) {
            u[j+1] = 1;
            for( int i = j+2; i < N; i++ ) {
                u[i] = QH.get(i,j);
            }
            QrHelperFunctions_DDRM.rank1UpdateMultR(Q, u, gammas[j], j + 1, j + 1, N, b);
        }

        return Q;
    }
887730
def mass_3d(self, R, Rs, rho0):
        
        Rs = float(Rs)
        m_3d = 4. * np.pi * rho0 * Rs**3 *(np.log((Rs + R)/Rs) - R/(Rs + R))
        return m_3d