NumericAnnex/docsets/NumericAnnex.docset/Contents/Resources/Documents/Protocols/Real.html

562 lines
26 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Real Protocol Reference</title>
<link rel="stylesheet" type="text/css" href="../css/highlight.css">
<link rel="stylesheet" type="text/css" href="../css/jazzy.css">
<script src="../js/jquery.min.js" defer></script>
<script src="../js/jazzy.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Protocol/Real" class="dashAnchor"></a>
<a title="Real Protocol Reference"></a>
<header>
<p class="primary">
<a href="../index.html">NumericAnnex Reference</a>
(100% documented)
</p>
<p>
<a href="https://github.com/xwu/NumericAnnex">View on GitHub</a>
</p>
<p>
<a href="dash-feed://https%3A%2F%2Fxwu%2Egithub%2Eio%2FNumericAnnex%2Fdocsets%2FNumericAnnex%2Exml">Install in Dash</a>
</p>
</header>
<div class="wrapper">
<nav>
<ul>
<li>
<p><a href="../Classes.html">Classes</a></p>
<ul>
<li>
<a href="../Classes/Random.html">Random</a>
</li>
<li>
<a href="../Classes/Random/Xoroshiro.html"> Xoroshiro</a>
</li>
</ul>
</li>
<li>
<p><a href="../Extensions.html">Extensions</a></p>
<ul>
<li>
<a href="../Extensions/BinaryInteger.html">BinaryInteger</a>
</li>
<li>
<a href="../Extensions/Double.html">Double</a>
</li>
<li>
<a href="../Extensions/Float.html">Float</a>
</li>
<li>
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
</li>
<li>
<a href="../Extensions/UnsignedInteger.html">UnsignedInteger</a>
</li>
</ul>
</li>
<li>
<p><a href="../Functions.html">Functions</a></p>
<ul>
<li>
<a href="../Functions.html#/s:12NumericAnnex3absAA7ComplexVyxGAeA4RealRzs9DecodableRzs9EncodableRzs33_ExpressibleByBuiltinFloatLiteralRzlF">abs(_:)</a>
</li>
<li>
<a href="../Functions.html#/s:12NumericAnnex3absAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF">abs(_:)</a>
</li>
<li>
<a href="../Functions.html#/s:12NumericAnnex4ceilAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF">ceil(_:)</a>
</li>
<li>
<a href="../Functions.html#/s:12NumericAnnex5floorAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF">floor(_:)</a>
</li>
<li>
<a href="../Functions.html#/s:12NumericAnnex5roundAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF">round(_:)</a>
</li>
<li>
<a href="../Functions.html#/s:12NumericAnnex4sqrtAA7ComplexVyxGAeA4RealRzs9DecodableRzs9EncodableRzs33_ExpressibleByBuiltinFloatLiteralRzlF">sqrt(_:)</a>
</li>
<li>
<a href="../Functions.html#/s:12NumericAnnex5truncAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF">trunc(_:)</a>
</li>
</ul>
</li>
<li>
<p><a href="../Protocols.html">Protocols</a></p>
<ul>
<li>
<a href="../Protocols/Math.html">Math</a>
</li>
<li>
<a href="../Protocols/PRNG.html">PRNG</a>
</li>
<li>
<a href="../Protocols/Real.html">Real</a>
</li>
</ul>
</li>
<li>
<p><a href="../Structs.html">Structs</a></p>
<ul>
<li>
<a href="../Structs/Complex.html">Complex</a>
</li>
<li>
<a href="../Structs/Rational.html">Rational</a>
</li>
</ul>
</li>
<li>
<p><a href="../Typealiases.html">Typealiases</a></p>
<ul>
<li>
<a href="../Typealiases.html#/s:12NumericAnnex12RoundingRulea">RoundingRule</a>
</li>
<li>
<a href="../Typealiases.html#/s:12NumericAnnex4Signa">Sign</a>
</li>
</ul>
</li>
</ul>
</nav>
<article>
<section>
<div class="wrapper">
<div class="overview">
<h1>Real</h1>
<div class="declaration">
<div class="language">
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">Real</span> <span class="p">:</span> <span class="kt"><a href="../Protocols/Math.html">Math</a></span><span class="p">,</span> <span class="kt">FloatingPoint</span></code></pre>
</div>
</div>
<p>A floating-point type that supports elementary functions and a selection of
special functions.</p>
<p>The <code>Real</code> protocol provides a suitable basis for writing functions that
work on any floating-point type that supports the required functions.</p>
</div>
</div>
</section>
<section class="toc">
<details open>
<summary>Topics</summary>
<div class="wrapper">
<ul>
<li><a href="#/s:12NumericAnnex4RealP5hypotxx_xtFZ">hypot(_:_:)</a></li>
<li><a href="#/s:12NumericAnnex4RealP14inverseTangentxx10dividingBy_tF">inverseTangent(dividingBy:)</a></li>
<li><a href="#/s:12NumericAnnex4RealP5errorxyF">error()</a></li>
<li><a href="#/s:12NumericAnnex4RealP18complementaryErrorxyF">complementaryError()</a></li>
<li><a href="#/s:12NumericAnnex4RealP5gammaxyF">gamma()</a></li>
<li><a href="#/s:12NumericAnnex4RealP16logarithmicGammaxyF">logarithmicGamma()</a></li>
</ul>
<ul>
<li><a href="#/s:12NumericAnnex4RealPAAE8cubeRootxyF">cubeRoot()</a></li>
</ul>
<ul>
<li><a href="#/s:12NumericAnnex4RealPAAE5atan2xx_xtFZ">atan2(_:_:)</a></li>
<li><a href="#/s:12NumericAnnex4RealPAAE3erfxxFZ">erf(_:)</a></li>
<li><a href="#/s:12NumericAnnex4RealPAAE4erfcxxFZ">erfc(_:)</a></li>
<li><a href="#/s:12NumericAnnex4RealPAAE6tgammaxxFZ">tgamma(_:)</a></li>
<li><a href="#/s:12NumericAnnex4RealPAAE6lgammaxxFZ">lgamma(_:)</a></li>
</ul>
</div>
</details>
</section>
<section>
<div class="wrapper">
<div class="group">
<ul>
<li>
<div>
<a name="/s:12NumericAnnex4RealP5hypotxx_xtFZ"></a>
<a name="//apple_ref/swift/Method/hypot(_:_:)" class="dashAnchor"></a>
<h4>
<code>hypot(_:_:)</code>
<span class="declaration-note">Default implementation</span>
</h4>
</div>
<div class="abstract">
<p>Returns the hypotenuse of a right-angle triangle with legs (catheti) of
length <code>x</code> and <code>y</code>, preventing avoidable arithmetic overflow and
underflow. The return value is the square root of the sum of squares of
the arguments.</p>
</div>
<div class="declaration">
<h5>Declaration</h5>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">static</span> <span class="kd">func</span> <span class="nf">hypot</span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">y</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="k">Self</span></code></pre>
</div>
</div>
<div class="parameters">
<h5>Parameters</h5>
<dl>
<dt><code>x</code></dt>
<dd>
<p>The length of one leg (cathetus) of a right-angle triangle.</p>
</dd>
<dt><code>y</code></dt>
<dd>
<p>The length of the other leg (cathetus) of a right-angle triangle.</p>
</dd>
</dl>
</div>
</li>
<li>
<div>
<a name="/s:12NumericAnnex4RealP14inverseTangentxx10dividingBy_tF"></a>
<a name="//apple_ref/swift/Method/inverseTangent(dividingBy:)" class="dashAnchor"></a>
<h4>
<code>inverseTangent(dividingBy:)</code>
<span class="declaration-note">Default implementation</span>
</h4>
</div>
<div class="abstract">
<p>Returns the inverse tangent of <code>self / other</code>, using the signs of <code>self</code>
and <code>other</code> to determine the quadrant of the computed angle.</p>
<p>If <code>self == 0 &amp;&amp; other == 0</code>, the return value is still finite.</p>
<div class="aside aside-see-also">
<p class="aside-title">See also</p>
<p><code><a href="../Protocols/Real.html#/s:12NumericAnnex4RealPAAE5atan2xx_xtFZ">atan2(_:_:)</a></code></p>
</div>
</div>
<div class="declaration">
<h5>Declaration</h5>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">inverseTangent</span><span class="p">(</span><span class="n">dividingBy</span> <span class="nv">other</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="k">Self</span></code></pre>
</div>
</div>
<div class="parameters">
<h5>Parameters</h5>
<dl>
<dt><code>other</code></dt>
<dd>
<p>The divisor by which to divide <code>self</code>.</p>
</dd>
</dl>
</div>
</li>
<li>
<div>
<a name="/s:12NumericAnnex4RealP5errorxyF"></a>
<a name="//apple_ref/swift/Method/error()" class="dashAnchor"></a>
<h4>
<code>error()</code>
</h4>
</div>
<div class="abstract">
<p>Returns the value of the <a href="http://mathworld.wolfram.com/Erf.html">error function</a> of <code>self</code>.</p>
<div class="aside aside-see-also">
<p class="aside-title">See also</p>
<code><a href="../Protocols/Real.html#/s:12NumericAnnex4RealPAAE3erfxxFZ">erf(_:)</a></code>
</div>
</div>
<div class="declaration">
<h5>Declaration</h5>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">error</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="k">Self</span></code></pre>
</div>
</div>
</li>
<li>
<div>
<a name="/s:12NumericAnnex4RealP18complementaryErrorxyF"></a>
<a name="//apple_ref/swift/Method/complementaryError()" class="dashAnchor"></a>
<h4>
<code>complementaryError()</code>
</h4>
</div>
<div class="abstract">
<p>Returns the value of the <a href="http://mathworld.wolfram.com/Erfc.html">complementary error function</a> of <code>self</code>.</p>
<div class="aside aside-see-also">
<p class="aside-title">See also</p>
<code><a href="../Protocols/Real.html#/s:12NumericAnnex4RealPAAE4erfcxxFZ">erfc(_:)</a></code>
</div>
</div>
<div class="declaration">
<h5>Declaration</h5>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">complementaryError</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="k">Self</span></code></pre>
</div>
</div>
</li>
<li>
<div>
<a name="/s:12NumericAnnex4RealP5gammaxyF"></a>
<a name="//apple_ref/swift/Method/gamma()" class="dashAnchor"></a>
<h4>
<code>gamma()</code>
</h4>
</div>
<div class="abstract">
<p>Returns the value of the <a href="http://mathworld.wolfram.com/GammaFunction.html">gamma function</a> of <code>self</code>.</p>
<div class="aside aside-see-also">
<p class="aside-title">See also</p>
<code><a href="../Protocols/Real.html#/s:12NumericAnnex4RealPAAE6tgammaxxFZ">tgamma(_:)</a></code>
</div>
</div>
<div class="declaration">
<h5>Declaration</h5>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">gamma</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="k">Self</span></code></pre>
</div>
</div>
</li>
<li>
<div>
<a name="/s:12NumericAnnex4RealP16logarithmicGammaxyF"></a>
<a name="//apple_ref/swift/Method/logarithmicGamma()" class="dashAnchor"></a>
<h4>
<code>logarithmicGamma()</code>
</h4>
</div>
<div class="abstract">
<p>Returns the value of the <a href="http://mathworld.wolfram.com/LogGammaFunction.html">logarithmic gamma function</a> of <code>self</code>.</p>
<div class="aside aside-see-also">
<p class="aside-title">See also</p>
<code><a href="../Protocols/Real.html#/s:12NumericAnnex4RealPAAE6lgammaxxFZ">lgamma(_:)</a></code>
</div>
</div>
<div class="declaration">
<h5>Declaration</h5>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">logarithmicGamma</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="k">Self</span></code></pre>
</div>
</div>
</li>
</ul>
</div>
<div class="group">
<ul>
<li>
<div>
<a name="/s:12NumericAnnex4RealPAAE8cubeRootxyF"></a>
<a name="//apple_ref/swift/Method/cubeRoot()" class="dashAnchor"></a>
<h4>
<code>cubeRoot()</code>
<span class="declaration-note">Extension method</span>
</h4>
</div>
<div class="abstract">
<p>Returns the cube root of the value, rounded to a representable value
(default implementation).</p>
<div class="aside aside-note">
<p class="aside-title">Note</p>
<p>This method is required by the protocol <code><a href="../Protocols/Math.html">Math</a></code>; it is not an
extension method.</p>
</div>
<div class="aside aside-see-also">
<p class="aside-title">See also</p>
<p><code>cbrt(_:)</code></p>
</div>
</div>
<div class="declaration">
<h5>Declaration</h5>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">cubeRoot</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="k">Self</span></code></pre>
</div>
</div>
</li>
</ul>
</div>
<div class="group">
<ul>
<li>
<div>
<a name="/s:12NumericAnnex4RealPAAE5atan2xx_xtFZ"></a>
<a name="//apple_ref/swift/Method/atan2(_:_:)" class="dashAnchor"></a>
<h4>
<code>atan2(_:_:)</code>
<span class="declaration-note">Extension method</span>
</h4>
</div>
<div class="abstract">
<p>Returns the inverse tangent of <code>y / x</code>, using the signs of <code>y</code> and <code>x</code> to
determine the quadrant of the computed angle.</p>
<p>If <code>x == 0 &amp;&amp; y == 0</code>, the return value is still finite.</p>
<div class="aside aside-see-also">
<p class="aside-title">See also</p>
<p><code><a href="../Protocols/Real.html#/s:12NumericAnnex4RealP14inverseTangentxx10dividingBy_tF">inverseTangent(dividingBy:)</a></code></p>
</div>
</div>
<div class="declaration">
<h5>Declaration</h5>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">atan2</span><span class="p">(</span><span class="n">_</span> <span class="nv">y</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="k">Self</span></code></pre>
</div>
</div>
<div class="parameters">
<h5>Parameters</h5>
<dl>
<dt><code>y</code></dt>
<dd>
<p>The value to divide.</p>
</dd>
<dt><code>x</code></dt>
<dd>
<p>The divisor by which to divide <code>y</code>.</p>
</dd>
</dl>
</div>
</li>
<li>
<div>
<a name="/s:12NumericAnnex4RealPAAE3erfxxFZ"></a>
<a name="//apple_ref/swift/Method/erf(_:)" class="dashAnchor"></a>
<h4>
<code>erf(_:)</code>
<span class="declaration-note">Extension method</span>
</h4>
</div>
<div class="abstract">
<p>Returns the value of the <a href="http://mathworld.wolfram.com/Erf.html">error function</a> of <code>x</code>.</p>
<div class="aside aside-see-also">
<p class="aside-title">See also</p>
<code><a href="../Protocols/Real.html#/s:12NumericAnnex4RealP5errorxyF">error()</a></code>
</div>
</div>
<div class="declaration">
<h5>Declaration</h5>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">erf</span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="k">Self</span></code></pre>
</div>
</div>
</li>
<li>
<div>
<a name="/s:12NumericAnnex4RealPAAE4erfcxxFZ"></a>
<a name="//apple_ref/swift/Method/erfc(_:)" class="dashAnchor"></a>
<h4>
<code>erfc(_:)</code>
<span class="declaration-note">Extension method</span>
</h4>
</div>
<div class="abstract">
<p>Returns the value of the <a href="http://mathworld.wolfram.com/Erfc.html">complementary error function</a> of <code>x</code>.</p>
<div class="aside aside-see-also">
<p class="aside-title">See also</p>
<code><a href="../Protocols/Real.html#/s:12NumericAnnex4RealP18complementaryErrorxyF">complementaryError()</a></code>
</div>
</div>
<div class="declaration">
<h5>Declaration</h5>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">erfc</span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="k">Self</span></code></pre>
</div>
</div>
</li>
<li>
<div>
<a name="/s:12NumericAnnex4RealPAAE6tgammaxxFZ"></a>
<a name="//apple_ref/swift/Method/tgamma(_:)" class="dashAnchor"></a>
<h4>
<code>tgamma(_:)</code>
<span class="declaration-note">Extension method</span>
</h4>
</div>
<div class="abstract">
<p>Returns the value of the <a href="http://mathworld.wolfram.com/GammaFunction.html">gamma function</a> of <code>x</code>.</p>
<div class="aside aside-see-also">
<p class="aside-title">See also</p>
<code><a href="../Protocols/Real.html#/s:12NumericAnnex4RealP5gammaxyF">gamma()</a></code>
</div>
</div>
<div class="declaration">
<h5>Declaration</h5>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">tgamma</span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="k">Self</span></code></pre>
</div>
</div>
</li>
<li>
<div>
<a name="/s:12NumericAnnex4RealPAAE6lgammaxxFZ"></a>
<a name="//apple_ref/swift/Method/lgamma(_:)" class="dashAnchor"></a>
<h4>
<code>lgamma(_:)</code>
<span class="declaration-note">Extension method</span>
</h4>
</div>
<div class="abstract">
<p>Returns the value of the <a href="http://mathworld.wolfram.com/LogGammaFunction.html">logarithmic gamma function</a> of <code>x</code>.</p>
<div class="aside aside-see-also">
<p class="aside-title">See also</p>
<code><a href="../Protocols/Real.html#/s:12NumericAnnex4RealP16logarithmicGammaxyF">logarithmicGamma()</a></code>
</div>
</div>
<div class="declaration">
<h5>Declaration</h5>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">lgamma</span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="k">Self</span></code></pre>
</div>
</div>
</li>
</ul>
</div>
</div>
</section>
</article>
</div>
<footer>
<p>&copy; 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-08-12)</p>
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.3, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</footer>
</body>
</div>
</html>