Complex scalar division.
176900
private static Complex cdiv(double xr, double xi, double yr, double yi) {
        double cdivr, cdivi;
        double r, d;
        if (Math.abs(yr) > Math.abs(yi)) {
            r = yi / yr;
            d = yr + r * yi;
            cdivr = (xr + r * xi) / d;
            cdivi = (xi - r * xr) / d;
        } else {
            r = yr / yi;
            d = yi + r * yr;
            cdivr = (r * xr + xi) / d;
            cdivi = (r * xi - xr) / d;
        }

        return new Complex(cdivr, cdivi);
    }
459930
public static ComplexNumber Multiply(ComplexNumber z1, double scalar) {
        return new ComplexNumber(z1.real * scalar, z1.imaginary * scalar);
    }
302922
public static ComplexNumber Subtract(ComplexNumber z1, double scalar) {
        return new ComplexNumber(z1.real - scalar, z1.imaginary);
    }
204225
public Complex dot(IVector b) {
        if ((b == null) || (size != b.size)) return new Complex(Double.NaN, Double.NaN);

        Complex result = new Complex(0d, 0d);
        int i;
        for (i = 0; i < size; i++) {
            result.real += realvector[i] * b.realvector[i] - imagvector[i] * b.imagvector[i];
            result.imag += realvector[i] * b.imagvector[i] + imagvector[i] * b.realvector[i];
        }
        return result;
    }
690424
public void orizzonte8( double delta, int quadrata, double beta, double alfa, double[][] Z0, int[][] curv, int[][] shadow,
            double novalue ) {
        /*=====================*/

        int y, I, J;
        double zenith;

        /*======================*/

        for( int j = quadrata; j >= 0; j-- ) {
            I = -1;
            J = -1;
            y = 0;
            for( int jj = j; jj < quadrata; jj++ ) {
                for( int i = (int) floor(1 / tan(beta) * (jj - j)) + 1; i <= (int) floor(1 / tan(beta) * (jj - j + 1))
                        && i <= Z0.length; i++ ) {
                    if (jj > quadrata - Z0[0].length && Z0[i][jj - (quadrata - Z0[0].length)] != novalue) {
                        /*shadow.element[i][jj-(quadrata-Z0.nch)]=j;}}}}*/
                        if (curv[i][jj] == 1 && I == -1) {
                            I = i;
                            J = jj - (quadrata - Z0[0].length);
                            y = 1;
                        } else if (curv[i][jj - (quadrata - Z0[0].length)] == 1 && I != 1) {
                            zenith = (Z0[I][J] - Z0[i][jj - (quadrata - Z0[0].length)])
                                    / sqrt(pow((double) (I - i) * (double) delta, (double) 2)
                                            + pow((double) (J - (jj - (quadrata - Z0[0].length))) * (double) delta, (double) 2));
                            if (zenith <= tan(alfa)) {
                                shadow[i][jj - (quadrata - Z0[0].length)] = 0;
                                I = i;
                                J = jj - (quadrata - Z0[0].length);
                            } else {
                                shadow[i][jj - (quadrata - Z0[0].length)] = 1;
                            }
                        } else if (curv[i][jj - (quadrata - Z0[0].length)] == 0 && y == 1) {
                            zenith = (Z0[I][J] - Z0[i][jj - (quadrata - Z0[0].length)])
                                    / sqrt(pow((double) (I - i) * (double) delta, (double) 2)
                                            + pow((double) (J - (jj - (quadrata - Z0[0].length))) * (double) delta, (double) 2));
                            if (zenith <= tan(alfa)) {
                                shadow[i][jj - (quadrata - Z0[0].length)] = 0;
                                y = 0;
                            } else {
                                shadow[i][jj - (quadrata - Z0[0].length)] = 1;
                            }
                        }
                    }
                }
            }
        }
    }
295837
public static void multiplyComplex( InterleavedF32 complexA , InterleavedF32 complexB , InterleavedF32 complexC ) {

		InputSanityCheck.checkSameShape(complexA, complexB,complexC);

		for( int y = 0; y < complexA.height; y++ ) {

			int indexA = complexA.startIndex + y*complexA.stride;
			int indexB = complexB.startIndex + y*complexB.stride;
			int indexC = complexC.startIndex + y*complexC.stride;

			for( int x = 0; x < complexA.width; x++, indexA += 2 , indexB += 2  ,indexC += 2 ) {

				float realA = complexA.data[indexA];
				float imgA = complexA.data[indexA+1];
				float realB = complexB.data[indexB];
				float imgB = complexB.data[indexB+1];

				complexC.data[indexC] = realA*realB - imgA*imgB;
				complexC.data[indexC+1] = realA*imgB + imgA*realB;
			}
		}
	}
234502
def _make_complex(self):
        """"""
        rcomplex_coeffs = _shtools.SHrtoc(self.coeffs,
                                          convention=1, switchcs=0)

        # These coefficients are using real floats, and need to be
        # converted to complex form.
        complex_coeffs = _np.zeros((2, self.lmax+1, self.lmax+1),
                                   dtype='complex')
        complex_coeffs[0, :, :] = (rcomplex_coeffs[0, :, :] + 1j *
                                   rcomplex_coeffs[1, :, :])
        complex_coeffs[1, :, :] = complex_coeffs[0, :, :].conjugate()
        for m in self.degrees():
            if m % 2 == 1:
                complex_coeffs[1, :, m] = - complex_coeffs[1, :, m]

        # complex_coeffs is initialized in this function and can be
        # passed as reference
        return SHCoeffs.from_array(complex_coeffs,
                                   normalization=self.normalization,
                                   csphase=self.csphase, copy=False)
788329
private static BigInteger divideAndRound(BigInteger bdividend, long ldivisor, int roundingMode) {
        boolean isRemainderZero; // record remainder is zero or not
        int qsign; // quotient sign
        long r = 0; // store quotient & remainder in long
        MutableBigInteger mq = null; // store quotient
        // Descend into mutables for faster remainder checks
        MutableBigInteger mdividend = new MutableBigInteger(bdividend.mag);
        mq = new MutableBigInteger();
        r = mdividend.divide(ldivisor, mq);
        isRemainderZero = (r == 0);
        qsign = (ldivisor < 0) ? -bdividend.signum : bdividend.signum;
        if (!isRemainderZero) {
            if(needIncrement(ldivisor, roundingMode, qsign, mq, r)) {
                mq.add(MutableBigInteger.ONE);
            }
        }
        return mq.toBigInteger(qsign);
    }
589668
function() {

      // acot(c) = i / 2 log((c - i) / (c + i))

      var a = this['re'];
      var b = this['im'];

      if (b === 0) {
        return new Complex(Math.atan2(1, a), 0);
      }

      var d = a * a + b * b;
      return (d !== 0)
              ? new Complex(
                      a / d,
                      -b / d).atan()
              : new Complex(
                      (a !== 0) ? a / 0 : 0,
                      (b !== 0) ? -b / 0 : 0).atan();
    }
743640
function() {

      /**
       * exp(a + i*b) - 1
       = exp(a) * (cos(b) + j*sin(b)) - 1
       = expm1(a)*cos(b) + cosm1(b) + j*exp(a)*sin(b)
       */

      var a = this['re'];
      var b = this['im'];

      return new Complex(
              Math.expm1(a) * Math.cos(b) + cosm1(b),
              Math.exp(a) * Math.sin(b));
    }
134116
private static boolean divisionByZeroSideEffect(
            final double pXA, final double pYA, final double pXB, final double pYB,
            final double pXC, final double pYC, final double pXD, final double pYD,
            final PointL pIntersection
    ) {
        return divisionByZeroSideEffectX(pXA, pYA, pXB, pYB, pXC, pYC, pXD, pYD, pIntersection)
                || divisionByZeroSideEffectX(pXC, pYC, pXD, pYD, pXA, pYA, pXB, pYB, pIntersection)
                || divisionByZeroSideEffectY(pXA, pYA, pXB, pYB, pXC, pYC, pXD, pYD, pIntersection)
                || divisionByZeroSideEffectY(pXC, pYC, pXD, pYD, pXA, pYA, pXB, pYB, pIntersection);
    }
654354
function div(a, b) {
    if (b instanceof complex_1.Complex) {
        return _mul_two(a, b.inverse());
    }
    else {
        return _mul_two(a, 1 / b);
    }
}
1011
function() {

      // acoth(c) = log((c+1) / (c-1)) / 2

      var a = this['re'];
      var b = this['im'];

      if (a === 0 && b === 0) {
        return new Complex(0, Math.PI / 2);
      }

      var d = a * a + b * b;
      return (d !== 0)
              ? new Complex(
                      a / d,
                      -b / d).atanh()
              : new Complex(
                      (a !== 0) ? a / 0 : 0,
                      (b !== 0) ? -b / 0 : 0).atanh();
    }
1299717
public void mul(Complex a, IMatrix result) {
        if ((result.rows != rows) || (result.columns != columns)) result.reshape(rows, columns);

        int i, j;
        for (i = 0; i < rows; i++)
            for (j = 0; j < columns; j++) {
                result.realmatrix[i][j] = realmatrix[i][j] * a.real - imagmatrix[i][j] * a.imag;
                result.imagmatrix[i][j] = realmatrix[i][j] * a.imag + imagmatrix[i][j] * a.real;
            }
    }
498810
public static void root(ComplexPolar_F64 a , int N , int k , ComplexPolar_F64 result )
    {
        result.r = Math.pow(a.r,1.0/N);
        result.theta = (a.theta + 2.0*k* UtilEjml.PI)/N;
    }
1268400
public Complex multiply(Complex c)
    {
        Complex ret = new Complex(real, imag);
        ret.mutableMultiply(c);
        return ret;
    }
564198
public static void multiply(Complex_F64 a, Complex_F64 b, Complex_F64 result) {
        result.real = a.real * b.real - a.imaginary*b.imaginary;
        result.imaginary = a.real*b.imaginary + a.imaginary*b.real;
    }