complex.html
来自「ST20 Embedded Toolset R2.0.5用于开发基于ST20芯片」· HTML 代码 · 共 668 行 · 第 1/2 页
HTML
668 行
of type <I>double,</I> one that represents the real partof a complex number and one that represents the imaginary part.The class differs from its fictitious base class<CODE><A HREF="#complex">complex</A><double></CODE>only in the constructors it defines.The first constructor initializes the stored real part to<CODE>realval</CODE> and the stored imaginary part to <CODE>imagval</CODE>.The second constructor initializes the stored real part to<CODE>right.real()</CODE> and the stored imaginary part to<CODE>right.imag()</CODE>.The assignment operator stores <CODE>right</CODE> in the stored real partand zero in the stored imaginary part.</P><H2><A NAME="exp"><CODE>exp</CODE></A></H2><PRE>double_complex <B>exp</B>(const double_complex& left);float_complex <B>exp</B>(const float_complex& left);</PRE><P>The function returns the exponential of <CODE>left</CODE>.</P><H2><A NAME="float_complex"><CODE>float_complex</CODE></A></H2><PRE>class <B>float_complex</B> : public complex<float> {public: <B>float_complex</B>(float realval = 0, float imagval = 0); explicit <B>float_complex</B>(const double_complex& right); float_complex& <B>operator=</B>(const float right); };</PRE><P>The class describes an object that stores two objectsof type <I>float,</I> one that represents the real partof a complex number and one that represents the imaginary part.The class differs from its fictitious base class<CODE><A HREF="#complex">complex</A><float></CODE>only in the constructors it defines.The first constructor initializes the stored real part to<CODE>realval</CODE> and the stored imaginary part to <CODE>imagval</CODE>.The second constructor initializes the stored real part to<CODE>right.real()</CODE> and the stored imaginary part to<CODE>right.imag()</CODE>.The assignment operator stores <CODE>right</CODE> in the stored real partand zero in the stored imaginary part.</P><H2><A NAME="imag"><CODE>imag</CODE></A></H2><PRE>double <B>imag</B>(const double_complex& left);float <B>imag</B>(const float_complex& left);</PRE><P>The function returns the imaginary part of <CODE>left</CODE>.</P><H2><A NAME="log"><CODE>log</CODE></A></H2><PRE>double_complex <B>log</B>(const double_complex& left);float_complex <B>log</B>(const float_complex& left);</PRE><P>The function returns the logarithm of <CODE>left</CODE>.The branch cuts are along the negative real axis.</P><H2><A NAME="log10"><CODE>log10</CODE></A></H2><PRE>double_complex <B>log10</B>(const double_complex& left);float_complex <B>log10</B>(const float_complex& left);</PRE><P>The function returns the base 10logarithm of <CODE>left</CODE>.The branch cuts are along the negative real axis.</P><H2><A NAME="norm"><CODE>norm</CODE></A></H2><PRE>double <B>norm</B>(const double_complex& left);float <B>norm</B>(const float_complex& left);</PRE><P>The function returns the squared magnitude of <CODE>left</CODE>.</P><H2><A NAME="operator!="><CODE>operator!=</CODE></A></H2><PRE>bool <B>operator!=</B>(const double_complex& left, const double_complex& right);bool <B>operator!=</B>(const double_complex& left, const double& right);bool <B>operator!=</B>(const double& left, const double_complex& right);bool <B>operator!=</B>(const float_complex& left, const float_complex& right);bool <B>operator!=</B>(const float_complex& left, const float& right);bool <B>operator!=</B>(const float& left, const float_complex& right);</PRE><P>The operators each return true only if<CODE><A HREF="#real">real</A>(left) != real(right) ||<A HREF="#imag">imag</A>(left) != imag(right)</CODE>.</P><H2><A NAME="operator*"><CODE>operator*</CODE></A></H2><PRE>double_complex <B>operator*</B>(const double_complex& left, const double_complex;& right);double_complex <B>operator*</B>(const double_complex& left, const double& right);double_complex <B>operator*</B>(const double& left, const double_complex& right);float_complex <B>operator*</B>(const float_complex& left, const float_complex;& right);float_complex <B>operator*</B>(const float_complex& left, const float& right);float_complex <B>operator*</B>(const float& left, const float_complex& right);</PRE><P>The operators each convert both operands to the return type,then return the complex productof the converted <CODE>left</CODE> and <CODE>right</CODE>.</P><H2><A NAME="operator+"><CODE>operator+</CODE></A></H2><PRE>double_complex <B>operator+</B>(const double_complex& left, const double_complex;& right);double_complex <B>operator+</B>(const double_complex& left, const double& right);double_complex <B>operator+</B>(const double& left, const double_complex& right);double_complex <B>operator+</B>(const double_complex& left);float_complex <B>operator+</B>(const float_complex& left, const float_complex;& right);float_complex <B>operator+</B>(const float_complex& left, const float& right);float_complex <B>operator+</B>(const float& left, const float_complex& right);float_complex <B>operator+</B>(const float_complex& left);</PRE><P>The binary operators each convert both operands to the return type,then return the complex sumof the converted <CODE>left</CODE> and <CODE>right</CODE>.</P><P>The unary operator returns <CODE>left</CODE>.</P><H2><A NAME="operator-"><CODE>operator-</CODE></A></H2><PRE>double_complex <B>operator-</B>(const double_complex& left, const double_complex;& right);double_complex <B>operator-</B>(const double_complex& left, const double& right);double_complex <B>operator-</B>(const double& left, const double_complex& right);double_complex <B>operator-</B>(const double_complex& left);float_complex <B>operator-</B>(const float_complex& left, const float_complex;& right);float_complex <B>operator-</B>(const float_complex& left, const float& right);float_complex <B>operator-</B>(const float& left, const float_complex& right);float_complex <B>operator-</B>(const float_complex& left);</PRE><P>The binary operators each convert both operands to the return type,then return the complex differenceof the converted <CODE>left</CODE> and <CODE>right</CODE>.</P><P>The unary operator returns a value whose real part is<CODE>-<A HREF="#real">real</A>(left)</CODE> and whose imaginary part is<CODE>-<A HREF="#imag">imag</A>(left)</CODE>.</P><H2><A NAME="operator/"><CODE>operator/</CODE></A></H2><PRE>double_complex <B>operator/</B>(const double_complex& left, const double_complex;& right);double_complex <B>operator/</B>(const double_complex& left, const double& right);double_complex <B>operator/</B>(const double& left, const double_complex& right);float_complex <B>operator/</B>(const float_complex& left, const float_complex;& right);float_complex <B>operator/</B>(const float_complex& left, const float& right);float_complex <B>operator/</B>(const float& left, const float_complex& right);</PRE><P>The operators each convert both operands to the return type,then return the complex quotientof the converted <CODE>left</CODE> and <CODE>right</CODE>.</P><H2><A NAME="operator<<"><CODE>operator<<</CODE></A></H2><PRE>ostream& <B><A HREF="#operator<<">operator<<</A></B>(ostream& ostr, const double_complex& right);ostream& <B><A HREF="#operator<<">operator<<</A></B>(ostream& ostr, const float_complex& right);</PRE><P>The template function inserts the complex value <CODE>right</CODE>in the output stream <CODE>ostr</CODE>, effectively by executing:</P><PRE>ostringstream osstr;osstr.flags(ostr.flags());osstr.precision(ostr.precision());osstr << '(' << real(right) << ',' << imag(right) << ')';ostr << osstr.str().c_str();</PRE><P>Thus, if<CODE>ostr.<A HREF="ios.html#ios_base::width">width</A>()</CODE> isgreater than zero, any padding occurs either before or after theparenthesized pair of values, which itself contains no padding.The function returns <CODE>ostr</CODE>.</P><H2><A NAME="operator=="><CODE>operator==</CODE></A></H2><PRE>bool <B>operator==</B>(const double_complex& left, const double_complex& right);bool <B>operator==</B>(const double_complex& left, const double& right);bool <B>operator==</B>(const double& left, const double_complex& right);bool <B>operator==</B>(const float_complex& left, const float_complex& right);bool <B>operator==</B>(const float_complex& left, const float& right);bool <B>operator==</B>(const float& left, const float_complex& right);</PRE><P>The operators each return true only if<CODE><A HREF="#real">real</A>(left) == real(right) &&<A HREF="#imag">imag</A>(left) == imag(right)</CODE>.</P><H2><A NAME="operator>>"><CODE>operator>></CODE></A></H2><PRE>istream& <B>operator>></B>(istream& istr, double_complex& right);istream& <B>operator>></B>(istream& istr, float_complex& right);</PRE><P>The template function attempts to extract a complex valuefrom the input stream <CODE>istr</CODE>, effectively by executing:</P><PRE>istr >> ch && ch == '(' && istr >> re >> ch && ch == ',' && istr >> im >> ch && ch == ')'</PRE><P>Here, <CODE>ch</CODE> is an object of type <I>char,</I>and <CODE>re</CODE> and <CODE>im</CODE> are objects of the same typeas <CODE>right.real()</CODE>.</P><P>If the result of this expression is true, the function stores<CODE>re</CODE> in the real part and <CODE>im</CODE> in theimaginary part of <CODE>right</CODE>. In any event, the functionreturns <CODE>istr</CODE>.</P><H2><A NAME="polar"><CODE>polar</CODE></A></H2><PRE>double_complex <B>polar</B>(const double& rho, const double& theta = 0);float_complex <B>polar</B>(const float& rho, const float& theta);</PRE><P>The function returns the complex value whose magnitudeis <CODE>rho</CODE> and whose phase angle is <CODE>theta</CODE>.</P><H2><A NAME="pow"><CODE>pow</CODE></A></H2><PRE>double_complex <B>pow</B>(const double_complex& left, int right);double_complex <B>pow</B>(const double_complex& left, const Ty& right);double_complex <B>pow</B>(const double_complex& left, const double_complex& right);double_complex <B>pow</B>(const Ty& left, const double_complex& right);float_complex <B>pow</B>(const float_complex& left, int right);float_complex <B>pow</B>(const float_complex& left, const Ty& right);float_complex <B>pow</B>(const float_complex& left, const float_complex& right);float_complex <B>pow</B>(const Ty& left, const float_complex& right);</PRE><P>The functions each effectively convert both operands tothe return type, then return the converted<CODE>left</CODE> to the power <CODE>right</CODE>.The branch cut for <CODE>left</CODE> is along the negative real axis.</P><H2><A NAME="real"><CODE>real</CODE></A></H2><PRE>double <B>real</B>(const double_complex& left);float <B>real</B>(const float_complex& left);</PRE><P>The function returns the real part of <CODE>left</CODE>.</P><H2><A NAME="sin"><CODE>sin</CODE></A></H2><PRE>double_complex <B>sin</B>(const double_complex& left);float_complex <B>sin</B>(const float_complex& left);</PRE><P>The function returns the sine of <CODE>left</CODE>.</P><H2><A NAME="sinh"><CODE>sinh</CODE></A></H2><PRE>double_complex <B>sinh</B>(const double_complex& left);float_complex <B>sinh</B>(const float_complex& left);</PRE><P>The function returns the hyperbolic sine of <CODE>left</CODE>.</P><H2><A NAME="sqrt"><CODE>sqrt</CODE></A></H2><PRE>double_complex <B>sqrt</B>(const double_complex& left);float_complex <B>sqrt</B>(const float_complex& left);</PRE><P>The function returns the square root of <CODE>left</CODE>,with phase angle in the half-open interval <CODE>(-pi/2, pi/2]</CODE>.The branch cuts are along the negative real axis.</P><H2><A NAME="__STD_COMPLEX"><CODE>__STD_COMPLEX</CODE></A></H2><PRE>#define <B>__STD_COMPLEX</B></PRE><P>The macro is defined, with an unspecified expansion, to indicatecompliance with the specifications of this header.</P><H2><A NAME="tan"><CODE>tan</CODE></A></H2><PRE>double_complex <B>tan</B>(const double_complex& left);float_complex <B>tan</B>(const float_complex& left);</PRE><P>The function returns the tangent of <CODE>left</CODE>.</P><H2><A NAME="tanh"><CODE>tanh</CODE></A></H2><PRE>double_complex <B>tanh</B>(const double_complex& left);float_complex <B>tanh</B>(const float_complex& left);</PRE><P>The function returns the hyperbolic tangent of <CODE>left</CODE>.</P><HR><P>See also the<B><A HREF="index.html#Table of Contents">Table of Contents</A></B> and the<B><A HREF="_index.html">Index</A></B>.</P><P><I><A HREF="crit_pjp.html">Copyright</A> © 1992-2002by P.J. Plauger. All rights reserved.</I></P><!--V4.01:1125--></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?