STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Protected Member Functions | List of all members
_Complex_base< _Ty, _Valbase > Class Template Reference
Inheritance diagram for _Complex_base< _Ty, _Valbase >:

Public Types

typedef _Ctraits< _Ty > _Myctraits
 
typedef _Complex_base< _Ty, _Valbase > _Myt
 
typedef _Ty value_type
 

Public Member Functions

 _Complex_base (const _Ty &_Realval, const _Ty &_Imagval)
 
_Ty real (const _Ty &_Right)
 
_Ty imag (const _Ty &_Right)
 
_Ty real () const
 
_Ty imag () const
 

Protected Member Functions

template<class _Other >
void _Add (const complex< _Other > &_Right)
 
template<class _Other >
void _Sub (const complex< _Other > &_Right)
 
template<class _Other >
void _Mul (const complex< _Other > &_Right)
 
template<class _Other >
void _Div (const complex< _Other > &_Right)
 

Member Typedef Documentation

template<class _Ty, class _Valbase>
typedef _Ctraits<_Ty> _Complex_base< _Ty, _Valbase >::_Myctraits
template<class _Ty, class _Valbase>
typedef _Complex_base<_Ty, _Valbase> _Complex_base< _Ty, _Valbase >::_Myt
template<class _Ty, class _Valbase>
typedef _Ty _Complex_base< _Ty, _Valbase >::value_type

Constructor & Destructor Documentation

template<class _Ty, class _Valbase>
_Complex_base< _Ty, _Valbase >::_Complex_base ( const _Ty &  _Realval,
const _Ty &  _Imagval 
)
inline
600  { // construct from components of same type
601  this->_Val[_RE] = _Realval;
602  this->_Val[_IM] = _Imagval;
603  }
#define _RE
Definition: complex:40
#define _IM
Definition: complex:41
_FwdIt const _Ty _Val
Definition: algorithm:1938

Member Function Documentation

template<class _Ty, class _Valbase>
template<class _Other >
void _Complex_base< _Ty, _Valbase >::_Add ( const complex< _Other > &  _Right)
inlineprotected
628  { // add other complex
629  this->_Val[_RE] = this->_Val[_RE] + (_Ty)_Right.real();
630  this->_Val[_IM] = this->_Val[_IM] + (_Ty)_Right.imag();
631  }
#define _RE
Definition: complex:40
_Ty imag(const _Ty &_Right)
Definition: complex:610
_Ty real(const _Ty &_Right)
Definition: complex:605
#define _IM
Definition: complex:41
_FwdIt const _Ty _Val
Definition: algorithm:1938
template<class _Ty, class _Valbase>
template<class _Other >
void _Complex_base< _Ty, _Valbase >::_Div ( const complex< _Other > &  _Right)
inlineprotected
655  { // divide by other complex
656  typedef _Ctraits<_Ty> _Myctraits;
657  _Ty _Rightreal = (_Ty)_Right.real();
658  _Ty _Rightimag = (_Ty)_Right.imag();
659 
660  if (_Myctraits::_Isnan(_Rightreal) || _Myctraits::_Isnan(_Rightimag))
661  { // set NaN result
662  this->_Val[_RE] = _Myctraits::_Nanv(_Rightreal);
663  this->_Val[_IM] = this->_Val[_RE];
664  }
665  else if ((_Rightimag < 0 ? -_Rightimag : +_Rightimag)
666  < (_Rightreal < 0 ? -_Rightreal : +_Rightreal))
667  { // |_Right.imag()| < |_Right.real()|
668  _Ty _Wr = _Rightimag / _Rightreal;
669  _Ty _Wd = _Rightreal + _Wr * _Rightimag;
670 
671  if (_Myctraits::_Isnan(_Wd) || _Wd == 0)
672  { // set NaN result
673  this->_Val[_RE] = _Myctraits::_Nanv(_Rightreal);
674  this->_Val[_IM] = this->_Val[_RE];
675  }
676  else
677  { // compute representable result
678  _Ty _Tmp = (this->_Val[_RE]
679  + this->_Val[_IM] * _Wr) / _Wd;
680  this->_Val[_IM] = (this->_Val[_IM]
681  - this->_Val[_RE] * _Wr) / _Wd;
682  this->_Val[_RE] = _Tmp;
683  }
684  }
685  else if (_Rightimag == 0)
686  { // set NaN result
687  this->_Val[_RE] = _Myctraits::_Nanv(_Rightreal);
688  this->_Val[_IM] = this->_Val[_RE];
689  }
690  else
691  { // 0 < |_Right.real()| <= |_Right.imag()|
692  _Ty _Wr = _Rightreal / _Rightimag;
693  _Ty _Wd = _Rightimag + _Wr * _Rightreal;
694 
695  if (_Myctraits::_Isnan(_Wd) || _Wd == 0)
696  { // set NaN result
697  this->_Val[_RE] = _Myctraits::_Nanv(_Rightreal);
698  this->_Val[_IM] = this->_Val[_RE];
699  }
700  else
701  { // compute representable result
702  _Ty _Tmp = (this->_Val[_RE] * _Wr + this->_Val[_IM]) / _Wd;
703  this->_Val[_IM] = (this->_Val[_IM] * _Wr
704  - this->_Val[_RE]) / _Wd;
705  this->_Val[_RE] = _Tmp;
706  }
707  }
708  }
static _Ty _Nanv(_Ty)
Definition: complex:102
#define _RE
Definition: complex:40
_Ty imag(const _Ty &_Right)
Definition: complex:610
_Ctraits< _Ty > _Myctraits
Definition: complex:595
Definition: complex:59
_Ty real(const _Ty &_Right)
Definition: complex:605
#define _IM
Definition: complex:41
_FwdIt const _Ty _Val
Definition: algorithm:1938
static bool _Isnan(_Ty _Left)
Definition: complex:96
template<class _Ty, class _Valbase>
template<class _Other >
void _Complex_base< _Ty, _Valbase >::_Mul ( const complex< _Other > &  _Right)
inlineprotected
642  { // multiply by other complex
643  _Ty _Rightreal = (_Ty)_Right.real();
644  _Ty _Rightimag = (_Ty)_Right.imag();
645 
646  _Ty _Tmp = this->_Val[_RE] * _Rightreal
647  - this->_Val[_IM] * _Rightimag;
648  this->_Val[_IM] = this->_Val[_RE] * _Rightimag
649  + this->_Val[_IM] * _Rightreal;
650  this->_Val[_RE] = _Tmp;
651  }
#define _RE
Definition: complex:40
_Ty imag(const _Ty &_Right)
Definition: complex:610
_Ty real(const _Ty &_Right)
Definition: complex:605
#define _IM
Definition: complex:41
_FwdIt const _Ty _Val
Definition: algorithm:1938
template<class _Ty, class _Valbase>
template<class _Other >
void _Complex_base< _Ty, _Valbase >::_Sub ( const complex< _Other > &  _Right)
inlineprotected
635  { // subtract other complex
636  this->_Val[_RE] = this->_Val[_RE] - (_Ty)_Right.real();
637  this->_Val[_IM] = this->_Val[_IM] - (_Ty)_Right.imag();
638  }
#define _RE
Definition: complex:40
_Ty imag(const _Ty &_Right)
Definition: complex:610
_Ty real(const _Ty &_Right)
Definition: complex:605
#define _IM
Definition: complex:41
_FwdIt const _Ty _Val
Definition: algorithm:1938
template<class _Ty, class _Valbase>
_Ty _Complex_base< _Ty, _Valbase >::imag ( const _Ty &  _Right)
inline
611  { // set imaginary component
612  return (this->_Val[_IM] = _Right);
613  }
#define _IM
Definition: complex:41
_FwdIt const _Ty _Val
Definition: algorithm:1938
const _Ty & _Right
Definition: algorithm:4087
template<class _Ty, class _Valbase>
_Ty _Complex_base< _Ty, _Valbase >::imag ( ) const
inline
621  { // return imaginary component
622  return (this->_Val[_IM]);
623  }
#define _IM
Definition: complex:41
_FwdIt const _Ty _Val
Definition: algorithm:1938
template<class _Ty, class _Valbase>
_Ty _Complex_base< _Ty, _Valbase >::real ( const _Ty &  _Right)
inline
606  { // set real component
607  return (this->_Val[_RE] = _Right);
608  }
#define _RE
Definition: complex:40
_FwdIt const _Ty _Val
Definition: algorithm:1938
const _Ty & _Right
Definition: algorithm:4087
template<class _Ty, class _Valbase>
_Ty _Complex_base< _Ty, _Valbase >::real ( ) const
inline
616  { // return real component
617  return (this->_Val[_RE]);
618  }
#define _RE
Definition: complex:40
_FwdIt const _Ty _Val
Definition: algorithm:1938

The documentation for this class was generated from the following file: