Lines Matching full:real
37 r.real = a.real + b.real; in c_sum()
46 r.real = a.real - b.real; in c_diff()
55 r.real = -a.real; in c_neg()
64 r.real = a.real*b.real - a.imag*b.imag; in c_prod()
65 r.imag = a.real*b.imag + a.imag*b.real; in c_prod()
80 double d = b.real*b.real + b.imag*b.imag; in c_quot()
83 r.real = (a.real*b.real + a.imag*b.imag)/d; in c_quot()
84 r.imag = (a.imag*b.real - a.real*b.imag)/d; in c_quot()
89 * numerators and denominator by whichever of {b.real, b.imag} has in c_quot()
96 const double abs_breal = b.real < 0 ? -b.real : b.real; in c_quot()
100 /* divide tops and bottom by b.real */ in c_quot()
103 r.real = r.imag = 0.0; in c_quot()
106 const double ratio = b.imag / b.real; in c_quot()
107 const double denom = b.real + b.imag * ratio; in c_quot()
108 r.real = (a.real + a.imag * ratio) / denom; in c_quot()
109 r.imag = (a.imag - a.real * ratio) / denom; in c_quot()
114 const double ratio = b.real / b.imag; in c_quot()
115 const double denom = b.real * ratio + b.imag; in c_quot()
117 r.real = (a.real * ratio + a.imag) / denom; in c_quot()
118 r.imag = (a.imag * ratio - a.real) / denom; in c_quot()
121 /* At least one of b.real or b.imag is a NaN */ in c_quot()
122 r.real = r.imag = Py_NAN; in c_quot()
132 if (b.real == 0. && b.imag == 0.) { in c_pow()
133 r.real = 1.; in c_pow()
136 else if (a.real == 0. && a.imag == 0.) { in c_pow()
137 if (b.imag != 0. || b.real < 0.) in c_pow()
139 r.real = 0.; in c_pow()
143 vabs = hypot(a.real,a.imag); in c_pow()
144 len = pow(vabs,b.real); in c_pow()
145 at = atan2(a.imag, a.real); in c_pow()
146 phase = at*b.real; in c_pow()
151 r.real = len*cos(phase); in c_pow()
179 cn.real = (double) n; in c_powi()
196 if (!Py_IS_FINITE(z.real) || !Py_IS_FINITE(z.imag)) { in c_abs()
197 /* C99 rules: if either the real or the imaginary part is an in c_abs()
200 if (Py_IS_INFINITY(z.real)) { in c_abs()
201 result = fabs(z.real); in c_abs()
210 /* either the real or imaginary part is a NaN, in c_abs()
214 result = hypot(z.real, z.imag); in c_abs()
248 complex_subtype_from_doubles(PyTypeObject *type, double real, double imag) in complex_subtype_from_doubles() argument
251 c.real = real; in complex_subtype_from_doubles()
257 PyComplex_FromDoubles(double real, double imag) in PyComplex_FromDoubles() argument
260 c.real = real; in PyComplex_FromDoubles()
269 return ((PyComplexObject *)op)->cval.real; in PyComplex_RealAsDouble()
333 cv.real = -1.; in PyComplex_AsCComplex()
353 real part of the result, and fill in the imaginary part as 0. */ in PyComplex_AsCComplex()
356 cv.real = PyFloat_AsDouble(op); in PyComplex_AsCComplex()
386 if (v->cval.real == 0. && copysign(1.0, v->cval.real)==1.0) { in complex_format()
395 /* Format imaginary part with sign, real part without */ in complex_format()
396 pre = PyOS_double_to_string(v->cval.real, format_code, in complex_format()
466 hashreal = _Py_HashDouble(v->cval.real); in complex_hash()
496 pc->real = pc->imag = 0.0; in to_complex()
498 pc->real = PyInt_AS_LONG(obj); in to_complex()
502 pc->real = PyLong_AsDouble(obj); in to_complex()
503 if (pc->real == -1.0 && PyErr_Occurred()) { in to_complex()
510 pc->real = PyFloat_AsDouble(obj); in to_complex()
616 div.real = floor(div.real); /* Use the floor of the real part. */ in complex_remainder()
642 div.real = floor(div.real); /* Use the floor of the real part. */ in complex_divmod()
669 int_exponent = (long)exponent.real; in complex_pow()
670 if (exponent.imag == 0. && exponent.real == int_exponent) in complex_pow()
676 Py_ADJUST_ERANGE2(p.real, p.imag); in complex_pow()
715 neg.real = -v->cval.real; in complex_neg()
751 return v->cval.real != 0.0 || v->cval.imag != 0.0; in complex_nonzero()
760 cval.real = (double)PyInt_AsLong(*pw); in complex_coerce()
766 cval.real = PyLong_AsDouble(*pw); in complex_coerce()
767 if (cval.real == -1.0 && PyErr_Occurred()) in complex_coerce()
774 cval.real = PyFloat_AsDouble(*pw); in complex_coerce()
818 j = PyFloat_FromDouble(i.real); in complex_richcompare()
831 equal = (i.real == PyFloat_AsDouble(w) && i.imag == 0.0); in complex_richcompare()
837 equal = (i.real == j.real && i.imag == j.imag); in complex_richcompare()
898 return Py_BuildValue("(dd)", c.real, c.imag); in complex_getnewargs()
942 return PyBool_FromLong((long)(Py_IS_FINITE(c.real) &&
949 "Returns True if the real and the imaginary part is finite.");
966 {"real", T_DOUBLE, offsetof(PyComplexObject, cval.real), READONLY,
967 "the real part of a complex number"},
1023 <float> - real part only in complex_subtype_from_string()
1025 <float><signed-float>j - real and imaginary parts in complex_subtype_from_string()
1143 static char *kwlist[] = {"real", "imag", 0}; in complex_new()
1199 /* If we get this far, then the "real" and "imag" parts should in complex_new()
1201 complex number equal to (real + imag*1j). in complex_new()
1204 form; the "real" and "imag" parts might themselves be complex in complex_new()
1208 retaining its real & imag parts here, and the return in complex_new()
1217 /* The "real" part really is entirely real, and contributes in complex_new()
1223 than the original "real" argument. */ in complex_new()
1234 cr.real = PyFloat_AsDouble(tmp); in complex_new()
1239 ci.real = cr.imag; in complex_new()
1246 contributes nothing in the real direction. in complex_new()
1251 ci.real = PyFloat_AsDouble(tmp); in complex_new()
1254 /* If the input was in canonical form, then the "real" and "imag" in complex_new()
1255 parts are real numbers, so that ci.imag and cr.imag are zero. in complex_new()
1256 We need this correction in case they were not real numbers. */ in complex_new()
1259 cr.real -= ci.imag; in complex_new()
1262 ci.real += cr.imag; in complex_new()
1264 return complex_subtype_from_doubles(type, cr.real, ci.real); in complex_new()
1268 "complex(real[, imag]) -> complex number\n"
1270 "Create a complex number from a real part and an optional imaginary part.\n"
1271 "This is equivalent to (real + imag*1j) where imag defaults to 0.");