summaryrefslogtreecommitdiff
path: root/devdocs/python~3.12/c-api%2Fcomplex.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/python~3.12/c-api%2Fcomplex.html')
-rw-r--r--devdocs/python~3.12/c-api%2Fcomplex.html58
1 files changed, 58 insertions, 0 deletions
diff --git a/devdocs/python~3.12/c-api%2Fcomplex.html b/devdocs/python~3.12/c-api%2Fcomplex.html
new file mode 100644
index 00000000..a268d8e0
--- /dev/null
+++ b/devdocs/python~3.12/c-api%2Fcomplex.html
@@ -0,0 +1,58 @@
+ <span id="complexobjects"></span><h1>Complex Number Objects</h1> <p id="index-0">Python’s complex number objects are implemented as two distinct types when viewed from the C API: one is the Python object exposed to Python programs, and the other is a C structure which represents the actual complex number value. The API provides functions for working with both.</p> <section id="complex-numbers-as-c-structures"> <h2>Complex Numbers as C Structures</h2> <p>Note that the functions which accept these structures as parameters and return them as results do so <em>by value</em> rather than dereferencing them through pointers. This is consistent throughout the API.</p> <dl class="c type"> <dt class="sig sig-object c" id="c.Py_complex">
+<code>type Py_complex</code> </dt> <dd>
+<p>The C structure which corresponds to the value portion of a Python complex number object. Most of the functions for dealing with complex number objects use structures of this type as input or output values, as appropriate. It is defined as:</p> <pre data-language="c">typedef struct {
+ double real;
+ double imag;
+} Py_complex;
+</pre> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c._Py_c_sum">
+<code>Py_complex _Py_c_sum(Py_complex left, Py_complex right)</code> </dt> <dd>
+<p>Return the sum of two complex numbers, using the C <a class="reference internal" href="#c.Py_complex" title="Py_complex"><code>Py_complex</code></a> representation.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c._Py_c_diff">
+<code>Py_complex _Py_c_diff(Py_complex left, Py_complex right)</code> </dt> <dd>
+<p>Return the difference between two complex numbers, using the C <a class="reference internal" href="#c.Py_complex" title="Py_complex"><code>Py_complex</code></a> representation.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c._Py_c_neg">
+<code>Py_complex _Py_c_neg(Py_complex num)</code> </dt> <dd>
+<p>Return the negation of the complex number <em>num</em>, using the C <a class="reference internal" href="#c.Py_complex" title="Py_complex"><code>Py_complex</code></a> representation.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c._Py_c_prod">
+<code>Py_complex _Py_c_prod(Py_complex left, Py_complex right)</code> </dt> <dd>
+<p>Return the product of two complex numbers, using the C <a class="reference internal" href="#c.Py_complex" title="Py_complex"><code>Py_complex</code></a> representation.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c._Py_c_quot">
+<code>Py_complex _Py_c_quot(Py_complex dividend, Py_complex divisor)</code> </dt> <dd>
+<p>Return the quotient of two complex numbers, using the C <a class="reference internal" href="#c.Py_complex" title="Py_complex"><code>Py_complex</code></a> representation.</p> <p>If <em>divisor</em> is null, this method returns zero and sets <code>errno</code> to <code>EDOM</code>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c._Py_c_pow">
+<code>Py_complex _Py_c_pow(Py_complex num, Py_complex exp)</code> </dt> <dd>
+<p>Return the exponentiation of <em>num</em> by <em>exp</em>, using the C <a class="reference internal" href="#c.Py_complex" title="Py_complex"><code>Py_complex</code></a> representation.</p> <p>If <em>num</em> is null and <em>exp</em> is not a positive real number, this method returns zero and sets <code>errno</code> to <code>EDOM</code>.</p> </dd>
+</dl> </section> <section id="complex-numbers-as-python-objects"> <h2>Complex Numbers as Python Objects</h2> <dl class="c type"> <dt class="sig sig-object c" id="c.PyComplexObject">
+<code>type PyComplexObject</code> </dt> <dd>
+<p>This subtype of <a class="reference internal" href="structures#c.PyObject" title="PyObject"><code>PyObject</code></a> represents a Python complex number object.</p> </dd>
+</dl> <dl class="c var"> <dt class="sig sig-object c" id="c.PyComplex_Type">
+<code>PyTypeObject PyComplex_Type</code> </dt> <dd>
+<em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>This instance of <a class="reference internal" href="type#c.PyTypeObject" title="PyTypeObject"><code>PyTypeObject</code></a> represents the Python complex number type. It is the same object as <a class="reference internal" href="../library/functions#complex" title="complex"><code>complex</code></a> in the Python layer.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyComplex_Check">
+<code>int PyComplex_Check(PyObject *p)</code> </dt> <dd>
+<p>Return true if its argument is a <a class="reference internal" href="#c.PyComplexObject" title="PyComplexObject"><code>PyComplexObject</code></a> or a subtype of <a class="reference internal" href="#c.PyComplexObject" title="PyComplexObject"><code>PyComplexObject</code></a>. This function always succeeds.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyComplex_CheckExact">
+<code>int PyComplex_CheckExact(PyObject *p)</code> </dt> <dd>
+<p>Return true if its argument is a <a class="reference internal" href="#c.PyComplexObject" title="PyComplexObject"><code>PyComplexObject</code></a>, but not a subtype of <a class="reference internal" href="#c.PyComplexObject" title="PyComplexObject"><code>PyComplexObject</code></a>. This function always succeeds.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyComplex_FromCComplex">
+<code>PyObject *PyComplex_FromCComplex(Py_complex v)</code> </dt> <dd>
+<em class="refcount">Return value: New reference.</em><p>Create a new Python complex number object from a C <a class="reference internal" href="#c.Py_complex" title="Py_complex"><code>Py_complex</code></a> value.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyComplex_FromDoubles">
+<code>PyObject *PyComplex_FromDoubles(double real, double imag)</code> </dt> <dd>
+<em class="refcount">Return value: New reference.</em><em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Return a new <a class="reference internal" href="#c.PyComplexObject" title="PyComplexObject"><code>PyComplexObject</code></a> object from <em>real</em> and <em>imag</em>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyComplex_RealAsDouble">
+<code>double PyComplex_RealAsDouble(PyObject *op)</code> </dt> <dd>
+<em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Return the real part of <em>op</em> as a C <span class="c-expr sig sig-inline c"><span class="kt">double</span></span>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyComplex_ImagAsDouble">
+<code>double PyComplex_ImagAsDouble(PyObject *op)</code> </dt> <dd>
+<em class="stableabi"> Part of the <a class="reference internal" href="stable#stable"><span class="std std-ref">Stable ABI</span></a>.</em><p>Return the imaginary part of <em>op</em> as a C <span class="c-expr sig sig-inline c"><span class="kt">double</span></span>.</p> </dd>
+</dl> <dl class="c function"> <dt class="sig sig-object c" id="c.PyComplex_AsCComplex">
+<code>Py_complex PyComplex_AsCComplex(PyObject *op)</code> </dt> <dd>
+<p>Return the <a class="reference internal" href="#c.Py_complex" title="Py_complex"><code>Py_complex</code></a> value of the complex number <em>op</em>.</p> <p>If <em>op</em> is not a Python complex number object but has a <a class="reference internal" href="../reference/datamodel#object.__complex__" title="object.__complex__"><code>__complex__()</code></a> method, this method will first be called to convert <em>op</em> to a Python complex number object. If <code>__complex__()</code> is not defined then it falls back to <a class="reference internal" href="../reference/datamodel#object.__float__" title="object.__float__"><code>__float__()</code></a>. If <code>__float__()</code> is not defined then it falls back to <a class="reference internal" href="../reference/datamodel#object.__index__" title="object.__index__"><code>__index__()</code></a>. Upon failure, this method returns <code>-1.0</code> as a real value.</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.8: </span>Use <a class="reference internal" href="../reference/datamodel#object.__index__" title="object.__index__"><code>__index__()</code></a> if available.</p> </div> </dd>
+</dl> </section> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; 2001&ndash;2023 Python Software Foundation<br>Licensed under the PSF License.<br>
+ <a href="https://docs.python.org/3.12/c-api/complex.html" class="_attribution-link">https://docs.python.org/3.12/c-api/complex.html</a>
+ </p>
+</div>