ReactOS 0.4.15-dev-7846-g8ba6c66
complex< _Tp > Struct Template Reference

#include <_complex.h>

Public Types

typedef _Tp value_type
 
typedef complex< _Tp > _Self
 

Public Member Functions

 complex ()
 
 complex (const value_type &__x)
 
 complex (const value_type &__x, const value_type &__y)
 
 complex (const _Self &__z)
 
_Selfoperator= (const _Self &__z)
 
value_type real () const
 
value_type imag () const
 
_Selfoperator= (const value_type &__x)
 
_Selfoperator+= (const value_type &__x)
 
_Selfoperator-= (const value_type &__x)
 
_Selfoperator*= (const value_type &__x)
 
_Selfoperator/= (const value_type &__x)
 
_Selfoperator+= (const _Self &__z)
 
_Selfoperator-= (const _Self &__z)
 
_Selfoperator*= (const _Self &__z)
 
_Selfoperator/= (const _Self &__z)
 

Static Public Member Functions

static void _STLP_CALL _div (const value_type &__z1_r, const value_type &__z1_i, const value_type &__z2_r, const value_type &__z2_i, value_type &__res_r, value_type &__res_i)
 
static void _STLP_CALL _div (const value_type &__z1_r, const value_type &__z2_r, const value_type &__z2_i, value_type &__res_r, value_type &__res_i)
 

Public Attributes

value_type _M_re
 
value_type _M_im
 

Detailed Description

template<class _Tp>
struct complex< _Tp >

Definition at line 36 of file _complex.h.

Member Typedef Documentation

◆ _Self

template<class _Tp >
typedef complex<_Tp> complex< _Tp >::_Self

Definition at line 38 of file _complex.h.

◆ value_type

template<class _Tp >
typedef _Tp complex< _Tp >::value_type

Definition at line 37 of file _complex.h.

Constructor & Destructor Documentation

◆ complex() [1/4]

template<class _Tp >
complex< _Tp >::complex ( )
inline

Definition at line 41 of file _complex.h.

41: _M_re(0), _M_im(0) {}
value_type _M_im
Definition: _complex.h:171
value_type _M_re
Definition: _complex.h:170

◆ complex() [2/4]

template<class _Tp >
complex< _Tp >::complex ( const value_type __x)
inline

Definition at line 42 of file _complex.h.

43 : _M_re(__x), _M_im(0) {}

◆ complex() [3/4]

template<class _Tp >
complex< _Tp >::complex ( const value_type __x,
const value_type __y 
)
inline

Definition at line 44 of file _complex.h.

45 : _M_re(__x), _M_im(__y) {}

◆ complex() [4/4]

template<class _Tp >
complex< _Tp >::complex ( const _Self __z)
inline

Definition at line 46 of file _complex.h.

47 : _M_re(__z._M_re), _M_im(__z._M_im) {}

Member Function Documentation

◆ _div() [1/2]

template<class _Tp >
_STLP_BEGIN_NAMESPACE void complex< _Tp >::_div ( const value_type __z1_r,
const value_type __z1_i,
const value_type __z2_r,
const value_type __z2_i,
value_type __res_r,
value_type __res_i 
)
static

Definition at line 44 of file _complex.c.

46 {
47 _Tp __ar = __z2_r >= 0 ? __z2_r : -__z2_r;
48 _Tp __ai = __z2_i >= 0 ? __z2_i : -__z2_i;
49
50 if (__ar <= __ai) {
51 _Tp __ratio = __z2_r / __z2_i;
52 _Tp __denom = __z2_i * (1 + __ratio * __ratio);
53 __res_r = (__z1_r * __ratio + __z1_i) / __denom;
54 __res_i = (__z1_i * __ratio - __z1_r) / __denom;
55 }
56 else {
57 _Tp __ratio = __z2_i / __z2_r;
58 _Tp __denom = __z2_r * (1 + __ratio * __ratio);
59 __res_r = (__z1_r + __z1_i * __ratio) / __denom;
60 __res_i = (__z1_i - __z1_r * __ratio) / __denom;
61 }
62}

Referenced by operator/(), and complex< _Tp >::operator/=().

◆ _div() [2/2]

template<class _Tp >
void complex< _Tp >::_div ( const value_type __z1_r,
const value_type __z2_r,
const value_type __z2_i,
value_type __res_r,
value_type __res_i 
)
static

Definition at line 65 of file _complex.c.

67 {
68 _Tp __ar = __z2_r >= 0 ? __z2_r : -__z2_r;
69 _Tp __ai = __z2_i >= 0 ? __z2_i : -__z2_i;
70
71 if (__ar <= __ai) {
72 _Tp __ratio = __z2_r / __z2_i;
73 _Tp __denom = __z2_i * (1 + __ratio * __ratio);
74 __res_r = (__z1_r * __ratio) / __denom;
75 __res_i = - __z1_r / __denom;
76 }
77 else {
78 _Tp __ratio = __z2_i / __z2_r;
79 _Tp __denom = __z2_r * (1 + __ratio * __ratio);
80 __res_r = __z1_r / __denom;
81 __res_i = - (__z1_r * __ratio) / __denom;
82 }
83}

◆ imag()

template<class _Tp >
value_type complex< _Tp >::imag ( ) const
inline

Definition at line 70 of file _complex.h.

70{ return _M_im; }

Referenced by abs(), arg(), operator<<(), and polar().

◆ operator*=() [1/2]

template<class _Tp >
_Self & complex< _Tp >::operator*= ( const _Self __z)
inline

Definition at line 152 of file _complex.h.

152 {
153 value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
154 value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
155 _M_re = __r;
156 _M_im = __i;
157 return *this;
158 }
_Tp value_type
Definition: _complex.h:37

◆ operator*=() [2/2]

template<class _Tp >
_Self & complex< _Tp >::operator*= ( const value_type __x)
inline

Definition at line 87 of file _complex.h.

87 {
88 _M_re *= __x;
89 _M_im *= __x;
90 return *this;
91 }

◆ operator+=() [1/2]

template<class _Tp >
_Self & complex< _Tp >::operator+= ( const _Self __z)
inline

Definition at line 140 of file _complex.h.

140 {
141 _M_re += __z._M_re;
142 _M_im += __z._M_im;
143 return *this;
144 }

◆ operator+=() [2/2]

template<class _Tp >
_Self & complex< _Tp >::operator+= ( const value_type __x)
inline

Definition at line 79 of file _complex.h.

79 {
80 _M_re += __x;
81 return *this;
82 }

◆ operator-=() [1/2]

template<class _Tp >
_Self & complex< _Tp >::operator-= ( const _Self __z)
inline

Definition at line 146 of file _complex.h.

146 {
147 _M_re -= __z._M_re;
148 _M_im -= __z._M_im;
149 return *this;
150 }

◆ operator-=() [2/2]

template<class _Tp >
_Self & complex< _Tp >::operator-= ( const value_type __x)
inline

Definition at line 83 of file _complex.h.

83 {
84 _M_re -= __x;
85 return *this;
86 }

◆ operator/=() [1/2]

template<class _Tp >
_Self & complex< _Tp >::operator/= ( const _Self __z)
inline

Definition at line 160 of file _complex.h.

160 {
161 value_type __r;
162 value_type __i;
163 _div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
164 _M_re = __r;
165 _M_im = __i;
166 return *this;
167 }
static void _STLP_CALL _div(const value_type &__z1_r, const value_type &__z1_i, const value_type &__z2_r, const value_type &__z2_i, value_type &__res_r, value_type &__res_i)
Definition: _complex.c:44

◆ operator/=() [2/2]

template<class _Tp >
_Self & complex< _Tp >::operator/= ( const value_type __x)
inline

Definition at line 92 of file _complex.h.

92 {
93 _M_re /= __x;
94 _M_im /= __x;
95 return *this;
96 }

◆ operator=() [1/2]

template<class _Tp >
_Self & complex< _Tp >::operator= ( const _Self __z)
inline

Definition at line 49 of file _complex.h.

49 {
50 _M_re = __z._M_re;
51 _M_im = __z._M_im;
52 return *this;
53 }

◆ operator=() [2/2]

template<class _Tp >
_Self & complex< _Tp >::operator= ( const value_type __x)
inline

Definition at line 74 of file _complex.h.

74 {
75 _M_re = __x;
76 _M_im = 0;
77 return *this;
78 }

◆ real()

template<class _Tp >
value_type complex< _Tp >::real ( ) const
inline

Definition at line 69 of file _complex.h.

69{ return _M_re; }

Referenced by abs(), arg(), operator<<(), and polar().

Member Data Documentation

◆ _M_im

◆ _M_re


The documentation for this struct was generated from the following files: