r"""Get the real or imaginary part of a complex number.
774276
def part(z, s):
    """
    if sage_included:
        if s == 1: return np.real(z)
        elif s == -1: return np.imag(z)
        elif s == 0:
            return z
    else:
        if s == 1: return z.real
        elif s == -1: return z.imag
        elif s == 0: return z
373300
def _call(self, x, out):
        """"""
        if self.domain.is_real:
            # Real domain, multiply separately
            out.real = self.scalar.real * x
            out.imag = self.scalar.imag * x
        else:
            # Complex domain
            out.lincomb(self.scalar, x)
1353264
def cdim(self):
        """"""
        if self._cdim is None:
            self._cdim = sum((circuit.cdim for circuit in self.operands))
        return self._cdim
826750
def element(self, inp=None):
        """"""
        if inp is not None:
            # Workaround for missing __complex__ of numpy.ndarray
            # for Numpy version < 1.12
            # TODO: remove when Numpy >= 1.12 is required
            if isinstance(inp, np.ndarray):
                return complex(inp.reshape([1])[0])
            else:
                return complex(inp)
        else:
            return complex(0.0, 0.0)
945790
public static double[] getReal(ComplexNumber[] cn) {
        double[] n = new double[cn.length];
        for (int i = 0; i < n.length; i++) {
            n[i] = cn[i].real;
        }
        return n;
    }
500553
function() {

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

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

      return new Complex(
              logHypot(a, b),
              Math.atan2(b, a));
    }
525306
def cis(x: float) -> complex:
    
    """
    return np.cos(x) + 1.0j * np.sin(x)
986334
public static function IMSIN($complexNumber) {
		$complexNumber	= PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);

		$parsedComplex = self::_parseComplex($complexNumber);

		if ($parsedComplex['imaginary'] == 0.0) {
			return sin($parsedComplex['real']);
		} else {
			return self::COMPLEX(sin($parsedComplex['real']) * cosh($parsedComplex['imaginary']),cos($parsedComplex['real']) * sinh($parsedComplex['imaginary']),$parsedComplex['suffix']);
		}
	}
623990
def IJ(mu, N):
    """"""
    if mu == 0: return 1, 1, 1

    if mu not in range(0, N**2):
        raise ValueError('mu has an invalid value mu='+str(mu)+'.')

    if 1 <= mu <= N-1:
        return mu+1, mu+1, 1
    else:
        m = N-1
        M = N*(N-1)/2
        for jj in range(1, N):
            for ii in range(jj+1, N+1):
                m += 1
                if m == mu or m+M == mu:
                    if mu > N*(N+1)/2 - 1:
                        return ii, jj, -1
                    else:
                        return ii, jj, 1
114851
def _f90complex(self, value):
        """"""
        return '({0:{fmt}}, {1:{fmt}})'.format(value.real, value.imag,
                                               fmt=self.float_format)
951120
def **(other)
      if other.is_a?(InternalComplex) or other.is_a?(Complex)
        r, theta = polar
        ore = other.real
        oim = other.imag
        nr = Math.exp ore * Math.log(r) - oim * theta
        ntheta = theta * ore + oim * Math.log(r)
        InternalComplex.polar nr, ntheta
      elsif InternalComplex.generic? other
        r, theta = polar
        InternalComplex.polar r ** other, theta * other
      else
        x, y = other.coerce self
        x ** y
      end
    end
356349
public static List<ListNumber> dft(ListNumber x, ListNumber y) {
        if (x.size() != y.size()) {
            throw new IllegalArgumentException("Real and imaginary part must be of the same length");
        }
        
        double cosarg,sinarg;
        double[] resX = new double[x.size()];
        double[] resY = new double[x.size()];
        int direction = 1; // -1 would be inverse
        double size = x.size();

        for (int i = 0; i < x.size(); i++) {
            double arg = - direction * 2.0 * Math.PI * (double) i / size;
            for (int k = 0; k < x.size(); k++) {
                cosarg = Math.cos(k * arg);
                sinarg = Math.sin(k * arg);
                resX[i] += (x.getDouble(k) * cosarg - y.getDouble(k) * sinarg);
                resY[i] += (x.getDouble(k) * sinarg + y.getDouble(k) * cosarg);
            }
        }

        if (direction == 1) {
            for (int i = 0; i < x.size(); i++) {
                resX[i] = resX[i] / size;
                resY[i] = resY[i] / size;
            }
            return Arrays.<ListNumber>asList(new ArrayDouble(resX), new ArrayDouble(resY));
        } else {
            return Arrays.<ListNumber>asList(new ArrayDouble(resY), new ArrayDouble(resX));
        }
    }
217222
def _evaluate_xyz(self,x,y,z=0.):
        """"""
        return -np.pi * self._rhoc_M /(self.n+1.)*self.a**3*self._b*self._c * \
            _potInt(x, y, z, self._a2, self._b2*self._a2, self._c2*self._a2, self.n)
949301
def get_n_r(self):
        """"""
        return math.floor(self.n / self.eta**self.i + _epsilon), math.floor(self.r * self.eta**self.i + _epsilon)
441123
def symbolic_part(z, s):
    """
    if s == 1: return symre(z)
    elif s == -1: return symim(z)
    elif s == 0: return z
411025
public IMatrix getIy() {
        return (new IMatrix(getIplus().sub(getIminus()))).mul(new Complex(0d, 1d)).mul(new Complex(0.5, 0d));
    }
286063
function(a, b) {

      var z = new Complex(a, b);

      // Infinity * 0 = NaN
      if ((this['isInfinite']() && z['isZero']()) || (this['isZero']() && z['isInfinite']())) {
        return Complex['NAN'];
      }

      // Infinity * z = Infinity { where z != 0 }
      if (this['isInfinite']() || z['isInfinite']()) {
        return Complex['INFINITY'];
      }

      // Short circuit for real values
      if (z['im'] === 0 && this['im'] === 0) {
        return new Complex(this['re'] * z['re'], 0);
      }

      return new Complex(
              this['re'] * z['re'] - this['im'] * z['im'],
              this['re'] * z['im'] + this['im'] * z['re']);
    }