<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
 lang="en" dir="ltr">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>
    C++ Complex Numbers    [C++ Reference]
  </title>

  <meta name="generator" content="DokuWiki Release 2009-12-25c &quot;Lemming&quot;" />
<meta name="robots" content="index,follow" />
<meta name="date" content="2010-03-17T22:27:23-0700" />
<meta name="keywords" content="complex,start" />
<link rel="search" type="application/opensearchdescription+xml" href="/wiki/lib/exe/opensearch.php" title="C++ Reference" />
<link rel="start" href="/wiki/" />
<link rel="contents" href="/wiki/complex/start?do=index" title="Index" />
<link rel="alternate" type="application/rss+xml" title="Recent Changes" href="/wiki/feed.php" />
<link rel="alternate" type="application/rss+xml" title="Current Namespace" href="/wiki/feed.php?mode=list&amp;ns=complex" />
<link rel="edit" title="Edit this page" href="/wiki/complex/start?do=edit" />
<link rel="alternate" type="text/html" title="Plain HTML" href="/wiki/_export/xhtml/complex/start" />
<link rel="alternate" type="text/plain" title="Wiki Markup" href="/wiki/_export/raw/complex/start" />
<link rel="canonical" href="http://www.cppreference.com/wiki/complex/start" />
<link rel="stylesheet" media="all" type="text/css" href="/wiki/lib/exe/css.php?s=all&amp;t=custom1&amp;tseed=1272971091" />
<link rel="stylesheet" media="screen" type="text/css" href="/wiki/lib/exe/css.php?t=custom1&amp;tseed=1272971091" />
<link rel="stylesheet" media="print" type="text/css" href="/wiki/lib/exe/css.php?s=print&amp;t=custom1&amp;tseed=1272971091" />
<script type="text/javascript" charset="utf-8" ><!--//--><![CDATA[//><!--
var NS='complex';var JSINFO = {"id":"complex:start","namespace":"complex"};
//--><!]]></script>
<script type="text/javascript" charset="utf-8" src="/wiki/lib/exe/js.php?tseed=1272971091" ></script>

  <link rel="shortcut icon" href="/wiki/lib/tpl/custom1/images/favicon.png" />

  </head>

<body>
<div class="dokuwiki">
  
  <div class="stylehead">

    <div class="breadcrumbs">
      <span class="bchead">You are here: </span><a href="../start.html"  title="start">C++ Reference</a> &raquo; <a href="../complex/start.html"  title="complex:start">C++ Complex Numbers</a>    </div>
    
  </div>


  
  
  <div class="page">

    <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-2828341-1";
urchinTracker();
</script>
    <!-- wikipage start -->
    


<h1><a name="c_complex_numbers" id="c_complex_numbers">C++ Complex Numbers</a></h1>
<div class="level1">

<p>

The <code>complex</code> class provides a useful way to deal with complex numbers. It is defined as a basic template class in the <code>std</code> namespace in the <code>&lt;complex&gt;</code> header file.

</p>
<pre class="c code c++" style="font-family:monospace;"> template<span class="sy0">&lt;</span>typename Num<span class="sy0">&gt;</span>
 <span class="kw4">struct</span> complex<span class="sy0">;</span></pre>
<p>
The type parameter <code>Num</code> is the type that is used for each of the real and imaginary components of the complex number. It must be one of: <code>float</code>, <code>double</code>, or <code>long double</code>.

</p>
<table class="inline">
	<tr class="row0">
		<td class="col0"><a href="../complex/complex.html" class="wikilink1" title="complex:complex_constructors">Constructors</a></td><td class="col1">create complex numbers from the real and imaginary parts or other complex numbers</td>
	</tr>
	<tr class="row1">
		<td class="col0"><a href="../complex/operator.html" class="wikilink2" title="complex:complex_operators" rel="nofollow">Operators</a></td><td class="col1">arithmetic of complex numbers, equality of complex numbers, IO of complex numbers</td>
	</tr>
	<tr class="row2">
		<td class="col0"><a href="../complex/abs.html" class="wikilink1" title="complex:abs">abs</a></td><td class="col1">absolute value of a complex number</td>
	</tr>
	<tr class="row3">
		<td class="col0"><a href="../complex/arg.html" class="wikilink1" title="complex:arg">arg</a></td><td class="col1">argument (angle) of a complex number</td>
	</tr>
	<tr class="row4">
		<td class="col0"><a href="../complex/conj.html" class="wikilink1" title="complex:conj">conj</a></td><td class="col1">conjugate of a complex number</td>
	</tr>
	<tr class="row5">
		<td class="col0"><a href="../complex/cos.html" class="wikilink2" title="complex:cos" rel="nofollow">cos</a></td><td class="col1">cosine of a complex number</td>
	</tr>
	<tr class="row6">
		<td class="col0"><a href="../complex/cosh.html" class="wikilink2" title="complex:cosh" rel="nofollow">cosh</a></td><td class="col1">hyperbolic cosine of a complex number</td>
	</tr>
	<tr class="row7">
		<td class="col0"><a href="../complex/exp.html" class="wikilink2" title="complex:exp" rel="nofollow">exp</a></td><td class="col1">exponential of a complex number</td>
	</tr>
	<tr class="row8">
		<td class="col0"><a href="../complex/imag.html" class="wikilink1" title="complex:imag">imag</a></td><td class="col1">imaginary part of a complex number</td>
	</tr>
	<tr class="row9">
		<td class="col0"><a href="../complex/log.html" class="wikilink2" title="complex:log" rel="nofollow">log</a></td><td class="col1">natural logarithm of a complex number</td>
	</tr>
	<tr class="row10">
		<td class="col0"><a href="../complex/log10.html" class="wikilink2" title="complex:log10" rel="nofollow">log10</a></td><td class="col1">base-10 logarithm of a complex number</td>
	</tr>
	<tr class="row11">
		<td class="col0"><a href="../complex/norm.html" class="wikilink1" title="complex:norm">norm</a></td><td class="col1">square of the absolute value of a complex number</td>
	</tr>
	<tr class="row12">
		<td class="col0"><a href="../complex/polar.html" class="wikilink1" title="complex:polar">polar</a></td><td class="col1">constructs a complex number from polar coordinates</td>
	</tr>
	<tr class="row13">
		<td class="col0"><a href="../complex/pow.html" class="wikilink2" title="complex:pow" rel="nofollow">pow</a></td><td class="col1">raising a complex number to a power, raising to a complex number power, or both</td>
	</tr>
	<tr class="row14">
		<td class="col0"><a href="../complex/real.html" class="wikilink1" title="complex:real">real</a></td><td class="col1">real part of a complex number</td>
	</tr>
	<tr class="row15">
		<td class="col0"><a href="../complex/sin.html" class="wikilink2" title="complex:sin" rel="nofollow">sin</a></td><td class="col1">sine of a complex number</td>
	</tr>
	<tr class="row16">
		<td class="col0"><a href="../complex/sinh.html" class="wikilink2" title="complex:sinh" rel="nofollow">sinh</a></td><td class="col1">hyperbolic sine of a complex number</td>
	</tr>
	<tr class="row17">
		<td class="col0"><a href="../complex/sqrt.html" class="wikilink2" title="complex:sqrt" rel="nofollow">sqrt</a></td><td class="col1">square root of a complex number</td>
	</tr>
	<tr class="row18">
		<td class="col0"><a href="../complex/tan.html" class="wikilink2" title="complex:tan" rel="nofollow">tan</a></td><td class="col1">tangent of a complex number</td>
	</tr>
	<tr class="row19">
		<td class="col0"><a href="../complex/tanh.html" class="wikilink2" title="complex:tanh" rel="nofollow">tanh</a></td><td class="col1">hyperbolic tangent of a complex number</td>
	</tr>
</table>

</div>

    <!-- wikipage stop -->
  </div>

  <div class="clearer">&nbsp;</div>

  
  <div class="stylefoot">

    <div class="meta">
      <div class="user">
              </div>
      <!--
      <div class="doc">
        complex/start.txt &middot; Last modified: 03/17/2010 22:27 by 71.165.0.69      </div>
      -->
    </div>

   
    </div></div></body>
</html>