Returns the **real** type for the real or imaginary part of a **real** complex type.

    For instance:

        COMPLEX128_t -> FLOAT64_t

    Args:
        cysparse:
838
def cysparse_real_type_from_real_cysparse_complex_type(cysparse_type):
    
    r_type = None

    if cysparse_type in ['COMPLEX64_t']:
        r_type = 'FLOAT32_t'
    elif cysparse_type in ['COMPLEX128_t']:
        r_type = 'FLOAT64_t'
    elif cysparse_type in ['COMPLEX256_t']:
        r_type = 'FLOAT128_t'
    else:
        raise TypeError("Not a recognized complex type")

    return r_type
91354
def iscomplex(polynomial):
    
    if isinstance(polynomial, (int, float)):
        return False
    if isinstance(polynomial, complex):
        return True
    polynomial = polynomial.expand()
    for monomial in polynomial.as_coefficients_dict():
        for variable in monomial.as_coeff_mul()[1]:
            if isinstance(variable, complex) or variable == I:
                return True
    return False
193147
def _realpart(self, f):
        """"""
        def f_re(x, **kwargs):
            result = np.asarray(f(x, **kwargs),
                                dtype=self.scalar_out_dtype)
            return result.real

        if is_real_dtype(self.out_dtype):
            return f
        else:
            return self.real_space.element(f_re)
1262258
def astype(self, dtype):
        """"""
        if dtype == "int":
            return Point2D( int( round(self.x, 0) ), int( round(self.y, 0) ) )
        elif dtype == "float":
            return Point2D( float(self.x), float(self.y))
        else:
            raise(RuntimeError("Invalid dtype: {}".format(dtype)))
1158866
def _isreal(obj):
    
    # pylint: disable=W0702
    if (obj is None) or isinstance(obj, bool):
        return False
    try:
        cond = (int(obj) == obj) or (float(obj) == obj)
    except:
        return False
    return cond
743200
protected function complexCompare(ComplexType $a, ComplexType $b)
    {
        if ($a->isReal() && $b->isReal()) {
            return $this->rationalCompare($a->r(), $b->r());
        }

        //hack to get around native php integer limitations
        //what we should be doing here is to return $this->rationalCompare($a->modulus(), $b->modulus())
        //but this blows up because of the big rationals it produces
        $am = $a->modulus()->asFloatType()->get();
        $bm = $b->modulus()->asFloatType()->get();

        if ($am == $bm) {
            return 0;
        }
        if ($am < $bm) {
            return -1;
        }
        return 1;
    }
582293
public static void convert(ComplexPolar_F64 input , Complex_F64 output ) {
        output.real = input.r * Math.cos(input.theta);
        output.imaginary = input.r * Math.sin(input.theta);
    }
33681
def _choose_float_dtype(dtype, has_offset):
    """"""
    # Keep float32 as-is.  Upcast half-precision to single-precision,
    # because float16 is "intended for storage but not computation"
    if dtype.itemsize <= 4 and np.issubdtype(dtype, np.floating):
        return np.float32
    # float32 can exactly represent all integers up to 24 bits
    if dtype.itemsize <= 2 and np.issubdtype(dtype, np.integer):
        # A scale factor is entirely safe (vanishing into the mantissa),
        # but a large integer offset could lead to loss of precision.
        # Sensitivity analysis can be tricky, so we just use a float64
        # if there's any offset at all - better unoptimised than wrong!
        if not has_offset:
            return np.float32
    # For all other types and circumstances, we just use float64.
    # (safe because eg. complex numbers are not supported in NetCDF)
    return np.float64
702583
public static void divide(Complex_F64 a, Complex_F64 b, Complex_F64 result) {
        double norm = b.getMagnitude2();
        result.real = (a.real * b.real + a.imaginary*b.imaginary)/norm;
        result.imaginary = (a.imaginary*b.real - a.real*b.imaginary)/norm;
    }
1358916
def real(self, newreal):
        
        try:
            iter(newreal)
        except TypeError:
            # `newreal` is not iterable, assume it can be assigned to
            # all indexed parts
            for part in self.parts:
                part.real = newreal
            return

        if self.space.is_power_space:
            try:
                # Set same value in all parts
                for part in self.parts:
                    part.real = newreal
            except (ValueError, TypeError):
                # Iterate over all parts and set them separately
                for part, new_re in zip(self.parts, newreal):
                    part.real = new_re
                pass
        elif len(newreal) == len(self):
            for part, new_re in zip(self.parts, newreal):
                part.real = new_re
        else:
            raise ValueError(
                'dimensions of the new real part does not match the space, '
                'got element {} to set real part of {}'.format(newreal, self))
595281
def real_out_dtype(self):
        """"""
        if self.__real_out_dtype is None:
            raise AttributeError(
                'no real variant of output dtype {} defined'
                ''.format(dtype_repr(self.scalar_out_dtype)))
        else:
            return self.__real_out_dtype
183293
public static double[][] getReal(ComplexNumber[][] cn) {
        double[][] n = new double[cn.length][cn[0].length];
        for (int i = 0; i < n.length; i++) {
            for (int j = 0; j < n[0].length; j++) {
                n[i][j] = cn[i][j].real;
            }
        }
        return n;
    }
245677
public Complex divide(Complex c)
    {
        Complex ret = new Complex(real, imag);
        ret.mutableDivide(c);
        return ret;
    }
1365491
def set_real(_bytearray, byte_index, real):
    
    real = float(real)
    real = struct.pack('>f', real)
    _bytes = struct.unpack('4B', real)
    for i, b in enumerate(_bytes):
        _bytearray[byte_index + i] = b
1339603
public static float spToPx(Context ctx, float spSize){
        return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, spSize, ctx.getResources().getDisplayMetrics());
    }
725222
public static BigComplex valueOf(double real, double imaginary) {
		return valueOf(BigDecimal.valueOf(real), BigDecimal.valueOf(imaginary));
	}
1281357
public static function IMCONJUGATE($complexNumber)
    {
        $complexNumber    = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);

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

        if ($parsedComplex['imaginary'] == 0.0) {
            return $parsedComplex['real'];
        } else {
            return self::cleanComplex(
                self::COMPLEX(
                    $parsedComplex['real'],
                    0 - $parsedComplex['imaginary'],
                    $parsedComplex['suffix']
                )
            );
        }
    }