복소수 객체¶
-
type PyComplexObject¶
파이썬 복소수 객체를 나타내는
PyObject의 서브 형.-
Py_complex cval¶
The complex number value, using the C
Py_complexrepresentation.Deprecated since version 3.15, will be removed in version 3.20: Use
PyComplex_AsCComplex()andPyComplex_FromCComplex()to convert a Python complex number to/from the CPy_complexrepresentation.
-
Py_complex cval¶
-
PyTypeObject PyComplex_Type¶
- Part of the 안정 ABI.
이
PyTypeObject인스턴스는 파이썬 복소수 형을 나타냅니다. 파이썬 계층의complex와 같은 객체입니다.
-
int PyComplex_Check(PyObject *p)¶
인자가
PyComplexObject나PyComplexObject의 서브 형이면 참을 반환합니다. 이 함수는 항상 성공합니다.
-
int PyComplex_CheckExact(PyObject *p)¶
인자가
PyComplexObject이지만,PyComplexObject의 서브 유형이 아니면 참을 반환합니다. 이 함수는 항상 성공합니다.
-
PyObject *PyComplex_FromDoubles(double real, double imag)¶
- 반환값: 새 참조. Part of the 안정 ABI.
real 및 imag로 새로운
PyComplexObject객체를 반환합니다. 에러면 예외를 설정하고NULL을 반환합니다.
-
double PyComplex_RealAsDouble(PyObject *op)¶
- Part of the 안정 ABI.
op의 실수부를 C double로 반환합니다.
op가 파이썬 복소수 객체가 아니지만
__complex__()메서드가 있으면, 이 메서드는 먼저 op를 파이썬 복소수 객체로 변환하도록 그 메서드를 호출합니다.__complex__()가 정의되지 않았으면PyFloat_AsDouble()을 호출하는 것으로 대체하고 그 결과를 반환합니다.실패하면, 이 메서드는 예외를 설정하고
-1.0을 반환합니다.PyErr_Occurred()를 호출하여 에러를 확인해야 합니다.버전 3.13에서 변경: 사용할 수 있다면
__complex__()를 사용합니다.
-
double PyComplex_ImagAsDouble(PyObject *op)¶
- Part of the 안정 ABI.
op의 허수부를 C double로 반환합니다.
op가 파이썬 복소수 객체가 아니지만
__complex__()메서드가 있으면, 이 메서드는 먼저 op를 파이썬 복소수 객체로 변환하도록 그 메서드를 호출합니다.__complex__()가 정의되지 않았으면PyFloat_AsDouble()을 호출하는 것으로 대체하고 성공할 때0.0을 반환합니다.실패하면, 이 메서드는 예외를 설정하고
-1.0을 반환합니다.PyErr_Occurred()를 호출하여 에러를 확인해야 합니다.버전 3.13에서 변경: 사용할 수 있다면
__complex__()를 사용합니다.
-
type Py_complex¶
This C structure defines an export format for a Python complex number object.
구조체는 다음과 같이 정의됩니다:
typedef struct { double real; double imag; } Py_complex;
-
PyObject *PyComplex_FromCComplex(Py_complex v)¶
- 반환값: 새 참조.
C
Py_complex값으로 새로운 파이썬 복소수 객체를 만듭니다. 에러면 예외를 설정하고NULL을 반환합니다.
-
Py_complex PyComplex_AsCComplex(PyObject *op)¶
복소수 op의
Py_complex값을 반환합니다.op가 파이썬 복소수 객체가 아니지만
__complex__()메서드가 있으면, 이 메서드는 먼저 op를 파이썬 복소수 객체로 변환하도록 그 메서드를 호출합니다.__complex__()가 정의되지 않았으면__float__()로 대체합니다.__float__()가 정의되지 않았으면__index__()로 대체합니다.실패하면, 이 메서드는 예외를 설정하고
real을-1.0으로 설정한Py_complex를 반환합니다.PyErr_Occurred()를 호출하여 에러를 확인해야 합니다.버전 3.8에서 변경: 사용할 수 있다면
__index__()를 사용합니다.
C 구조체로서의 복소수¶
The API also provides functions for working with complex numbers, using the
Py_complex representation. Note that the functions which accept
these structures as parameters and return them as results do so by value
rather than dereferencing them through pointers.
Please note, that these functions are soft deprecated since Python 3.15. Avoid using this API in a new code to do complex arithmetic: either use the Number Protocol API or use native complex types, like double complex.
-
Py_complex _Py_c_sum(Py_complex left, Py_complex right)¶
C
Py_complex표현을 사용하여 두 복소수의 합을 반환합니다.버전 3.15부터 폐지됨.
-
Py_complex _Py_c_diff(Py_complex left, Py_complex right)¶
C
Py_complex표현을 사용하여 두 복소수의 차이를 반환합니다.버전 3.15부터 폐지됨.
-
Py_complex _Py_c_neg(Py_complex num)¶
C
Py_complex표현을 사용하여 복소수 num의 음의 값을 반환합니다.버전 3.15부터 폐지됨.
-
Py_complex _Py_c_prod(Py_complex left, Py_complex right)¶
C
Py_complex표현을 사용하여 두 복소수의 곱을 반환합니다.버전 3.15부터 폐지됨.
-
Py_complex _Py_c_quot(Py_complex dividend, Py_complex divisor)¶
C
Py_complex표현을 사용하여 두 복소수의 몫을 반환합니다.divisor가 null이면, 이 메서드는 0을 반환하고,
errno를EDOM으로 설정합니다.버전 3.15부터 폐지됨.
-
Py_complex _Py_c_pow(Py_complex num, Py_complex exp)¶
C
Py_complex표현을 사용하여 num의 exp 거듭제곱을 반환합니다.num이 null이고 exp가 양의 실수가 아니면, 이 메서드는 0을 반환하고
errno를EDOM으로 설정합니다.Set
errnotoERANGEon overflows.버전 3.15부터 폐지됨.
-
double _Py_c_abs(Py_complex num)¶
Return the absolute value of the complex number num.
Set
errnotoERANGEon overflows.버전 3.15부터 폐지됨.