Compare commits
74 Commits
Author | SHA1 | Date |
---|---|---|
![]() |
84cc54e27d | |
![]() |
df2fdb5e47 | |
![]() |
b89a616423 | |
![]() |
ff93e4f6e5 | |
![]() |
4fe96908dd | |
![]() |
430c8b0f92 | |
![]() |
4866d2c445 | |
![]() |
4e552d177a | |
![]() |
7dbc0fdf4a | |
![]() |
4567210eb5 | |
![]() |
3b7a96ac20 | |
![]() |
549e9a8068 | |
![]() |
8685816017 | |
![]() |
3091966872 | |
![]() |
c2b204b52a | |
![]() |
af7ecbe5dc | |
![]() |
d249080347 | |
![]() |
43078eba79 | |
![]() |
21797a27c6 | |
![]() |
ed1f699270 | |
![]() |
70806040c2 | |
![]() |
615b2d3dd5 | |
![]() |
0b8ca5e0c9 | |
![]() |
ba1be89844 | |
![]() |
f956653b94 | |
![]() |
e9770db6cb | |
![]() |
d720def3de | |
![]() |
1a7e232324 | |
![]() |
3c201debb3 | |
![]() |
fbf5de6b1c | |
![]() |
47eb87ac71 | |
![]() |
9db23d960c | |
![]() |
08d633b51e | |
![]() |
7926395462 | |
![]() |
d3528300e1 | |
![]() |
4d86a9f9a4 | |
![]() |
df5d67f057 | |
![]() |
45f6d435ee | |
![]() |
85b5b1aa69 | |
![]() |
00e087482f | |
![]() |
45d53def42 | |
![]() |
8ed64471df | |
![]() |
45791e7346 | |
![]() |
fb9264f790 | |
![]() |
91595aaf9b | |
![]() |
d3d2319952 | |
![]() |
347c19ccc5 | |
![]() |
5bd5c26270 | |
![]() |
9e00c90399 | |
![]() |
4be41cb25e | |
![]() |
dd7b25f7a4 | |
![]() |
06a6711a08 | |
![]() |
8b46c763ea | |
![]() |
1be062a90e | |
![]() |
4b143e581c | |
![]() |
14fb3051f5 | |
![]() |
3200dde589 | |
![]() |
3614c32760 | |
![]() |
36a7ed01b2 | |
![]() |
51405cc98f | |
![]() |
fcefdb0db8 | |
![]() |
56a6e7a536 | |
![]() |
62ed708666 | |
![]() |
bdf6c6ced0 | |
![]() |
9c928aa2e3 | |
![]() |
de63a951c3 | |
![]() |
f0430b8091 | |
![]() |
f2545cafa3 | |
![]() |
79d331bcd9 | |
![]() |
3a48d63826 | |
![]() |
5066c80f28 | |
![]() |
461a141b90 | |
![]() |
dc31dd2748 | |
![]() |
4eff9ced7a |
|
@ -1,4 +1,2 @@
|
|||
.DS_Store
|
||||
/.build
|
||||
/Packages
|
||||
/*.xcodeproj
|
||||
undocumented.json
|
||||
|
|
|
@ -0,0 +1,246 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Classes 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 title="Classes 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Classes</h1>
|
||||
<p>The following classes are available globally.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex6RandomC">Random</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex6RandomC"></a>
|
||||
<a name="//apple_ref/swift/Class/Random" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Random</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>A pseudo-random number generator (PRNG) that implements
|
||||
<a href="http://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf"><code>xorshift128+</code></a>, an efficient linear-feedback shift register.</p>
|
||||
<div class="aside aside-warning">
|
||||
<p class="aside-title">Warning</p>
|
||||
Once seeded from cryptographically secure random bytes, an
|
||||
instance of <code>Random</code> generates high-quality random numbers but is <em>not</em> a
|
||||
cryptographically secure PRNG.
|
||||
|
||||
</div>
|
||||
|
||||
<p>To generate random numbers, create your own instance of <code>Random</code> with an
|
||||
internal state seeded from cryptographically secure random bytes:</p>
|
||||
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">random</span> <span class="o">=</span> <span class="kt">Random</span><span class="p">()</span><span class="o">!</span>
|
||||
<span class="k">let</span> <span class="nv">x</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">()</span> <span class="k">as</span> <span class="kt">Int</span>
|
||||
|
||||
<span class="c1">// You can also pass the desired result type as an argument.</span>
|
||||
<span class="k">let</span> <span class="nv">y</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="kt">Int</span><span class="o">.</span><span class="k">self</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">x</span> <span class="o">></span> <span class="n">y</span> <span class="p">{</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="s">"Here's a random value between 0 and 42 (inclusive):"</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="mi">42</span><span class="p">))</span>
|
||||
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="s">"Here's a random value between -42 and 0 (inclusive):"</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="o">-</span><span class="mi">42</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="mi">0</span><span class="p">))</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
<div class="aside aside-see-also">
|
||||
<p class="aside-title">See also</p>
|
||||
<code><a href="Classes/Random/Xoroshiro.html">Random.Xoroshiro</a></code>, <code><a href="Protocols/PRNG.html">PRNG</a></code>
|
||||
|
||||
</div>
|
||||
|
||||
<a href="Classes/Random.html">See more…</a>
|
||||
</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">final</span> <span class="kd">class</span> <span class="kt">Random</span> <span class="p">:</span> <span class="kt"><a href="Protocols/PRNG.html">PRNG</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,389 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Random Class 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/Class/Random" class="dashAnchor"></a>
|
||||
<a title="Random Class 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Random</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">final</span> <span class="kd">class</span> <span class="kt">Random</span> <span class="p">:</span> <span class="kt"><a href="../Protocols/PRNG.html">PRNG</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>A pseudo-random number generator (PRNG) that implements
|
||||
<a href="http://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf"><code>xorshift128+</code></a>, an efficient linear-feedback shift register.</p>
|
||||
<div class="aside aside-warning">
|
||||
<p class="aside-title">Warning</p>
|
||||
Once seeded from cryptographically secure random bytes, an
|
||||
instance of <code>Random</code> generates high-quality random numbers but is <em>not</em> a
|
||||
cryptographically secure PRNG.
|
||||
|
||||
</div>
|
||||
|
||||
<p>To generate random numbers, create your own instance of <code>Random</code> with an
|
||||
internal state seeded from cryptographically secure random bytes:</p>
|
||||
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">random</span> <span class="o">=</span> <span class="kt">Random</span><span class="p">()</span><span class="o">!</span>
|
||||
<span class="k">let</span> <span class="nv">x</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">()</span> <span class="k">as</span> <span class="kt">Int</span>
|
||||
|
||||
<span class="c1">// You can also pass the desired result type as an argument.</span>
|
||||
<span class="k">let</span> <span class="nv">y</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="kt">Int</span><span class="o">.</span><span class="k">self</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">x</span> <span class="o">></span> <span class="n">y</span> <span class="p">{</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="s">"Here's a random value between 0 and 42 (inclusive):"</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="mi">42</span><span class="p">))</span>
|
||||
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="s">"Here's a random value between -42 and 0 (inclusive):"</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="o">-</span><span class="mi">42</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="mi">0</span><span class="p">))</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
<div class="aside aside-see-also">
|
||||
<p class="aside-title">See also</p>
|
||||
<code><a href="../Classes/Random/Xoroshiro.html">Random.Xoroshiro</a></code>, <code><a href="../Protocols/PRNG.html">PRNG</a></code>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex6RandomC5states6UInt64V_AFtv">state</a></li>
|
||||
<li><a href="#/s:12NumericAnnex6RandomCACs6UInt64V_AEt5state_tcfc">init(state:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex6RandomCACSgycfc">init()</a></li>
|
||||
<li><a href="#/s:s16IteratorProtocolP4next7ElementQzSgyF">next()</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex6RandomC9XoroshiroC">Xoroshiro</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex6RandomC5states6UInt64V_AFtv"></a>
|
||||
<a name="//apple_ref/swift/Property/state" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>state</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>The internal state of the pseudo-random number generator.</p>
|
||||
|
||||
</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="k">var</span> <span class="nv">state</span><span class="p">:</span> <span class="p">(</span><span class="kt">UInt64</span><span class="p">,</span> <span class="kt">UInt64</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex6RandomCACs6UInt64V_AEt5state_tcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(state:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(state:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a pseudo-random number generator with the given internal state.</p>
|
||||
|
||||
</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="nf">init</span><span class="p">(</span><span class="nv">state</span><span class="p">:</span> <span class="p">(</span><span class="kt">UInt64</span><span class="p">,</span> <span class="kt">UInt64</span><span class="p">))</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>state</code></dt>
|
||||
<dd>
|
||||
<p>The value to be used as the generator’s internal state.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex6RandomCACSgycfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a pseudo-random number generator with an internal state seeded
|
||||
using cryptographically secure random bytes.</p>
|
||||
|
||||
<p>If cryptographically secure random bytes are unavailable, the result is
|
||||
<code>nil</code>.</p>
|
||||
|
||||
</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="n">convenience</span> <span class="nf">init</span><span class="p">?()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s16IteratorProtocolP4next7ElementQzSgyF"></a>
|
||||
<a name="//apple_ref/swift/Method/next()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>next()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">next</span><span class="p">()</span> <span class="o">-></span> <span class="kt">UInt64</span><span class="p">?</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex6RandomC9XoroshiroC"></a>
|
||||
<a name="//apple_ref/swift/Class/Xoroshiro" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Xoroshiro</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>A pseudo-random number generator (PRNG) that implements <code>xoroshiro128+</code>, a
|
||||
successor to <code>xorshift128+</code> devised by S. Vigna and D. Blackman.</p>
|
||||
<div class="aside aside-warning">
|
||||
<p class="aside-title">Warning</p>
|
||||
Once seeded from cryptographically secure random bytes, an
|
||||
instance of <code>Random.Xoroshiro</code> generates high-quality random numbers but
|
||||
is <em>not</em> a cryptographically secure PRNG.
|
||||
|
||||
</div>
|
||||
|
||||
<p>To generate random numbers, create your own instance of <code>Random.Xoroshiro</code>
|
||||
with an internal state seeded from cryptographically secure random bytes:</p>
|
||||
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">random</span> <span class="o">=</span> <span class="kt">Random</span><span class="o">.</span><span class="kt">Xoroshiro</span><span class="p">()</span><span class="o">!</span>
|
||||
<span class="k">let</span> <span class="nv">x</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">()</span> <span class="k">as</span> <span class="kt">Int</span>
|
||||
|
||||
<span class="c1">// You can also pass the desired result type as an argument.</span>
|
||||
<span class="k">let</span> <span class="nv">y</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="kt">Int</span><span class="o">.</span><span class="k">self</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">x</span> <span class="o">></span> <span class="n">y</span> <span class="p">{</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="s">"Here's a random value between 0 and 42 (inclusive):"</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="mi">42</span><span class="p">))</span>
|
||||
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="s">"Here's a random value between -42 and 0 (inclusive):"</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="o">-</span><span class="mi">42</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="mi">0</span><span class="p">))</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
<div class="aside aside-see-also">
|
||||
<p class="aside-title">See also</p>
|
||||
<code><a href="../Classes/Random.html">Random</a></code>, <code><a href="../Protocols/PRNG.html">PRNG</a></code>
|
||||
|
||||
</div>
|
||||
|
||||
<a href="../Classes/Random/Xoroshiro.html">See more…</a>
|
||||
</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">final</span> <span class="kd">class</span> <span class="kt">Xoroshiro</span> <span class="p">:</span> <span class="kt"><a href="../Protocols/PRNG.html">PRNG</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,330 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Xoroshiro Class 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/Class/Xoroshiro" class="dashAnchor"></a>
|
||||
<a title="Xoroshiro Class 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Xoroshiro</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">final</span> <span class="kd">class</span> <span class="kt">Xoroshiro</span> <span class="p">:</span> <span class="kt"><a href="../../Protocols/PRNG.html">PRNG</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>A pseudo-random number generator (PRNG) that implements <code>xoroshiro128+</code>, a
|
||||
successor to <code>xorshift128+</code> devised by S. Vigna and D. Blackman.</p>
|
||||
<div class="aside aside-warning">
|
||||
<p class="aside-title">Warning</p>
|
||||
Once seeded from cryptographically secure random bytes, an
|
||||
instance of <code>Random.Xoroshiro</code> generates high-quality random numbers but
|
||||
is <em>not</em> a cryptographically secure PRNG.
|
||||
|
||||
</div>
|
||||
|
||||
<p>To generate random numbers, create your own instance of <code>Random.Xoroshiro</code>
|
||||
with an internal state seeded from cryptographically secure random bytes:</p>
|
||||
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">random</span> <span class="o">=</span> <span class="kt">Random</span><span class="o">.</span><span class="kt">Xoroshiro</span><span class="p">()</span><span class="o">!</span>
|
||||
<span class="k">let</span> <span class="nv">x</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">()</span> <span class="k">as</span> <span class="kt">Int</span>
|
||||
|
||||
<span class="c1">// You can also pass the desired result type as an argument.</span>
|
||||
<span class="k">let</span> <span class="nv">y</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="kt">Int</span><span class="o">.</span><span class="k">self</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">x</span> <span class="o">></span> <span class="n">y</span> <span class="p">{</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="s">"Here's a random value between 0 and 42 (inclusive):"</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="mi">42</span><span class="p">))</span>
|
||||
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="s">"Here's a random value between -42 and 0 (inclusive):"</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="o">-</span><span class="mi">42</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="mi">0</span><span class="p">))</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
<div class="aside aside-see-also">
|
||||
<p class="aside-title">See also</p>
|
||||
<code><a href="../../Classes/Random.html">Random</a></code>, <code><a href="../../Protocols/PRNG.html">PRNG</a></code>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex6RandomC9XoroshiroC5states6UInt64V_AHtv">state</a></li>
|
||||
<li><a href="#/s:12NumericAnnex6RandomC9XoroshiroCAEs6UInt64V_AGt5state_tcfc">init(state:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex6RandomC9XoroshiroCAESgycfc">init()</a></li>
|
||||
<li><a href="#/s:s16IteratorProtocolP4next7ElementQzSgyF">next()</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex6RandomC9XoroshiroC5states6UInt64V_AHtv"></a>
|
||||
<a name="//apple_ref/swift/Property/state" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>state</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>The internal state of the pseudo-random number generator.</p>
|
||||
|
||||
</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="k">var</span> <span class="nv">state</span><span class="p">:</span> <span class="p">(</span><span class="kt">UInt64</span><span class="p">,</span> <span class="kt">UInt64</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex6RandomC9XoroshiroCAEs6UInt64V_AGt5state_tcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(state:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(state:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a pseudo-random number generator with the given internal state.</p>
|
||||
|
||||
</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="nf">init</span><span class="p">(</span><span class="nv">state</span><span class="p">:</span> <span class="p">(</span><span class="kt">UInt64</span><span class="p">,</span> <span class="kt">UInt64</span><span class="p">))</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>state</code></dt>
|
||||
<dd>
|
||||
<p>The value to be used as the generator’s internal state.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex6RandomC9XoroshiroCAESgycfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a pseudo-random number generator with an internal state seeded
|
||||
using cryptographically secure random bytes.</p>
|
||||
|
||||
<p>If cryptographically secure random bytes are unavailable, the result is
|
||||
<code>nil</code>.</p>
|
||||
|
||||
</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="n">convenience</span> <span class="nf">init</span><span class="p">?()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s16IteratorProtocolP4next7ElementQzSgyF"></a>
|
||||
<a name="//apple_ref/swift/Method/next()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>next()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">next</span><span class="p">()</span> <span class="o">-></span> <span class="kt">UInt64</span><span class="p">?</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,549 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Extensions 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 title="Extensions 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Extensions</h1>
|
||||
<p>The following extensions are available globally.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s13BinaryIntegerP">BinaryInteger</a></li>
|
||||
<li><a href="#/s:s15UnsignedIntegerP">UnsignedInteger</a></li>
|
||||
<li><a href="#/s:Si">Int</a></li>
|
||||
<li><a href="#/s:s4Int8V">Int8</a></li>
|
||||
<li><a href="#/s:s5Int16V">Int16</a></li>
|
||||
<li><a href="#/s:s5Int32V">Int32</a></li>
|
||||
<li><a href="#/s:s5Int64V">Int64</a></li>
|
||||
<li><a href="#/s:Su">UInt</a></li>
|
||||
<li><a href="#/s:s5UInt8V">UInt8</a></li>
|
||||
<li><a href="#/s:s6UInt16V">UInt16</a></li>
|
||||
<li><a href="#/s:s6UInt32V">UInt32</a></li>
|
||||
<li><a href="#/s:s6UInt64V">UInt64</a></li>
|
||||
<li><a href="#/">DoubleWidth</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:Sf">Float</a></li>
|
||||
<li><a href="#/s:Sd">Double</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:s13FloatingPointP">FloatingPoint</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP"></a>
|
||||
<a name="//apple_ref/swift/Extension/BinaryInteger" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>BinaryInteger</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/BinaryInteger.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">protocol</span> <span class="kt">BinaryInteger</span> <span class="p">:</span> <span class="kt">Hashable</span><span class="p">,</span> <span class="kt">Numeric</span><span class="p">,</span> <span class="kt">CustomStringConvertible</span><span class="p">,</span> <span class="kt">Strideable</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s15UnsignedIntegerP"></a>
|
||||
<a name="//apple_ref/swift/Extension/UnsignedInteger" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>UnsignedInteger</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/UnsignedInteger.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">protocol</span> <span class="kt">UnsignedInteger</span> <span class="p">:</span> <span class="kt">BinaryInteger</span> <span class="k">where</span> <span class="k">Self</span><span class="o">.</span><span class="kt">Magnitude</span> <span class="p">:</span> <span class="kt">BinaryInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:Si"></a>
|
||||
<a name="//apple_ref/swift/Extension/Int" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Int</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/Int.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s4Int8V"></a>
|
||||
<a name="//apple_ref/swift/Extension/Int8" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Int8</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/Int8.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int8</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int16V"></a>
|
||||
<a name="//apple_ref/swift/Extension/Int16" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Int16</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/Int16.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int16</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int32V"></a>
|
||||
<a name="//apple_ref/swift/Extension/Int32" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Int32</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/Int32.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int32</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int64V"></a>
|
||||
<a name="//apple_ref/swift/Extension/Int64" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Int64</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/Int64.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int64</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:Su"></a>
|
||||
<a name="//apple_ref/swift/Extension/UInt" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>UInt</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/UInt.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5UInt8V"></a>
|
||||
<a name="//apple_ref/swift/Extension/UInt8" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>UInt8</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/UInt8.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt8</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt16V"></a>
|
||||
<a name="//apple_ref/swift/Extension/UInt16" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>UInt16</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/UInt16.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt16</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt32V"></a>
|
||||
<a name="//apple_ref/swift/Extension/UInt32" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>UInt32</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/UInt32.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt32</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt64V"></a>
|
||||
<a name="//apple_ref/swift/Extension/UInt64" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>UInt64</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/UInt64.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt64</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/"></a>
|
||||
<a name="//apple_ref/swift/Extension/DoubleWidth" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>DoubleWidth</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/DoubleWidth.html">See more…</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:Sf"></a>
|
||||
<a name="//apple_ref/swift/Extension/Float" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Float</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/Float.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:Sd"></a>
|
||||
<a name="//apple_ref/swift/Extension/Double" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Double</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/Double.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13FloatingPointP"></a>
|
||||
<a name="//apple_ref/swift/Extension/FloatingPoint" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>FloatingPoint</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/FloatingPoint.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">protocol</span> <span class="kt">FloatingPoint</span> <span class="p">:</span> <span class="kt">SignedNumeric</span><span class="p">,</span> <span class="kt">Strideable</span><span class="p">,</span> <span class="kt">Hashable</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,564 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>BinaryInteger Extension 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/Extension/BinaryInteger" class="dashAnchor"></a>
|
||||
<a title="BinaryInteger Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>BinaryInteger</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">protocol</span> <span class="kt">BinaryInteger</span> <span class="p">:</span> <span class="kt">Hashable</span><span class="p">,</span> <span class="kt">Numeric</span><span class="p">,</span> <span class="kt">CustomStringConvertible</span><span class="p">,</span> <span class="kt">Strideable</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<p><a href="#/Exponentiation">Exponentiation</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexE2mmoixx_xtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexE3mmeoiyxz_xtFZ">**=(_:_:)</a></li>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexE3powxx_xtFZ">pow(_:_:)</a></li>
|
||||
</ul>
|
||||
<p><a href="#/Square%20Root">Square Root</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexE4sqrtxxFZ">sqrt(_:)</a></li>
|
||||
</ul>
|
||||
<p><a href="#/Cube%20Root">Cube Root</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexsAARzs08UnsignedB09MagnitudeRpzlE4cbrtxxFZ">cbrt(_:)</a></li>
|
||||
</ul>
|
||||
<p><a href="#/Factoring">Factoring</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexsAARzs08UnsignedB09MagnitudeRpzlE3gcdxx_xtFZ">gcd(_:_:)</a></li>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexsAARzs08UnsignedB09MagnitudeRpzlE3lcmxx_xtFZ">lcm(_:_:)</a></li>
|
||||
</ul>
|
||||
<p><a href="#/Factoring%20(Fixed-Width)">Factoring (Fixed-Width)</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexs010FixedWidthB0RzsAD9MagnitudeRpzs08UnsignedB0AFRQAE_AEs0C0PQZAFRSlE20gcdReportingOverflowx12partialValue_Sb8overflowtx_xtFZ">gcdReportingOverflow(_:_:)</a></li>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexs010FixedWidthB0RzsAD9MagnitudeRpzs08UnsignedB0AFRQAE_AEs0C0PQZAFRSlE20lcmReportingOverflowx12partialValue_Sb8overflowtx_xtFZ">lcmReportingOverflow(_:_:)</a></li>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexs010FixedWidthB0RzsAD9MagnitudeRpzs08UnsignedB0AFRQAE_AEs0C0PQZAFRSlE07lcmFullF0x4high_AF3lowtx_xtFZ">lcmFullWidth(_:_:)</a></li>
|
||||
</ul>
|
||||
<p><a href="#/Initializers">Initializers</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexExSgAC8RationalVyqd__G7exactly_tcs9DecodableRd__s9EncodableRd__s06SignedB0Rd__s021_ExpressibleByBuiltinB7LiteralRd__s08UnsignedB09Magnitudes0C0PRpd__AnP_ANQYd__AQRSlufc">init(exactly:)</a></li>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexExAC8RationalVyqd__Gcs9DecodableRd__s9EncodableRd__s06SignedB0Rd__s021_ExpressibleByBuiltinB7LiteralRd__s08UnsignedB09Magnitudes0C0PRpd__AlN_ALQYd__AORSlufc">init(_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Exponentiation"></a>
|
||||
<a name="//apple_ref/swift/Section/Exponentiation" class="dashAnchor"></a>
|
||||
<h3>Exponentiation</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexE2mmoixx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexE3mmeoiyxz_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="k">Self</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexE3powxx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/pow(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>pow(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>base</code> to the power of <code>exponent</code>, rounded
|
||||
to a representable value (deprecated).</p>
|
||||
|
||||
</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">pow</span><span class="p">(</span><span class="n">_</span> <span class="nv">base</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">exponent</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Square%20Root"></a>
|
||||
<a name="//apple_ref/swift/Section/Square Root" class="dashAnchor"></a>
|
||||
<h3>Square Root</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexE4sqrtxxFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/sqrt(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>sqrt(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the square root of <code>x</code>, rounding toward zero. If <code>x</code> is negative,
|
||||
a runtime error may occur.</p>
|
||||
|
||||
</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">sqrt</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">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Cube%20Root"></a>
|
||||
<a name="//apple_ref/swift/Section/Cube Root" class="dashAnchor"></a>
|
||||
<h3>Cube Root</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexsAARzs08UnsignedB09MagnitudeRpzlE4cbrtxxFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/cbrt(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>cbrt(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the cube root of <code>x</code>, rounding toward zero.</p>
|
||||
|
||||
</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">cbrt</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">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Factoring"></a>
|
||||
<a name="//apple_ref/swift/Section/Factoring" class="dashAnchor"></a>
|
||||
<h3>Factoring</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexsAARzs08UnsignedB09MagnitudeRpzlE3gcdxx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/gcd(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>gcd(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the greatest common divisor of <code>a</code> and <code>b</code>.</p>
|
||||
|
||||
</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">gcd</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexsAARzs08UnsignedB09MagnitudeRpzlE3lcmxx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/lcm(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>lcm(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the least common multiple of <code>a</code> and <code>b</code>.</p>
|
||||
|
||||
</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">lcm</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Factoring%20(Fixed-Width)"></a>
|
||||
<a name="//apple_ref/swift/Section/Factoring (Fixed-Width)" class="dashAnchor"></a>
|
||||
<h3>Factoring (Fixed-Width)</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexs010FixedWidthB0RzsAD9MagnitudeRpzs08UnsignedB0AFRQAE_AEs0C0PQZAFRSlE20gcdReportingOverflowx12partialValue_Sb8overflowtx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/gcdReportingOverflow(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>gcdReportingOverflow(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the greatest common divisor of <code>a</code> and <code>b</code> and a flag to indicate
|
||||
whether overflow occurred during the operation.</p>
|
||||
|
||||
</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">gcdReportingOverflow</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span>
|
||||
<span class="o">-></span> <span class="p">(</span><span class="nv">partialValue</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="nv">overflow</span><span class="p">:</span> <span class="kt">Bool</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexs010FixedWidthB0RzsAD9MagnitudeRpzs08UnsignedB0AFRQAE_AEs0C0PQZAFRSlE20lcmReportingOverflowx12partialValue_Sb8overflowtx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/lcmReportingOverflow(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>lcmReportingOverflow(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the least common multiple of <code>a</code> and <code>b</code> and a flag to indicate
|
||||
whether overflow occurred during the operation.</p>
|
||||
|
||||
</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">lcmReportingOverflow</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span>
|
||||
<span class="o">-></span> <span class="p">(</span><span class="nv">partialValue</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="nv">overflow</span><span class="p">:</span> <span class="kt">Bool</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexs010FixedWidthB0RzsAD9MagnitudeRpzs08UnsignedB0AFRQAE_AEs0C0PQZAFRSlE07lcmFullF0x4high_AF3lowtx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/lcmFullWidth(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>lcmFullWidth(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the high and low parts of the least common multiple of <code>a</code> and <code>b</code>
|
||||
computed using full-width arithmetic.</p>
|
||||
|
||||
</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">lcmFullWidth</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span>
|
||||
<span class="o">-></span> <span class="p">(</span><span class="nv">high</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="nv">low</span><span class="p">:</span> <span class="k">Self</span><span class="o">.</span><span class="kt">Magnitude</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Initializers"></a>
|
||||
<a name="//apple_ref/swift/Section/Initializers" class="dashAnchor"></a>
|
||||
<h3>Initializers</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexExSgAC8RationalVyqd__G7exactly_tcs9DecodableRd__s9EncodableRd__s06SignedB0Rd__s021_ExpressibleByBuiltinB7LiteralRd__s08UnsignedB09Magnitudes0C0PRpd__AnP_ANQYd__AQRSlufc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(exactly:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(exactly:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a new binary integer from the given rational value, if it can be
|
||||
represented exactly.</p>
|
||||
|
||||
<p>If <code>source</code> is not representable exactly, the result is <code>nil</code>.</p>
|
||||
|
||||
</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">init</span><span class="p">?</span><span class="o"><</span><span class="kt">U</span><span class="o">></span><span class="p">(</span><span class="n">exactly</span> <span class="nv">source</span><span class="p">:</span> <span class="kt"><a href="../Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">U</span><span class="o">></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>source</code></dt>
|
||||
<dd>
|
||||
<p>A rational value to convert to a binary integer.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexExAC8RationalVyqd__Gcs9DecodableRd__s9EncodableRd__s06SignedB0Rd__s021_ExpressibleByBuiltinB7LiteralRd__s08UnsignedB09Magnitudes0C0PRpd__AlN_ALQYd__AORSlufc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a new binary integer from the given rational value, rounding
|
||||
toward zero.</p>
|
||||
|
||||
<p>If <code>source</code> is outside the bounds of this type after rounding toward zero,
|
||||
a runtime error may occur.</p>
|
||||
|
||||
</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">init</span><span class="o"><</span><span class="kt">U</span><span class="o">></span><span class="p">(</span><span class="n">_</span> <span class="nv">source</span><span class="p">:</span> <span class="kt"><a href="../Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">U</span><span class="o">></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>source</code></dt>
|
||||
<dd>
|
||||
<p>A rational value to convert to a binary integer.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,856 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Double Extension 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/Extension/Double" class="dashAnchor"></a>
|
||||
<a title="Double Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Double</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<p><a href="#/Real">Real</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4MathP1exvZ">e</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP3phixvZ">phi</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP2mmoixx_xtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP3mmeoiyxz_xtFZ">**=(_:_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP18naturalExponentialxyF">naturalExponential()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP17binaryExponentialxyF">binaryExponential()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP17commonExponentialxyF">commonExponential()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP26naturalExponentialMinusOnexyF">naturalExponentialMinusOne()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP16naturalLogarithmxyF">naturalLogarithm()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP15binaryLogarithmxyF">binaryLogarithm()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP15commonLogarithmxyF">commonLogarithm()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP23naturalLogarithmOnePlusxyF">naturalLogarithmOnePlus()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP8cubeRootxyF">cubeRoot()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP4sinexyF">sine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP6cosinexyF">cosine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP7tangentxyF">tangent()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP11inverseSinexyF">inverseSine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP13inverseCosinexyF">inverseCosine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP14inverseTangentxyF">inverseTangent()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP14hyperbolicSinexyF">hyperbolicSine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP16hyperbolicCosinexyF">hyperbolicCosine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP17hyperbolicTangentxyF">hyperbolicTangent()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP21inverseHyperbolicSinexyF">inverseHyperbolicSine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP23inverseHyperbolicCosinexyF">inverseHyperbolicCosine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP24inverseHyperbolicTangentxyF">inverseHyperbolicTangent()</a></li>
|
||||
<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>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Real"></a>
|
||||
<a name="//apple_ref/swift/Section/Real" class="dashAnchor"></a>
|
||||
<h3>Real</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP1exvZ"></a>
|
||||
<a name="//apple_ref/swift/Variable/e" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>e</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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="k">var</span> <span class="nv">e</span><span class="p">:</span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP3phixvZ"></a>
|
||||
<a name="//apple_ref/swift/Variable/phi" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>phi</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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="k">var</span> <span class="nv">phi</span><span class="p">:</span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP2mmoixx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">Double</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Double</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP3mmeoiyxz_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Double</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Double</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP18naturalExponentialxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/naturalExponential()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>naturalExponential()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">naturalExponential</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP17binaryExponentialxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/binaryExponential()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>binaryExponential()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">binaryExponential</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP17commonExponentialxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/commonExponential()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>commonExponential()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">commonExponential</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP26naturalExponentialMinusOnexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/naturalExponentialMinusOne()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>naturalExponentialMinusOne()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">naturalExponentialMinusOne</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP16naturalLogarithmxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/naturalLogarithm()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>naturalLogarithm()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">naturalLogarithm</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP15binaryLogarithmxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/binaryLogarithm()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>binaryLogarithm()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">binaryLogarithm</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP15commonLogarithmxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/commonLogarithm()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>commonLogarithm()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">commonLogarithm</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP23naturalLogarithmOnePlusxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/naturalLogarithmOnePlus()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>naturalLogarithmOnePlus()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">naturalLogarithmOnePlus</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP8cubeRootxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/cubeRoot()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>cubeRoot()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP4sinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/sine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>sine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">sine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP6cosinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/cosine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>cosine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">cosine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP7tangentxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/tangent()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>tangent()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">tangent</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP11inverseSinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseSine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseSine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseSine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP13inverseCosinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseCosine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseCosine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseCosine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP14inverseTangentxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseTangent()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseTangent()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseTangent</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP14hyperbolicSinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/hyperbolicSine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>hyperbolicSine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">hyperbolicSine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP16hyperbolicCosinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/hyperbolicCosine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>hyperbolicCosine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">hyperbolicCosine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP17hyperbolicTangentxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/hyperbolicTangent()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>hyperbolicTangent()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">hyperbolicTangent</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP21inverseHyperbolicSinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseHyperbolicSine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseHyperbolicSine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseHyperbolicSine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP23inverseHyperbolicCosinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseHyperbolicCosine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseHyperbolicCosine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseHyperbolicCosine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP24inverseHyperbolicTangentxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseHyperbolicTangent()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseHyperbolicTangent()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseHyperbolicTangent</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4RealP5hypotxx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/hypot(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>hypot(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">hypot</span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="kt">Double</span><span class="p">,</span> <span class="n">_</span> <span class="nv">y</span><span class="p">:</span> <span class="kt">Double</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</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>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseTangent</span><span class="p">(</span><span class="n">dividingBy</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">Double</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</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">
|
||||
|
||||
</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">error</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</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">
|
||||
|
||||
</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">complementaryError</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</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">
|
||||
|
||||
</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">gamma</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</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">
|
||||
|
||||
</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">logarithmicGamma</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,223 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>DoubleWidth Extension 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/Extension/DoubleWidth" class="dashAnchor"></a>
|
||||
<a title="DoubleWidth Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>DoubleWidth</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/">**(_:_:)</a></li>
|
||||
<li><a href="#/">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,856 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Float Extension 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/Extension/Float" class="dashAnchor"></a>
|
||||
<a title="Float Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Float</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<p><a href="#/Real">Real</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4MathP1exvZ">e</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP3phixvZ">phi</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP2mmoixx_xtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP3mmeoiyxz_xtFZ">**=(_:_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP18naturalExponentialxyF">naturalExponential()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP17binaryExponentialxyF">binaryExponential()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP17commonExponentialxyF">commonExponential()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP26naturalExponentialMinusOnexyF">naturalExponentialMinusOne()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP16naturalLogarithmxyF">naturalLogarithm()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP15binaryLogarithmxyF">binaryLogarithm()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP15commonLogarithmxyF">commonLogarithm()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP23naturalLogarithmOnePlusxyF">naturalLogarithmOnePlus()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP8cubeRootxyF">cubeRoot()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP4sinexyF">sine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP6cosinexyF">cosine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP7tangentxyF">tangent()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP11inverseSinexyF">inverseSine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP13inverseCosinexyF">inverseCosine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP14inverseTangentxyF">inverseTangent()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP14hyperbolicSinexyF">hyperbolicSine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP16hyperbolicCosinexyF">hyperbolicCosine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP17hyperbolicTangentxyF">hyperbolicTangent()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP21inverseHyperbolicSinexyF">inverseHyperbolicSine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP23inverseHyperbolicCosinexyF">inverseHyperbolicCosine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP24inverseHyperbolicTangentxyF">inverseHyperbolicTangent()</a></li>
|
||||
<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>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Real"></a>
|
||||
<a name="//apple_ref/swift/Section/Real" class="dashAnchor"></a>
|
||||
<h3>Real</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP1exvZ"></a>
|
||||
<a name="//apple_ref/swift/Variable/e" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>e</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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="k">var</span> <span class="nv">e</span><span class="p">:</span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP3phixvZ"></a>
|
||||
<a name="//apple_ref/swift/Variable/phi" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>phi</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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="k">var</span> <span class="nv">phi</span><span class="p">:</span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP2mmoixx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">Float</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Float</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP3mmeoiyxz_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Float</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Float</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP18naturalExponentialxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/naturalExponential()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>naturalExponential()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">naturalExponential</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP17binaryExponentialxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/binaryExponential()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>binaryExponential()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">binaryExponential</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP17commonExponentialxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/commonExponential()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>commonExponential()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">commonExponential</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP26naturalExponentialMinusOnexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/naturalExponentialMinusOne()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>naturalExponentialMinusOne()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">naturalExponentialMinusOne</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP16naturalLogarithmxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/naturalLogarithm()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>naturalLogarithm()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">naturalLogarithm</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP15binaryLogarithmxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/binaryLogarithm()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>binaryLogarithm()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">binaryLogarithm</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP15commonLogarithmxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/commonLogarithm()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>commonLogarithm()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">commonLogarithm</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP23naturalLogarithmOnePlusxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/naturalLogarithmOnePlus()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>naturalLogarithmOnePlus()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">naturalLogarithmOnePlus</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP8cubeRootxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/cubeRoot()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>cubeRoot()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP4sinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/sine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>sine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">sine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP6cosinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/cosine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>cosine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">cosine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP7tangentxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/tangent()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>tangent()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">tangent</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP11inverseSinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseSine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseSine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseSine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP13inverseCosinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseCosine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseCosine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseCosine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP14inverseTangentxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseTangent()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseTangent()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseTangent</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP14hyperbolicSinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/hyperbolicSine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>hyperbolicSine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">hyperbolicSine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP16hyperbolicCosinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/hyperbolicCosine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>hyperbolicCosine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">hyperbolicCosine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP17hyperbolicTangentxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/hyperbolicTangent()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>hyperbolicTangent()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">hyperbolicTangent</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP21inverseHyperbolicSinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseHyperbolicSine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseHyperbolicSine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseHyperbolicSine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP23inverseHyperbolicCosinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseHyperbolicCosine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseHyperbolicCosine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseHyperbolicCosine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP24inverseHyperbolicTangentxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseHyperbolicTangent()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseHyperbolicTangent()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseHyperbolicTangent</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4RealP5hypotxx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/hypot(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>hypot(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">hypot</span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="kt">Float</span><span class="p">,</span> <span class="n">_</span> <span class="nv">y</span><span class="p">:</span> <span class="kt">Float</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</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>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseTangent</span><span class="p">(</span><span class="n">dividingBy</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">Float</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</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">
|
||||
|
||||
</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">error</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</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">
|
||||
|
||||
</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">complementaryError</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</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">
|
||||
|
||||
</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">gamma</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</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">
|
||||
|
||||
</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">logarithmicGamma</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,390 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>FloatingPoint Extension 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/Extension/FloatingPoint" class="dashAnchor"></a>
|
||||
<a title="FloatingPoint Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>FloatingPoint</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">protocol</span> <span class="kt">FloatingPoint</span> <span class="p">:</span> <span class="kt">SignedNumeric</span><span class="p">,</span> <span class="kt">Strideable</span><span class="p">,</span> <span class="kt">Hashable</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<p><a href="#/Initializers">Initializers</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s13FloatingPointP12NumericAnnexExAC8RationalVySiGcfc">init(_:)</a></li>
|
||||
<li><a href="#/s:s13FloatingPointP12NumericAnnexExAC8RationalVys4Int8VGcfc">init(_:)</a></li>
|
||||
<li><a href="#/s:s13FloatingPointP12NumericAnnexExAC8RationalVys5Int16VGcfc">init(_:)</a></li>
|
||||
<li><a href="#/s:s13FloatingPointP12NumericAnnexExAC8RationalVys5Int32VGcfc">init(_:)</a></li>
|
||||
<li><a href="#/s:s13FloatingPointP12NumericAnnexExAC8RationalVys5Int64VGcfc">init(_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Initializers"></a>
|
||||
<a name="//apple_ref/swift/Section/Initializers" class="dashAnchor"></a>
|
||||
<h3>Initializers</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13FloatingPointP12NumericAnnexExAC8RationalVySiGcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a new floating-point value from the given rational value, after
|
||||
rounding the whole part, the numerator of the fractional part, and the
|
||||
denominator of the fractional part each to the closest possible
|
||||
representation.</p>
|
||||
|
||||
<p>If two representable values are equally close, the result of rounding is
|
||||
the value with more trailing zeros in its significand bit pattern.</p>
|
||||
|
||||
</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="nf">init</span><span class="p">(</span><span class="n">_</span> <span class="nv">source</span><span class="p">:</span> <span class="kt"><a href="../Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">Int</span><span class="o">></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>source</code></dt>
|
||||
<dd>
|
||||
<p>The rational value to convert to a floating-point value.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13FloatingPointP12NumericAnnexExAC8RationalVys4Int8VGcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a new floating-point value from the given rational value, after
|
||||
rounding the whole part, the numerator of the fractional part, and the
|
||||
denominator of the fractional part each to the closest possible
|
||||
representation.</p>
|
||||
|
||||
<p>If two representable values are equally close, the result of rounding is
|
||||
the value with more trailing zeros in its significand bit pattern.</p>
|
||||
|
||||
</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="nf">init</span><span class="p">(</span><span class="n">_</span> <span class="nv">source</span><span class="p">:</span> <span class="kt"><a href="../Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">Int8</span><span class="o">></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>source</code></dt>
|
||||
<dd>
|
||||
<p>The rational value to convert to a floating-point value.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13FloatingPointP12NumericAnnexExAC8RationalVys5Int16VGcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a new floating-point value from the given rational value, after
|
||||
rounding the whole part, the numerator of the fractional part, and the
|
||||
denominator of the fractional part each to the closest possible
|
||||
representation.</p>
|
||||
|
||||
<p>If two representable values are equally close, the result of rounding is
|
||||
the value with more trailing zeros in its significand bit pattern.</p>
|
||||
|
||||
</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="nf">init</span><span class="p">(</span><span class="n">_</span> <span class="nv">source</span><span class="p">:</span> <span class="kt"><a href="../Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">Int16</span><span class="o">></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>source</code></dt>
|
||||
<dd>
|
||||
<p>The rational value to convert to a floating-point value.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13FloatingPointP12NumericAnnexExAC8RationalVys5Int32VGcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a new floating-point value from the given rational value, after
|
||||
rounding the whole part, the numerator of the fractional part, and the
|
||||
denominator of the fractional part each to the closest possible
|
||||
representation.</p>
|
||||
|
||||
<p>If two representable values are equally close, the result of rounding is
|
||||
the value with more trailing zeros in its significand bit pattern.</p>
|
||||
|
||||
</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="nf">init</span><span class="p">(</span><span class="n">_</span> <span class="nv">source</span><span class="p">:</span> <span class="kt"><a href="../Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">Int32</span><span class="o">></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>source</code></dt>
|
||||
<dd>
|
||||
<p>The rational value to convert to a floating-point value.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13FloatingPointP12NumericAnnexExAC8RationalVys5Int64VGcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a new floating-point value from the given rational value, after
|
||||
rounding the whole part, the numerator of the fractional part, and the
|
||||
denominator of the fractional part each to the closest possible
|
||||
representation.</p>
|
||||
|
||||
<p>If two representable values are equally close, the result of rounding is
|
||||
the value with more trailing zeros in its significand bit pattern.</p>
|
||||
|
||||
</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="nf">init</span><span class="p">(</span><span class="n">_</span> <span class="nv">source</span><span class="p">:</span> <span class="kt"><a href="../Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">Int64</span><span class="o">></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>source</code></dt>
|
||||
<dd>
|
||||
<p>The rational value to convert to a floating-point value.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Int Extension 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/Extension/Int" class="dashAnchor"></a>
|
||||
<a title="Int Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Int</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:Si12NumericAnnexE2mmoiS2i_SitFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:Si12NumericAnnexE3mmeoiySiz_SitFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:Si12NumericAnnexE2mmoiS2i_SitFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">Int</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:Si12NumericAnnexE3mmeoiySiz_SitFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Int</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Int16 Extension 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/Extension/Int16" class="dashAnchor"></a>
|
||||
<a title="Int16 Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Int16</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int16</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s5Int16V12NumericAnnexE2mmoiA2B_ABtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s5Int16V12NumericAnnexE3mmeoiyABz_ABtFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int16V12NumericAnnexE2mmoiA2B_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">Int16</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int16</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Int16</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int16V12NumericAnnexE3mmeoiyABz_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Int16</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int16</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Int32 Extension 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/Extension/Int32" class="dashAnchor"></a>
|
||||
<a title="Int32 Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Int32</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int32</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s5Int32V12NumericAnnexE2mmoiA2B_ABtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s5Int32V12NumericAnnexE3mmeoiyABz_ABtFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int32V12NumericAnnexE2mmoiA2B_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">Int32</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int32</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Int32</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int32V12NumericAnnexE3mmeoiyABz_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Int32</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int32</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Int64 Extension 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/Extension/Int64" class="dashAnchor"></a>
|
||||
<a title="Int64 Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Int64</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int64</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s5Int64V12NumericAnnexE2mmoiA2B_ABtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s5Int64V12NumericAnnexE3mmeoiyABz_ABtFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int64V12NumericAnnexE2mmoiA2B_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">Int64</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int64</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Int64</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int64V12NumericAnnexE3mmeoiyABz_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Int64</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int64</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Int8 Extension 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/Extension/Int8" class="dashAnchor"></a>
|
||||
<a title="Int8 Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Int8</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int8</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s4Int8V12NumericAnnexE2mmoiA2B_ABtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s4Int8V12NumericAnnexE3mmeoiyABz_ABtFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s4Int8V12NumericAnnexE2mmoiA2B_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">Int8</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int8</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Int8</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s4Int8V12NumericAnnexE3mmeoiyABz_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Int8</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int8</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>UInt Extension 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/Extension/UInt" class="dashAnchor"></a>
|
||||
<a title="UInt Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>UInt</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:Su12NumericAnnexE2mmoiS2u_SutFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:Su12NumericAnnexE3mmeoiySuz_SutFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:Su12NumericAnnexE2mmoiS2u_SutFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span> <span class="o">-></span> <span class="kt">UInt</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:Su12NumericAnnexE3mmeoiySuz_SutFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">UInt</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>UInt16 Extension 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/Extension/UInt16" class="dashAnchor"></a>
|
||||
<a title="UInt16 Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>UInt16</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt16</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s6UInt16V12NumericAnnexE2mmoiA2B_ABtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s6UInt16V12NumericAnnexE3mmeoiyABz_ABtFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt16V12NumericAnnexE2mmoiA2B_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">UInt16</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt16</span><span class="p">)</span> <span class="o">-></span> <span class="kt">UInt16</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt16V12NumericAnnexE3mmeoiyABz_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">UInt16</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt16</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>UInt32 Extension 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/Extension/UInt32" class="dashAnchor"></a>
|
||||
<a title="UInt32 Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>UInt32</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt32</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s6UInt32V12NumericAnnexE2mmoiA2B_ABtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s6UInt32V12NumericAnnexE3mmeoiyABz_ABtFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt32V12NumericAnnexE2mmoiA2B_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">UInt32</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt32</span><span class="p">)</span> <span class="o">-></span> <span class="kt">UInt32</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt32V12NumericAnnexE3mmeoiyABz_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">UInt32</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt32</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>UInt64 Extension 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/Extension/UInt64" class="dashAnchor"></a>
|
||||
<a title="UInt64 Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>UInt64</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt64</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s6UInt64V12NumericAnnexE2mmoiA2B_ABtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s6UInt64V12NumericAnnexE3mmeoiyABz_ABtFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt64V12NumericAnnexE2mmoiA2B_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">UInt64</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt64</span><span class="p">)</span> <span class="o">-></span> <span class="kt">UInt64</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt64V12NumericAnnexE3mmeoiyABz_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">UInt64</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt64</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>UInt8 Extension 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/Extension/UInt8" class="dashAnchor"></a>
|
||||
<a title="UInt8 Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>UInt8</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt8</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s5UInt8V12NumericAnnexE2mmoiA2B_ABtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s5UInt8V12NumericAnnexE3mmeoiyABz_ABtFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5UInt8V12NumericAnnexE2mmoiA2B_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">UInt8</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt8</span><span class="p">)</span> <span class="o">-></span> <span class="kt">UInt8</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5UInt8V12NumericAnnexE3mmeoiyABz_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">UInt8</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt8</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,343 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>UnsignedInteger Extension 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/Extension/UnsignedInteger" class="dashAnchor"></a>
|
||||
<a title="UnsignedInteger Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>UnsignedInteger</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">protocol</span> <span class="kt">UnsignedInteger</span> <span class="p">:</span> <span class="kt">BinaryInteger</span> <span class="k">where</span> <span class="k">Self</span><span class="o">.</span><span class="kt">Magnitude</span> <span class="p">:</span> <span class="kt">BinaryInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<p><a href="#/Cube%20Root">Cube Root</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s15UnsignedIntegerP12NumericAnnexE4cbrtxxFZ">cbrt(_:)</a></li>
|
||||
</ul>
|
||||
<p><a href="#/Factoring">Factoring</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s15UnsignedIntegerP12NumericAnnexE3gcdxx_xtFZ">gcd(_:_:)</a></li>
|
||||
<li><a href="#/s:s15UnsignedIntegerP12NumericAnnexE3lcmxx_xtFZ">lcm(_:_:)</a></li>
|
||||
</ul>
|
||||
<p><a href="#/Factoring%20(Fixed-Width)">Factoring (Fixed-Width)</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s15UnsignedIntegerP12NumericAnnexs010FixedWidthB0RzsAARzlE20lcmReportingOverflowx12partialValue_Sb8overflowtx_xtFZ">lcmReportingOverflow(_:_:)</a></li>
|
||||
<li><a href="#/s:s15UnsignedIntegerP12NumericAnnexs010FixedWidthB0RzsAARzlE07lcmFullF0x4high_9Magnitudes0C0PQz3lowtx_xtFZ">lcmFullWidth(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Cube%20Root"></a>
|
||||
<a name="//apple_ref/swift/Section/Cube Root" class="dashAnchor"></a>
|
||||
<h3>Cube Root</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s15UnsignedIntegerP12NumericAnnexE4cbrtxxFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/cbrt(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>cbrt(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the cube root of <code>x</code>, rounding toward zero.</p>
|
||||
|
||||
</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">cbrt</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">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Factoring"></a>
|
||||
<a name="//apple_ref/swift/Section/Factoring" class="dashAnchor"></a>
|
||||
<h3>Factoring</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s15UnsignedIntegerP12NumericAnnexE3gcdxx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/gcd(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>gcd(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the greatest common divisor of <code>a</code> and <code>b</code>.</p>
|
||||
|
||||
</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">gcd</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s15UnsignedIntegerP12NumericAnnexE3lcmxx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/lcm(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>lcm(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the least common multiple of <code>a</code> and <code>b</code>.</p>
|
||||
|
||||
</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">lcm</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Factoring%20(Fixed-Width)"></a>
|
||||
<a name="//apple_ref/swift/Section/Factoring (Fixed-Width)" class="dashAnchor"></a>
|
||||
<h3>Factoring (Fixed-Width)</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s15UnsignedIntegerP12NumericAnnexs010FixedWidthB0RzsAARzlE20lcmReportingOverflowx12partialValue_Sb8overflowtx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/lcmReportingOverflow(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>lcmReportingOverflow(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the least common multiple of <code>a</code> and <code>b</code> and a flag to indicate
|
||||
whether overflow occurred during the operation.</p>
|
||||
|
||||
</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">lcmReportingOverflow</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span>
|
||||
<span class="o">-></span> <span class="p">(</span><span class="nv">partialValue</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="nv">overflow</span><span class="p">:</span> <span class="kt">Bool</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s15UnsignedIntegerP12NumericAnnexs010FixedWidthB0RzsAARzlE07lcmFullF0x4high_9Magnitudes0C0PQz3lowtx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/lcmFullWidth(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>lcmFullWidth(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the high and low parts of the least common multiple of <code>a</code> and <code>b</code>
|
||||
computed using full-width arithmetic.</p>
|
||||
|
||||
</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">lcmFullWidth</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span>
|
||||
<span class="o">-></span> <span class="p">(</span><span class="nv">high</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="nv">low</span><span class="p">:</span> <span class="k">Self</span><span class="o">.</span><span class="kt">Magnitude</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,355 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Functions 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 title="Functions 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Functions</h1>
|
||||
<p>The following functions are available globally.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex3absAA7ComplexVyxGAeA4RealRzs9DecodableRzs9EncodableRzs33_ExpressibleByBuiltinFloatLiteralRzlF">abs(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4sqrtAA7ComplexVyxGAeA4RealRzs9DecodableRzs9EncodableRzs33_ExpressibleByBuiltinFloatLiteralRzlF">sqrt(_:)</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex3absAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF">abs(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4ceilAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF">ceil(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex5floorAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF">floor(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex5roundAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF">round(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex5truncAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF">trunc(_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex3absAA7ComplexVyxGAeA4RealRzs9DecodableRzs9EncodableRzs33_ExpressibleByBuiltinFloatLiteralRzlF"></a>
|
||||
<a name="//apple_ref/swift/Function/abs(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>abs(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the absolute value (magnitude, modulus) of <code>z</code>.</p>
|
||||
|
||||
</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="n">abs</span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">(</span><span class="n">_</span> <span class="nv">z</span><span class="p">:</span> <span class="kt"><a href="Structs/Complex.html">Complex</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="Structs/Complex.html">Complex</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4sqrtAA7ComplexVyxGAeA4RealRzs9DecodableRzs9EncodableRzs33_ExpressibleByBuiltinFloatLiteralRzlF"></a>
|
||||
<a name="//apple_ref/swift/Function/sqrt(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>sqrt(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the square root of <code>z</code>.</p>
|
||||
|
||||
</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="n">sqrt</span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">(</span><span class="n">_</span> <span class="nv">z</span><span class="p">:</span> <span class="kt"><a href="Structs/Complex.html">Complex</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="Structs/Complex.html">Complex</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex3absAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF"></a>
|
||||
<a name="//apple_ref/swift/Function/abs(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>abs(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the absolute value (magnitude) of <code>x</code>.</p>
|
||||
|
||||
</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="n">abs</span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4ceilAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF"></a>
|
||||
<a name="//apple_ref/swift/Function/ceil(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>ceil(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the closest integral value greater than or equal to <code>x</code>.</p>
|
||||
|
||||
</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="n">ceil</span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex5floorAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF"></a>
|
||||
<a name="//apple_ref/swift/Function/floor(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>floor(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the closest integral value less than or equal to <code>x</code>.</p>
|
||||
|
||||
</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="n">floor</span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex5roundAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF"></a>
|
||||
<a name="//apple_ref/swift/Function/round(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>round(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the closest integral value; if two values are equally close, returns
|
||||
the one with greater magnitude.</p>
|
||||
|
||||
</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="n">round</span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex5truncAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF"></a>
|
||||
<a name="//apple_ref/swift/Function/trunc(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>trunc(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the closest integral value with magnitude less than or equal to that
|
||||
of <code>x</code>.</p>
|
||||
|
||||
</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="n">trunc</span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
19
LICENSE
19
LICENSE
|
@ -1,19 +0,0 @@
|
|||
Copyright © 2017 Xiaodi Wu (https://github.com/xwu).
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -1,7 +0,0 @@
|
|||
// swift-tools-version:3.1
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "NumericAnnex"
|
||||
)
|
|
@ -0,0 +1,319 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Protocols 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 title="Protocols 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Protocols</h1>
|
||||
<p>The following protocols are available globally.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGP">PRNG</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4RealP">Real</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4MathP">Math</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGP"></a>
|
||||
<a name="//apple_ref/swift/Protocol/PRNG" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>PRNG</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>A pseudo-random number generator (PRNG).</p>
|
||||
|
||||
<p>Reference types that conform to <code>PRNG</code> are infinite sequences of
|
||||
pseudo-random elements. Protocol extension methods iterate over such a
|
||||
sequence as necessary to generate pseudo-random values from the desired
|
||||
distribution.</p>
|
||||
<h2 id='considerations-for-conforming-types' class='heading'>Considerations for Conforming Types</h2>
|
||||
|
||||
<p>For clarity to end users, custom PRNGs may be implemented in an extension to
|
||||
<code><a href="Classes/Random.html">Random</a></code>. For instance, the <code>xoroshiro128+</code> algorithm is implemented in a
|
||||
final class named <code><a href="Classes/Random/Xoroshiro.html">Random.Xoroshiro</a></code>.</p>
|
||||
|
||||
<p>The static methods <code>_entropy(_:)</code> and <code>_entropy(_:count:)</code> return
|
||||
cryptographically secure random bytes that may be useful for seeding your
|
||||
custom PRNG. However, these methods may return <code>nil</code> if the requested number
|
||||
of random bytes is not available, and they are not recommended as a routine
|
||||
source of random data.</p>
|
||||
<h2 id='adding-other-probability-distributions' class='heading'>Adding Other Probability Distributions</h2>
|
||||
|
||||
<p>Many built-in protocol extension methods make use of the primitive,
|
||||
overloaded method <code>_random(_:bitCount:)</code>. You may wish to use the same
|
||||
method in new protocol extension methods that return pseudo-random
|
||||
values from other probability distributions.</p>
|
||||
|
||||
<p>The method <code>_random(_:bitCount:)</code> generates uniformly distributed binary
|
||||
floating-point values in the half-open range [0, 1) with a precision of
|
||||
either <code>bitCount</code> or the significand bit count of the floating-point type,
|
||||
whichever is less. Additionally, this method generates uniformly distributed
|
||||
unsigned integers in the half-open range [0, 2 ** <em>x</em>), where ** is the
|
||||
exponentiation operator and <em>x</em> is the lesser of <code>bitCount</code> and the bit
|
||||
width of the integer type.</p>
|
||||
|
||||
<p>For end users, however, the recommended spelling for a uniformly distributed
|
||||
numeric value is <code>uniform()</code>; that method is overloaded to permit custom
|
||||
minimum and maximum values for the uniform distribution.</p>
|
||||
|
||||
<a href="Protocols/PRNG.html">See more…</a>
|
||||
</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">protocol</span> <span class="kt">PRNG</span> <span class="p">:</span> <span class="kd">class</span><span class="p">,</span> <span class="kt">IteratorProtocol</span><span class="p">,</span> <span class="kt">Sequence</span>
|
||||
<span class="k">where</span> <span class="kt">Element</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span><span class="p">,</span>
|
||||
<span class="kt">SubSequence</span> <span class="p">:</span> <span class="kt">Sequence</span><span class="p">,</span>
|
||||
<span class="kt">Element</span> <span class="o">==</span> <span class="kt">SubSequence</span><span class="o">.</span><span class="kt">Element</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4RealP"></a>
|
||||
<a name="//apple_ref/swift/Protocol/Real" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Real</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<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>
|
||||
|
||||
<a href="Protocols/Real.html">See more…</a>
|
||||
</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">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>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP"></a>
|
||||
<a name="//apple_ref/swift/Protocol/Math" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Math</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>A signed numeric type that supports elementary functions.</p>
|
||||
|
||||
<p>The <code>Math</code> protocol provides a suitable basis for writing functions that
|
||||
work on any real or complex floating-point type that supports the required
|
||||
functions.</p>
|
||||
|
||||
<a href="Protocols/Math.html">See more…</a>
|
||||
</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">protocol</span> <span class="kt">Math</span> <span class="p">:</span> <span class="kt">SignedNumeric</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,857 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>PRNG 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/PRNG" class="dashAnchor"></a>
|
||||
<a title="PRNG 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>PRNG</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">PRNG</span> <span class="p">:</span> <span class="kd">class</span><span class="p">,</span> <span class="kt">IteratorProtocol</span><span class="p">,</span> <span class="kt">Sequence</span>
|
||||
<span class="k">where</span> <span class="kt">Element</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span><span class="p">,</span>
|
||||
<span class="kt">SubSequence</span> <span class="p">:</span> <span class="kt">Sequence</span><span class="p">,</span>
|
||||
<span class="kt">Element</span> <span class="o">==</span> <span class="kt">SubSequence</span><span class="o">.</span><span class="kt">Element</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>A pseudo-random number generator (PRNG).</p>
|
||||
|
||||
<p>Reference types that conform to <code>PRNG</code> are infinite sequences of
|
||||
pseudo-random elements. Protocol extension methods iterate over such a
|
||||
sequence as necessary to generate pseudo-random values from the desired
|
||||
distribution.</p>
|
||||
<h2 id='considerations-for-conforming-types' class='heading'>Considerations for Conforming Types</h2>
|
||||
|
||||
<p>For clarity to end users, custom PRNGs may be implemented in an extension to
|
||||
<code><a href="../Classes/Random.html">Random</a></code>. For instance, the <code>xoroshiro128+</code> algorithm is implemented in a
|
||||
final class named <code><a href="../Classes/Random/Xoroshiro.html">Random.Xoroshiro</a></code>.</p>
|
||||
|
||||
<p>The static methods <code>_entropy(_:)</code> and <code>_entropy(_:count:)</code> return
|
||||
cryptographically secure random bytes that may be useful for seeding your
|
||||
custom PRNG. However, these methods may return <code>nil</code> if the requested number
|
||||
of random bytes is not available, and they are not recommended as a routine
|
||||
source of random data.</p>
|
||||
<h2 id='adding-other-probability-distributions' class='heading'>Adding Other Probability Distributions</h2>
|
||||
|
||||
<p>Many built-in protocol extension methods make use of the primitive,
|
||||
overloaded method <code>_random(_:bitCount:)</code>. You may wish to use the same
|
||||
method in new protocol extension methods that return pseudo-random
|
||||
values from other probability distributions.</p>
|
||||
|
||||
<p>The method <code>_random(_:bitCount:)</code> generates uniformly distributed binary
|
||||
floating-point values in the half-open range [0, 1) with a precision of
|
||||
either <code>bitCount</code> or the significand bit count of the floating-point type,
|
||||
whichever is less. Additionally, this method generates uniformly distributed
|
||||
unsigned integers in the half-open range [0, 2 ** <em>x</em>), where ** is the
|
||||
exponentiation operator and <em>x</em> is the lesser of <code>bitCount</code> and the bit
|
||||
width of the integer type.</p>
|
||||
|
||||
<p>For end users, however, the recommended spelling for a uniformly distributed
|
||||
numeric value is <code>uniform()</code>; that method is overloaded to permit custom
|
||||
minimum and maximum values for the uniform distribution.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGP5State">State</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGP5state5StateQzv">state</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPx5StateQz5state_tcfc">init(state:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPxSgycfc">init()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGP3max7ElementQzvZ">max</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGP3min7ElementQzvZ">min</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE15_randomBitWidthSivZ">_randomBitWidth</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE8_entropyqd__Sgqd__ms17FixedWidthIntegerRd__s08UnsignedG0Rd__lFZ">_entropy(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE8_entropySayqd__GSgqd__m_Si5countts17FixedWidthIntegerRd__s08UnsignedH0Rd__lFZ">_entropy(_:count:)</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7_randomqd__qd__m_Si8bitCountts17FixedWidthIntegerRd__s08UnsignedI0Rd__lF">_random(_:bitCount:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7uniformqd__qd__m_qd__1aqd__1bts17FixedWidthIntegerRd__s08UnsignedG0Rd__lF">uniform(_:a:b:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7uniformqd__qd__ms17FixedWidthIntegerRd__s08UnsignedG0Rd__lF">uniform(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7uniforms14UnfoldSequenceVyqd__SiGqd__m_qd__1aqd__1bSi5countts17FixedWidthIntegerRd__s08UnsignedJ0Rd__lF">uniform(_:a:b:count:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7uniforms14UnfoldSequenceVyqd__SiGqd__m_Si5countts17FixedWidthIntegerRd__s08UnsignedJ0Rd__lF">uniform(_:count:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7uniformqd__qd__m_qd__1aqd__1bts17FixedWidthIntegerRd__s06SignedG0Rd__sAG9Magnitudes0A0PRpd__s08UnsignedG0ALRQlF">uniform(_:a:b:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7uniformqd__qd__ms17FixedWidthIntegerRd__s06SignedG0Rd__sAE9Magnitudes0A0PRpd__s08UnsignedG0AJRQlF">uniform(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7uniforms14UnfoldSequenceVyqd__SiGqd__m_qd__1aqd__1bSi5countts17FixedWidthIntegerRd__s06SignedJ0Rd__sAK9Magnitudes0A0PRpd__s08UnsignedJ0APRQlF">uniform(_:a:b:count:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7uniforms14UnfoldSequenceVyqd__SiGqd__m_Si5countts17FixedWidthIntegerRd__s06SignedJ0Rd__sAI9Magnitudes0A0PRpd__s08UnsignedJ0ANRQlF">uniform(_:count:)</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7_randomqd__qd__m_Si8bitCountts19BinaryFloatingPointRd__lF">_random(_:bitCount:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7uniformqd__qd__m_qd__1aqd__1bts19BinaryFloatingPointRd__lF">uniform(_:a:b:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7uniformqd__qd__ms19BinaryFloatingPointRd__lF">uniform(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7uniforms14UnfoldSequenceVyqd__SiGqd__m_qd__1aqd__1bSi5countts19BinaryFloatingPointRd__lF">uniform(_:a:b:count:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7uniforms14UnfoldSequenceVyqd__SiGqd__m_Si5countts19BinaryFloatingPointRd__lF">uniform(_:count:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGP5State"></a>
|
||||
<a name="//apple_ref/swift/Alias/State" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>State</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>A type that can represent the internal state of the pseudo-random number
|
||||
generator.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">associatedtype</span> <span class="kt">State</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGP5state5StateQzv"></a>
|
||||
<a name="//apple_ref/swift/Property/state" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>state</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>The internal state of the pseudo-random number generator.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">var</span> <span class="nv">state</span><span class="p">:</span> <span class="kt"><a href="../Protocols/PRNG.html#/s:12NumericAnnex4PRNGP5State">State</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPx5StateQz5state_tcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(state:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(state:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a pseudo-random number generator with the given internal state.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="nf">init</span><span class="p">(</span><span class="nv">state</span><span class="p">:</span> <span class="kt"><a href="../Protocols/PRNG.html#/s:12NumericAnnex4PRNGP5State">State</a></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>state</code></dt>
|
||||
<dd>
|
||||
<p>The value to be used as the generator’s internal state.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPxSgycfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a pseudo-random number generator with an internal state seeded
|
||||
using cryptographically secure random bytes.</p>
|
||||
|
||||
<p>If cryptographically secure random bytes are unavailable, the result is
|
||||
<code>nil</code>.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="nf">init</span><span class="p">?()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGP3max7ElementQzvZ"></a>
|
||||
<a name="//apple_ref/swift/Variable/max" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>max</code>
|
||||
<span class="declaration-note">Default implementation</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>The maximum value that may be generated by the pseudo-random number
|
||||
generator.</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="k">var</span> <span class="nv">max</span><span class="p">:</span> <span class="kt">Element</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGP3min7ElementQzvZ"></a>
|
||||
<a name="//apple_ref/swift/Variable/min" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>min</code>
|
||||
<span class="declaration-note">Default implementation</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>The minimum value that may be generated by the pseudo-random number
|
||||
generator.</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="k">var</span> <span class="nv">min</span><span class="p">:</span> <span class="kt">Element</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE15_randomBitWidthSivZ"></a>
|
||||
<a name="//apple_ref/swift/Variable/_randomBitWidth" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>_randomBitWidth</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>The number of pseudo-random bits available from a value generated by the
|
||||
pseudo-random number generator.</p>
|
||||
|
||||
</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="k">var</span> <span class="nv">_randomBitWidth</span><span class="p">:</span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE8_entropyqd__Sgqd__ms17FixedWidthIntegerRd__s08UnsignedG0Rd__lFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/_entropy(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>_entropy(_:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns a value filled with data from a source of cryptographically secure
|
||||
random bytes, or <code>nil</code> if a sufficient number of cryptographically secure
|
||||
random bytes is unavailable.</p>
|
||||
|
||||
</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="n">_entropy</span><span class="o"><</span>
|
||||
<span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span>
|
||||
<span class="o">></span><span class="p">(</span><span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">)</span> <span class="o">-></span> <span class="kt">T</span><span class="p">?</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE8_entropySayqd__GSgqd__m_Si5countts17FixedWidthIntegerRd__s08UnsignedH0Rd__lFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/_entropy(_:count:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>_entropy(_:count:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns an array of <code>count</code> values filled with data from a source of
|
||||
cryptographically secure random bytes, or <code>nil</code> if a sufficient number of
|
||||
cryptographically secure random bytes is unavailable.</p>
|
||||
|
||||
</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="n">_entropy</span><span class="o"><</span>
|
||||
<span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span>
|
||||
<span class="o">></span><span class="p">(</span><span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">count</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-></span> <span class="p">[</span><span class="kt">T</span><span class="p">]?</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7_randomqd__qd__m_Si8bitCountts17FixedWidthIntegerRd__s08UnsignedI0Rd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/_random(_:bitCount:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>_random(_:bitCount:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a pseudo-random unsigned integer of type <code>T</code> in the range from 0
|
||||
to <code>2 ** min(bitCount, T.bitWidth)</code> (exclusive), where <code>**</code> is the
|
||||
exponentiation operator.</p>
|
||||
|
||||
</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="n">_random</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">bitCount</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="n">bitWidth</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">T</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7uniformqd__qd__m_qd__1aqd__1bts17FixedWidthIntegerRd__s08UnsignedG0Rd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:a:b:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:a:b:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a pseudo-random unsigned integer of type <code>T</code> in the range from
|
||||
<code>a</code> through <code>b</code> (inclusive) from the discrete uniform distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">a</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="kt">T</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">T</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7uniformqd__qd__ms17FixedWidthIntegerRd__s08UnsignedG0Rd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a pseudo-random unsigned integer of type <code>T</code> in the range from
|
||||
<code>T.min</code> through <code>T.max</code> (inclusive) from the discrete uniform
|
||||
distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">T</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7uniforms14UnfoldSequenceVyqd__SiGqd__m_qd__1aqd__1bSi5countts17FixedWidthIntegerRd__s08UnsignedJ0Rd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:a:b:count:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:a:b:count:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a sequence of <code>count</code> pseudo-random unsigned integers of type
|
||||
<code>T</code> in the range from <code>a</code> through <code>b</code> (inclusive) from the discrete
|
||||
uniform distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">a</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">count</span><span class="p">:</span> <span class="kt">Int</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">UnfoldSequence</span><span class="o"><</span><span class="kt">T</span><span class="p">,</span> <span class="kt">Int</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7uniforms14UnfoldSequenceVyqd__SiGqd__m_Si5countts17FixedWidthIntegerRd__s08UnsignedJ0Rd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:count:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:count:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a sequence of <code>count</code> pseudo-random unsigned integers of type
|
||||
<code>T</code> in the range from <code>T.min</code> through <code>T.max</code> (inclusive) from the
|
||||
discrete uniform distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">count</span><span class="p">:</span> <span class="kt">Int</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">UnfoldSequence</span><span class="o"><</span><span class="kt">T</span><span class="p">,</span> <span class="kt">Int</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7uniformqd__qd__m_qd__1aqd__1bts17FixedWidthIntegerRd__s06SignedG0Rd__sAG9Magnitudes0A0PRpd__s08UnsignedG0ALRQlF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:a:b:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:a:b:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a pseudo-random signed integer of type <code>T</code> in the range from <code>a</code>
|
||||
through <code>b</code> (inclusive) from the discrete uniform distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">SignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">a</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="kt">T</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">T</span> <span class="k">where</span> <span class="kt">T</span><span class="o">.</span><span class="kt">Magnitude</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7uniformqd__qd__ms17FixedWidthIntegerRd__s06SignedG0Rd__sAE9Magnitudes0A0PRpd__s08UnsignedG0AJRQlF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a pseudo-random signed integer of type <code>T</code> in the range from
|
||||
<code>T.min</code> through <code>T.max</code> (inclusive) from the discrete uniform
|
||||
distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">SignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">T</span> <span class="k">where</span> <span class="kt">T</span><span class="o">.</span><span class="kt">Magnitude</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7uniforms14UnfoldSequenceVyqd__SiGqd__m_qd__1aqd__1bSi5countts17FixedWidthIntegerRd__s06SignedJ0Rd__sAK9Magnitudes0A0PRpd__s08UnsignedJ0APRQlF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:a:b:count:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:a:b:count:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a sequence of <code>count</code> pseudo-random signed integers of type <code>T</code>
|
||||
in the range from <code>a</code> through <code>b</code> (inclusive) from the discrete uniform
|
||||
distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">SignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">a</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">count</span><span class="p">:</span> <span class="kt">Int</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">UnfoldSequence</span><span class="o"><</span><span class="kt">T</span><span class="p">,</span> <span class="kt">Int</span><span class="o">></span>
|
||||
<span class="k">where</span> <span class="kt">T</span><span class="o">.</span><span class="kt">Magnitude</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7uniforms14UnfoldSequenceVyqd__SiGqd__m_Si5countts17FixedWidthIntegerRd__s06SignedJ0Rd__sAI9Magnitudes0A0PRpd__s08UnsignedJ0ANRQlF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:count:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:count:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a sequence of <code>count</code> pseudo-random signed integers of type <code>T</code>
|
||||
in the range from <code>T.min</code> through <code>T.max</code> (inclusive) from the discrete
|
||||
uniform distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">SignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">count</span><span class="p">:</span> <span class="kt">Int</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">UnfoldSequence</span><span class="o"><</span><span class="kt">T</span><span class="p">,</span> <span class="kt">Int</span><span class="o">></span>
|
||||
<span class="k">where</span> <span class="kt">T</span><span class="o">.</span><span class="kt">Magnitude</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7_randomqd__qd__m_Si8bitCountts19BinaryFloatingPointRd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/_random(_:bitCount:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>_random(_:bitCount:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a pseudo-random binary floating-point value of type <code>T</code> in the
|
||||
range from 0 to 1 (exclusive) with <code>min(bitCount, T.significandBitCount)</code>
|
||||
bits of precision.</p>
|
||||
|
||||
</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="n">_random</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">BinaryFloatingPoint</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">bitCount</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="n">significandBitCount</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">T</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7uniformqd__qd__m_qd__1aqd__1bts19BinaryFloatingPointRd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:a:b:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:a:b:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a pseudo-random binary floating-point value of type <code>T</code> in the
|
||||
range from <code>a</code> to <code>b</code> (exclusive) from the uniform distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">BinaryFloatingPoint</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">a</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="kt">T</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">T</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7uniformqd__qd__ms19BinaryFloatingPointRd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a pseudo-random binary floating-point value of type <code>T</code> in the
|
||||
range from 0 to 1 (exclusive) from the uniform distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">BinaryFloatingPoint</span><span class="o">></span><span class="p">(</span><span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">)</span> <span class="o">-></span> <span class="kt">T</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7uniforms14UnfoldSequenceVyqd__SiGqd__m_qd__1aqd__1bSi5countts19BinaryFloatingPointRd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:a:b:count:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:a:b:count:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a sequence of <code>count</code> pseudo-random binary floating-point values
|
||||
of type <code>T</code> in the range from <code>a</code> to <code>b</code> (exclusive) from the uniform
|
||||
distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">BinaryFloatingPoint</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">a</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">count</span><span class="p">:</span> <span class="kt">Int</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">UnfoldSequence</span><span class="o"><</span><span class="kt">T</span><span class="p">,</span> <span class="kt">Int</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7uniforms14UnfoldSequenceVyqd__SiGqd__m_Si5countts19BinaryFloatingPointRd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:count:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:count:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a sequence of <code>count</code> pseudo-random binary floating-point values
|
||||
of type <code>T</code> in the range from 0 to 1 (exclusive) from the uniform
|
||||
distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">BinaryFloatingPoint</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">count</span><span class="p">:</span> <span class="kt">Int</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">UnfoldSequence</span><span class="o"><</span><span class="kt">T</span><span class="p">,</span> <span class="kt">Int</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,594 @@
|
|||
<!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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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">-></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 && 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">-></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">-></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">-></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">-></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">-></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">-></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 && 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">-></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">-></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">-></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">-></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">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
108
README.md
108
README.md
|
@ -1,108 +0,0 @@
|
|||
# NumericAnnex
|
||||
|
||||
NumericAnnex supplements the numeric facilities provided in the Swift standard
|
||||
library.
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- [x] `BinaryInteger` exponentiation, greatest common divisor, and least common
|
||||
multiple functions.
|
||||
- [x] `Math`, a protocol for types providing square root, cube root, and
|
||||
elementary transcendental functions.
|
||||
- [x] `FloatingPointMath`, a protocol for floating-point types providing certain
|
||||
special functions.
|
||||
- [x] `PRNG`, a protocol for pseudo-random number generators (PRNGs).
|
||||
- [x] `Complex`, a value type to represent complex values in Cartesian form.
|
||||
- [x] `Rational`, a value type to represent rational values, which supports
|
||||
division by zero.
|
||||
- [x] `Random` and `Random.Xoroshiro`, two reference types implementing
|
||||
efficient non-cryptographically-secure PRNGs.
|
||||
|
||||
> Note: This project is in the early stages of development and is not
|
||||
> production-ready at this time.
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
NumericAnnex now requires a recent development snapshot of Swift 4.0 that
|
||||
includes the revised numeric protocols. It requires either `Darwin.C` or `Glibc`
|
||||
for transcendental functions provided by the C standard library and either
|
||||
`Security` (Apple platforms) or `Glibc` (Linux) for cryptographically secure
|
||||
random bytes.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
After NumericAnnex has been cloned or downloaded locally, build the library by
|
||||
invoking `swift build`, or run tests with `swift test`. An Xcode project can be
|
||||
generated by invoking `swift package generate-xcodeproj`.
|
||||
|
||||
[Swift Package Manager](https://swift.org/package-manager/) can also be used to
|
||||
add the package as a dependency for your own project. See Swift documentation
|
||||
for details.
|
||||
|
||||
|
||||
## Basic Usage
|
||||
|
||||
```swift
|
||||
import NumericAnnex
|
||||
|
||||
var x: Ratio = 1 / 4
|
||||
// Ratio is a type alias for Rational<Int>.
|
||||
|
||||
print(x.reciprocal())
|
||||
// Prints "4".
|
||||
|
||||
x *= 8
|
||||
print(x + x)
|
||||
// Prints "4".
|
||||
|
||||
x = Ratio(Float.phi) // Golden ratio.
|
||||
print(x)
|
||||
// Prints "13573053/8388608".
|
||||
|
||||
var z: Complex64 = 42 * .i
|
||||
// Complex64 is a type alias for Complex<Float>.
|
||||
|
||||
print(Complex.sqrt(z))
|
||||
// Prints "4.58258 + 4.58258i".
|
||||
|
||||
z = .pi + .i * .log(2 - .sqrt(3))
|
||||
print(Complex.cos(z).real)
|
||||
// Prints "-2.0".
|
||||
```
|
||||
|
||||
|
||||
## Documentation
|
||||
|
||||
All public protocols, types, and functions have been carefully documented in
|
||||
comments.
|
||||
|
||||
The project adheres to many design patterns found in the Swift standard library.
|
||||
For example, `Math` types provide methods such as `cubeRoot()` and `tangent()`
|
||||
just as `FloatingPoint` types provide methods such as `squareRoot()`.
|
||||
|
||||
No free functions are declared in this library unless they overload existing
|
||||
ones in the Swift standard library. Instead, functions such as `cbrt(_:)` and
|
||||
`tan(_:)` are provided as static members. This avoids collisions with C standard
|
||||
library functions that you may wish to use. It also promotes clarity at the call
|
||||
site when the result of a complex operation differs from that of its real
|
||||
counterpart (e.g., `Complex128.cbrt(-8) != -2`).
|
||||
|
||||
|
||||
## Future Directions
|
||||
|
||||
- [ ] Add more tests, including performance tests
|
||||
- [ ] Design and implement additional methods on `PRNG`
|
||||
- [ ] Design and implement `BigInt`
|
||||
|
||||
|
||||
## License
|
||||
|
||||
All original work is released under the MIT license. See
|
||||
[LICENSE](https://github.com/xwu/NumericAnnex/blob/master/LICENSE) for details.
|
||||
|
||||
Portions of the complex square root and elementary transcendental functions use
|
||||
checks for special values adapted from libc++. Code in libc++ is dual-licensed
|
||||
under the MIT and UIUC/NCSA licenses.
|
|
@ -1,484 +0,0 @@
|
|||
//
|
||||
// Complex+Math.swift
|
||||
// NumericAnnex
|
||||
//
|
||||
// Created by Xiaodi Wu on 4/2/17.
|
||||
//
|
||||
// Note
|
||||
// ====
|
||||
//
|
||||
// For maximum consistency with corresponding functions in C/C++, checks for
|
||||
// special values in `naturalExponential()`, `squareRoot()`, trigonometric
|
||||
// functions, and hyperbolic functions are adapted from libc++.
|
||||
//
|
||||
// Code in libc++ is dual-licensed under the MIT and UIUC/NCSA licenses.
|
||||
// Copyright © 2009-2017 contributors to the LLVM/libc++ project.
|
||||
|
||||
extension Complex : Numeric {
|
||||
@_transparent // @_inlineable
|
||||
public init?<U>(exactly source: U) where U : BinaryInteger {
|
||||
guard let t = T(exactly: source) else { return nil }
|
||||
self.real = t
|
||||
self.imaginary = 0
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public static func + (lhs: Complex, rhs: Complex) -> Complex {
|
||||
return Complex(
|
||||
real: lhs.real + rhs.real, imaginary: lhs.imaginary + rhs.imaginary
|
||||
)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public static func += (lhs: inout Complex, rhs: Complex) {
|
||||
lhs.real += rhs.real
|
||||
lhs.imaginary += rhs.imaginary
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public static func - (lhs: Complex, rhs: Complex) -> Complex {
|
||||
return Complex(
|
||||
real: lhs.real - rhs.real, imaginary: lhs.imaginary - rhs.imaginary
|
||||
)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public static func -= (lhs: inout Complex, rhs: Complex) {
|
||||
lhs.real -= rhs.real
|
||||
lhs.imaginary -= rhs.imaginary
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public static func * (lhs: Complex, rhs: Complex) -> Complex {
|
||||
return Complex(
|
||||
real: lhs.real * rhs.real - lhs.imaginary * rhs.imaginary,
|
||||
imaginary: lhs.real * rhs.imaginary + lhs.imaginary * rhs.real
|
||||
)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public static func *= (lhs: inout Complex, rhs: Complex) {
|
||||
let t = lhs.real
|
||||
lhs.real = lhs.real * rhs.real - lhs.imaginary * rhs.imaginary
|
||||
lhs.imaginary = t * rhs.imaginary + lhs.imaginary * rhs.real
|
||||
}
|
||||
}
|
||||
|
||||
extension Complex : SignedNumeric {
|
||||
@_transparent // @_inlineable
|
||||
public static prefix func - (operand: Complex) -> Complex {
|
||||
return Complex(real: -operand.real, imaginary: -operand.imaginary)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public mutating func negate() {
|
||||
real.negate()
|
||||
imaginary.negate()
|
||||
}
|
||||
}
|
||||
|
||||
extension Complex : Math {
|
||||
@_transparent // @_inlineable
|
||||
public static var pi: Complex {
|
||||
return Complex(real: .pi)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public static var e: Complex {
|
||||
return Complex(real: .e)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public static var phi: Complex {
|
||||
return Complex(real: .phi)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public static func / (lhs: Complex, rhs: Complex) -> Complex {
|
||||
// Prevent avoidable overflow; see Numerical Recipes.
|
||||
if rhs.real.magnitude >= rhs.imaginary.magnitude {
|
||||
let ratio = rhs.imaginary / rhs.real
|
||||
let denominator = rhs.real + rhs.imaginary * ratio
|
||||
return Complex(
|
||||
real: (lhs.real + lhs.imaginary * ratio) / denominator,
|
||||
imaginary: (lhs.imaginary - lhs.real * ratio) / denominator
|
||||
)
|
||||
}
|
||||
let ratio = rhs.real / rhs.imaginary
|
||||
let denominator = rhs.real * ratio + rhs.imaginary
|
||||
return Complex(
|
||||
real: (lhs.real * ratio + lhs.imaginary) / denominator,
|
||||
imaginary: (lhs.imaginary * ratio - lhs.real) / denominator
|
||||
)
|
||||
|
||||
/*
|
||||
let denominator = rhs.squaredMagnitude
|
||||
return Complex(
|
||||
real:
|
||||
(lhs.real * rhs.real + lhs.imaginary * rhs.imaginary) / denominator,
|
||||
imaginary:
|
||||
(lhs.imaginary * rhs.real - lhs.real * rhs.imaginary) / denominator
|
||||
)
|
||||
*/
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public static func /= (lhs: inout Complex, rhs: Complex) {
|
||||
// Prevent avoidable overflow; see Numerical Recipes.
|
||||
let t = lhs.real
|
||||
if rhs.real.magnitude >= rhs.imaginary.magnitude {
|
||||
let ratio = rhs.imaginary / rhs.real
|
||||
let denominator = rhs.real + rhs.imaginary * ratio
|
||||
lhs.real = (lhs.real + lhs.imaginary * ratio) / denominator
|
||||
lhs.imaginary = (lhs.imaginary - t * ratio) / denominator
|
||||
} else {
|
||||
let ratio = rhs.real / rhs.imaginary
|
||||
let denominator = rhs.real * ratio + rhs.imaginary
|
||||
lhs.real = (lhs.real * ratio + lhs.imaginary) / denominator
|
||||
lhs.imaginary = (lhs.imaginary * ratio - t) / denominator
|
||||
}
|
||||
}
|
||||
|
||||
// @_transparent // @_inlineable
|
||||
public func naturalExponential() -> Complex {
|
||||
if real.isNaN && imaginary == 0 { return self }
|
||||
var im = imaginary
|
||||
if real.isInfinite {
|
||||
if real < 0 && !im.isFinite {
|
||||
im = 1
|
||||
} else if im == 0 || !im.isFinite {
|
||||
if im.isInfinite { im = .nan }
|
||||
return Complex(real: real, imaginary: im)
|
||||
}
|
||||
}
|
||||
return Complex(r: T.exp(real), theta: im)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func naturalLogarithm() -> Complex {
|
||||
return Complex(real: T.log(magnitude), imaginary: argument)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func commonLogarithm() -> Complex {
|
||||
return Complex.log(self) / Complex.log(10 as Complex)
|
||||
}
|
||||
|
||||
// @_transparent // @_inlineable
|
||||
public func squareRoot() -> Complex {
|
||||
if imaginary.isInfinite {
|
||||
return Complex(real: .infinity, imaginary: imaginary)
|
||||
}
|
||||
if real.isInfinite {
|
||||
if real > 0 {
|
||||
return Complex(
|
||||
real: real,
|
||||
imaginary: imaginary.isNaN ? imaginary :
|
||||
T(signOf: imaginary, magnitudeOf: 0)
|
||||
)
|
||||
}
|
||||
return Complex(
|
||||
real: imaginary.isNaN ? imaginary : 0,
|
||||
imaginary: T(signOf: imaginary, magnitudeOf: real)
|
||||
)
|
||||
}
|
||||
// Guard intermediate results and enforce a branch cut; see Numerical
|
||||
// Recipes.
|
||||
if real == 0 && imaginary == 0 { return 0 }
|
||||
let w: T
|
||||
let x = abs(real), y = abs(imaginary)
|
||||
if x >= y {
|
||||
let r = y / x
|
||||
w = T.sqrt(x) * T.sqrt((1 + T.sqrt(1 + r * r)) / 2)
|
||||
} else {
|
||||
let r = x / y
|
||||
w = T.sqrt(y) * T.sqrt((r + T.sqrt(1 + r * r)) / 2)
|
||||
}
|
||||
if real >= 0 {
|
||||
return Complex(real: w, imaginary: imaginary / (2 * w))
|
||||
}
|
||||
/* real < 0 */
|
||||
return Complex(real: y / (2 * w), imaginary: imaginary >= 0 ? w : -w)
|
||||
|
||||
/*
|
||||
return Complex(r: T.sqrt(magnitude), theta: argument / 2)
|
||||
*/
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func cubeRoot() -> Complex {
|
||||
return Complex.exp(Complex.log(self) / 3)
|
||||
|
||||
/*
|
||||
return Complex(r: T.cbrt(magnitude), theta: argument / 3)
|
||||
*/
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func power(of base: Complex) -> Complex {
|
||||
return Complex.exp(self * Complex.log(base))
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func sine() -> Complex {
|
||||
let sinh = Complex.sinh(Complex(real: -imaginary, imaginary: real))
|
||||
return Complex(real: sinh.imaginary, imaginary: -sinh.real)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func cosine() -> Complex {
|
||||
return Complex.cosh(Complex(real: -imaginary, imaginary: real))
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func tangent() -> Complex {
|
||||
let tanh = Complex.tanh(Complex(real: -imaginary, imaginary: real))
|
||||
return Complex(real: tanh.imaginary, imaginary: -tanh.real)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func inverseSine() -> Complex {
|
||||
let asinh = Complex.asinh(Complex(real: -imaginary, imaginary: real))
|
||||
return Complex(real: asinh.imaginary, imaginary: -asinh.real)
|
||||
}
|
||||
|
||||
// @_transparent // @_inlineable
|
||||
public func inverseCosine() -> Complex {
|
||||
if real.isNaN {
|
||||
if imaginary.isInfinite {
|
||||
return Complex(real: real, imaginary: -imaginary)
|
||||
}
|
||||
return Complex(real: real, imaginary: real)
|
||||
}
|
||||
if real.isInfinite {
|
||||
if imaginary.isNaN {
|
||||
return Complex(real: imaginary, imaginary: real)
|
||||
}
|
||||
if imaginary.isInfinite {
|
||||
return Complex(
|
||||
real: real < 0 ? .pi * 3 / 4 : .pi / 4,
|
||||
imaginary: -imaginary
|
||||
)
|
||||
}
|
||||
return real < 0 ?
|
||||
Complex(real: .pi, imaginary: imaginary.sign == .minus ? -real : real) :
|
||||
Complex(real: 0, imaginary: imaginary.sign == .minus ? real : -real)
|
||||
}
|
||||
if real == 0 && (imaginary.isNaN || imaginary == 0) {
|
||||
return Complex(real: .pi / 2, imaginary: -imaginary)
|
||||
}
|
||||
if imaginary.isInfinite {
|
||||
return Complex(real: .pi / 2, imaginary: -imaginary)
|
||||
}
|
||||
let a = Complex.pow(self, 2) - 1
|
||||
let b = Complex.log(self + Complex.sqrt(a))
|
||||
return Complex(
|
||||
real: abs(b.imaginary),
|
||||
imaginary: imaginary.sign == .minus ? abs(b.real) : -abs(b.real)
|
||||
)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func inverseTangent() -> Complex {
|
||||
let atanh = Complex.atanh(Complex(real: -imaginary, imaginary: real))
|
||||
return Complex(real: atanh.imaginary, imaginary: -atanh.real)
|
||||
}
|
||||
|
||||
// @_transparent // @_inlineable
|
||||
public func hyperbolicSine() -> Complex {
|
||||
if (real.isInfinite || real == 0) && !imaginary.isFinite {
|
||||
return Complex(real: real, imaginary: .nan)
|
||||
}
|
||||
if imaginary == 0 && !real.isFinite {
|
||||
return self
|
||||
}
|
||||
return Complex(
|
||||
real: T.sinh(real) * T.cos(imaginary),
|
||||
imaginary: T.cosh(real) * T.sin(imaginary)
|
||||
)
|
||||
}
|
||||
|
||||
// @_transparent // @_inlineable
|
||||
public func hyperbolicCosine() -> Complex {
|
||||
if real.isInfinite && !imaginary.isFinite {
|
||||
return Complex(real: abs(real), imaginary: .nan)
|
||||
}
|
||||
if real == 0 && imaginary == 0 {
|
||||
return Complex(real: 1, imaginary: imaginary)
|
||||
}
|
||||
if real == 0 && !imaginary.isFinite {
|
||||
return Complex(real: .nan, imaginary: real)
|
||||
}
|
||||
if imaginary == 0 && !real.isFinite {
|
||||
return Complex(real: abs(real), imaginary: imaginary)
|
||||
}
|
||||
return Complex(
|
||||
real: T.cosh(real) * T.cos(imaginary),
|
||||
imaginary: T.sinh(real) * T.sin(imaginary)
|
||||
)
|
||||
}
|
||||
|
||||
// @_transparent // @_inlineable
|
||||
public func hyperbolicTangent() -> Complex {
|
||||
if real.isNaN && imaginary == 0 { return self }
|
||||
if real.isInfinite {
|
||||
if !imaginary.isFinite { return 1 }
|
||||
return Complex(
|
||||
real: 1, imaginary: T(signOf: T.sin(2 * imaginary), magnitudeOf: 0)
|
||||
)
|
||||
}
|
||||
// See AMS55 4.5.51
|
||||
let twiceReal = 2 * real, twiceImaginary = 2 * imaginary
|
||||
let denominator = T.cosh(twiceReal) + T.cos(twiceImaginary)
|
||||
let sinh = T.sinh(twiceReal)
|
||||
if sinh.isInfinite && denominator.isInfinite {
|
||||
return Complex(
|
||||
real: sinh > 0 ? (1 as T) : -(1 as T),
|
||||
imaginary: twiceImaginary > 0 ? (0 as T) : -(0 as T)
|
||||
)
|
||||
}
|
||||
return Complex(
|
||||
real: sinh / denominator,
|
||||
imaginary: T.sin(twiceImaginary) / denominator
|
||||
)
|
||||
}
|
||||
|
||||
// @_transparent // @_inlineable
|
||||
public func inverseHyperbolicSine() -> Complex {
|
||||
if real.isNaN {
|
||||
if imaginary.isInfinite {
|
||||
return Complex(real: imaginary, imaginary: real)
|
||||
}
|
||||
if imaginary == 0 { return self }
|
||||
return Complex(real: real, imaginary: real)
|
||||
}
|
||||
if real.isInfinite {
|
||||
if imaginary.isNaN { return self }
|
||||
if imaginary.isInfinite {
|
||||
return Complex(
|
||||
real: real, imaginary: T(signOf: imaginary, magnitudeOf: .pi / 4)
|
||||
)
|
||||
}
|
||||
return Complex(
|
||||
real: real, imaginary: T(signOf: imaginary, magnitudeOf: 0)
|
||||
)
|
||||
}
|
||||
if imaginary.isInfinite {
|
||||
return Complex(
|
||||
real: T(signOf: real, magnitudeOf: imaginary),
|
||||
imaginary: T(signOf: imaginary, magnitudeOf: .pi / 2)
|
||||
)
|
||||
}
|
||||
let a = Complex.pow(self, 2) + 1
|
||||
let b = Complex.log(self + Complex.sqrt(a))
|
||||
return Complex(
|
||||
real: T(signOf: real, magnitudeOf: b.real),
|
||||
imaginary: T(signOf: imaginary, magnitudeOf: b.imaginary)
|
||||
)
|
||||
}
|
||||
|
||||
// @_transparent // @_inlineable
|
||||
public func inverseHyperbolicCosine() -> Complex {
|
||||
if real.isNaN {
|
||||
if imaginary.isInfinite {
|
||||
return Complex(real: .infinity, imaginary: real)
|
||||
}
|
||||
return Complex(real: real, imaginary: real)
|
||||
}
|
||||
if real.isInfinite {
|
||||
if imaginary.isNaN {
|
||||
return Complex(real: .infinity, imaginary: imaginary)
|
||||
}
|
||||
if imaginary.isInfinite {
|
||||
switch (real.sign, imaginary.sign) {
|
||||
case (.plus, .plus):
|
||||
return Complex(real: .infinity, imaginary: .pi / 4)
|
||||
case (.plus, .minus):
|
||||
return Complex(real: .infinity, imaginary: -.pi / 4)
|
||||
case (.minus, .plus):
|
||||
return Complex(real: .infinity, imaginary: .pi * 3 / 4)
|
||||
case (.minus, .minus):
|
||||
return Complex(real: .infinity, imaginary: -.pi * 3 / 4)
|
||||
}
|
||||
}
|
||||
switch (real.sign, imaginary.sign) {
|
||||
case (.plus, .plus):
|
||||
return Complex(real: .infinity, imaginary: 0)
|
||||
case (.plus, .minus):
|
||||
return Complex(real: .infinity, imaginary: -(0 as T))
|
||||
case (.minus, .plus):
|
||||
return Complex(real: .infinity, imaginary: .pi)
|
||||
case (.minus, .minus):
|
||||
return Complex(real: .infinity, imaginary: -.pi)
|
||||
}
|
||||
}
|
||||
if imaginary.isNaN {
|
||||
// See C11 DR 471.
|
||||
return Complex(
|
||||
real: imaginary,
|
||||
imaginary: real == 0 ? .pi / 2 : imaginary
|
||||
)
|
||||
}
|
||||
if imaginary.isInfinite {
|
||||
return Complex(
|
||||
real: .infinity, imaginary: T(signOf: imaginary, magnitudeOf: .pi / 2)
|
||||
)
|
||||
}
|
||||
let a = Complex.pow(self, 2) - 1
|
||||
let b = Complex.log(self + Complex.sqrt(a))
|
||||
return Complex(
|
||||
real: T(signOf: 0, magnitudeOf: b.real),
|
||||
imaginary: T(signOf: imaginary, magnitudeOf: b.imaginary)
|
||||
)
|
||||
}
|
||||
|
||||
// @_transparent // @_inlineable
|
||||
public func inverseHyperbolicTangent() -> Complex {
|
||||
if imaginary.isNaN {
|
||||
if real.isInfinite || real == 0 {
|
||||
return Complex(
|
||||
real: T(signOf: real, magnitudeOf: 0), imaginary: imaginary
|
||||
)
|
||||
}
|
||||
return Complex(real: imaginary, imaginary: imaginary)
|
||||
}
|
||||
if imaginary.isInfinite {
|
||||
return Complex(
|
||||
real: T(signOf: real, magnitudeOf: 0),
|
||||
imaginary: T(signOf: imaginary, magnitudeOf: .pi / 2)
|
||||
)
|
||||
}
|
||||
if imaginary == 0 && abs(real) == 1 {
|
||||
return Complex(
|
||||
real: T(signOf: real, magnitudeOf: .infinity),
|
||||
imaginary: T(signOf: imaginary, magnitudeOf: 0)
|
||||
)
|
||||
}
|
||||
if real.isNaN {
|
||||
return Complex(real: real, imaginary: real)
|
||||
}
|
||||
if real.isInfinite {
|
||||
return Complex(
|
||||
real: T(signOf: real, magnitudeOf: 0),
|
||||
imaginary: T(signOf: imaginary, magnitudeOf: .pi / 2)
|
||||
)
|
||||
}
|
||||
let a = Complex.log((1 + self) / (1 - self)) / 2
|
||||
return Complex(
|
||||
real: T(signOf: real, magnitudeOf: a.real),
|
||||
imaginary: T(signOf: imaginary, magnitudeOf: a.imaginary)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the absolute value (magnitude, modulus) of `z`.
|
||||
@_transparent
|
||||
public func abs<T>(_ z: Complex<T>) -> Complex<T> {
|
||||
return Complex(real: z.magnitude)
|
||||
}
|
||||
|
||||
/// Returns the square root of `z`.
|
||||
@_transparent
|
||||
public func sqrt<T>(_ z: Complex<T>) -> Complex<T> {
|
||||
return z.squareRoot()
|
||||
}
|
|
@ -1,426 +0,0 @@
|
|||
//
|
||||
// Complex.swift
|
||||
// NumericAnnex
|
||||
//
|
||||
// Created by Xiaodi Wu on 3/25/17.
|
||||
//
|
||||
|
||||
/// A type to represent a complex value in Cartesian form.
|
||||
///
|
||||
/// Create new instances of `Complex<T>` using integer or floating-point
|
||||
/// literals and the imaginary unit `.i`. For example:
|
||||
///
|
||||
/// ```swift
|
||||
/// let x = 2 + 4 * .i // `x` is of type `Complex<Double>`
|
||||
/// let y = 3.5 + 7 * .i // `y` is of type `Complex<Double>`
|
||||
///
|
||||
/// let z: Complex64 = .e + .pi * .i // `z` is of type `Complex<Float>`
|
||||
/// ```
|
||||
///
|
||||
/// Additional Considerations
|
||||
/// =========================
|
||||
///
|
||||
/// Floating-point types have special values that represent infinity or NaN
|
||||
/// ("not a number"). Complex functions in different languages may return
|
||||
/// different results when working with special values.
|
||||
///
|
||||
/// Many complex functions have [branch cuts][dfn], which are curves in the
|
||||
/// complex plane across which a function is discontinuous. Different languages
|
||||
/// may adopt different branch cut structures for the same complex function.
|
||||
///
|
||||
/// Implementations in `Complex<T>` adhere to the [C standard][std] (Annex G) as
|
||||
/// closely as possible with respect to special values and branch cuts.
|
||||
///
|
||||
/// To users unfamiliar with complex functions, the principal value returned by
|
||||
/// some complex functions may be unexpected. For example,
|
||||
/// `Double.cbrt(-8) == -2`, which is the __real root__, while
|
||||
/// `Complex.cbrt(-8) == 2 * Complex.exp(.i * .pi / 3)`, which is the
|
||||
/// __principal root__.
|
||||
///
|
||||
/// [dfn]: http://mathworld.wolfram.com/BranchCut.html
|
||||
/// [std]: http://www.open-std.org/JTC1/SC22/WG14/www/standards.html#9899
|
||||
@_fixed_layout
|
||||
public struct Complex<T : FloatingPointMath>
|
||||
where T : _ExpressibleByBuiltinFloatLiteral {
|
||||
/// The real component of the complex value.
|
||||
public var real: T
|
||||
|
||||
/// The imaginary component of the complex value.
|
||||
public var imaginary: T
|
||||
|
||||
/// Creates a new value from the given real and imaginary components.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - real: The new value's real component.
|
||||
/// - imaginary: The new value's imaginary component.
|
||||
@_transparent // @_inlineable
|
||||
public init(real: T = 0, imaginary: T = 0) {
|
||||
self.real = real
|
||||
self.imaginary = imaginary
|
||||
}
|
||||
|
||||
/// The imaginary unit i.
|
||||
@_transparent // @_inlineable
|
||||
public static var i: Complex {
|
||||
return Complex(real: 0, imaginary: 1)
|
||||
}
|
||||
}
|
||||
|
||||
extension Complex {
|
||||
/// Creates a new value from the given real component, rounded to the closest
|
||||
/// possible representation.
|
||||
///
|
||||
/// If two representable values are equally close, the result is the value
|
||||
/// with more trailing zeros in its significand bit pattern.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - real: The integer to convert to a floating-point real component.
|
||||
@_transparent // @_inlineable
|
||||
init(_ real: Int) {
|
||||
self.real = T(real)
|
||||
self.imaginary = 0
|
||||
}
|
||||
|
||||
/// Creates a new value from the given real component, rounded to the closest
|
||||
/// possible representation.
|
||||
///
|
||||
/// If two representable values are equally close, the result is the value
|
||||
/// with more trailing zeros in its significand bit pattern.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - real: The integer to convert to a floating-point real component.
|
||||
@_transparent // @_inlineable
|
||||
init(_ real: Int8) {
|
||||
self.real = T(real)
|
||||
self.imaginary = 0
|
||||
}
|
||||
|
||||
/// Creates a new value from the given real component, rounded to the closest
|
||||
/// possible representation.
|
||||
///
|
||||
/// If two representable values are equally close, the result is the value
|
||||
/// with more trailing zeros in its significand bit pattern.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - real: The integer to convert to a floating-point real component.
|
||||
@_transparent // @_inlineable
|
||||
init(_ real: Int16) {
|
||||
self.real = T(real)
|
||||
self.imaginary = 0
|
||||
}
|
||||
|
||||
/// Creates a new value from the given real component, rounded to the closest
|
||||
/// possible representation.
|
||||
///
|
||||
/// If two representable values are equally close, the result is the value
|
||||
/// with more trailing zeros in its significand bit pattern.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - real: The integer to convert to a floating-point real component.
|
||||
@_transparent // @_inlineable
|
||||
init(_ real: Int32) {
|
||||
self.real = T(real)
|
||||
self.imaginary = 0
|
||||
}
|
||||
|
||||
/// Creates a new value from the given real component, rounded to the closest
|
||||
/// possible representation.
|
||||
///
|
||||
/// If two representable values are equally close, the result is the value
|
||||
/// with more trailing zeros in its significand bit pattern.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - real: The integer to convert to a floating-point real component.
|
||||
@_transparent // @_inlineable
|
||||
init(_ real: Int64) {
|
||||
self.real = T(real)
|
||||
self.imaginary = 0
|
||||
}
|
||||
|
||||
/// Creates a new value from the given real component, rounded to the closest
|
||||
/// possible representation.
|
||||
///
|
||||
/// If two representable values are equally close, the result is the value
|
||||
/// with more trailing zeros in its significand bit pattern.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - real: The integer to convert to a floating-point real component.
|
||||
@_transparent // @_inlineable
|
||||
init(_ real: UInt) {
|
||||
self.real = T(real)
|
||||
self.imaginary = 0
|
||||
}
|
||||
|
||||
/// Creates a new value from the given real component, rounded to the closest
|
||||
/// possible representation.
|
||||
///
|
||||
/// If two representable values are equally close, the result is the value
|
||||
/// with more trailing zeros in its significand bit pattern.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - real: The integer to convert to a floating-point real component.
|
||||
@_transparent // @_inlineable
|
||||
init(_ real: UInt8) {
|
||||
self.real = T(real)
|
||||
self.imaginary = 0
|
||||
}
|
||||
|
||||
/// Creates a new value from the given real component, rounded to the closest
|
||||
/// possible representation.
|
||||
///
|
||||
/// If two representable values are equally close, the result is the value
|
||||
/// with more trailing zeros in its significand bit pattern.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - real: The integer to convert to a floating-point real component.
|
||||
@_transparent // @_inlineable
|
||||
init(_ real: UInt16) {
|
||||
self.real = T(real)
|
||||
self.imaginary = 0
|
||||
}
|
||||
|
||||
/// Creates a new value from the given real component, rounded to the closest
|
||||
/// possible representation.
|
||||
///
|
||||
/// If two representable values are equally close, the result is the value
|
||||
/// with more trailing zeros in its significand bit pattern.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - real: The integer to convert to a floating-point real component.
|
||||
@_transparent // @_inlineable
|
||||
init(_ real: UInt32) {
|
||||
self.real = T(real)
|
||||
self.imaginary = 0
|
||||
}
|
||||
|
||||
/// Creates a new value from the given real component, rounded to the closest
|
||||
/// possible representation.
|
||||
///
|
||||
/// If two representable values are equally close, the result is the value
|
||||
/// with more trailing zeros in its significand bit pattern.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - real: The integer to convert to a floating-point real component.
|
||||
@_transparent // @_inlineable
|
||||
init(_ real: UInt64) {
|
||||
self.real = T(real)
|
||||
self.imaginary = 0
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// FIXME: If corresponding requirements are added to FloatingPoint
|
||||
// add init<U : Integer>(_: U) as well as init?<U : Integer>(exactly: U).
|
||||
// ---------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
extension Complex where T : BinaryFloatingPoint {
|
||||
/// Creates a new value from the given real component, rounded to the closest
|
||||
/// possible representation.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - real: The value to convert to a real component of type `T`.
|
||||
@_transparent // @_inlineable
|
||||
public init(_ real: Float) {
|
||||
self.real = T(real)
|
||||
self.imaginary = 0
|
||||
}
|
||||
|
||||
/// Creates a new value from the given real component, rounded to the closest
|
||||
/// possible representation.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - real: The value to convert to a real component of type `T`.
|
||||
@_transparent // @_inlineable
|
||||
public init(_ real: Double) {
|
||||
self.real = T(real)
|
||||
self.imaginary = 0
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// FIXME: If corresponding requirements are added to BinaryFloatingPoint
|
||||
// add init<U : BinaryFloatingPoint>(_: U) as well as
|
||||
// init?<U : BinaryFloatingPoint>(exactly: U).
|
||||
// ---------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
extension Complex {
|
||||
/// Creates a new value from the given polar coordinates `(r, theta)`.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - r: The new value's radial coordinate.
|
||||
/// - theta: The new value's angular coordinate.
|
||||
@_transparent // @_inlineable
|
||||
public init(r: T, theta: T) {
|
||||
self.real = r * T.cos(theta)
|
||||
self.imaginary = r * T.sin(theta)
|
||||
}
|
||||
|
||||
/// The principal argument (phase angle) of this value.
|
||||
///
|
||||
/// Special cases are handled as if calling `T.atan2(imaginary, real)`. The
|
||||
/// result lies in the range [-π, π].
|
||||
@_transparent // @_inlineable
|
||||
public var argument: T {
|
||||
return T.atan2(imaginary, real)
|
||||
}
|
||||
|
||||
/// A Boolean value indicating whether the instance's real and imaginary
|
||||
/// components are both in canonical form, as defined in the [IEEE 754
|
||||
/// specification][spec]. Every `Float` or `Double` value is canonical.
|
||||
///
|
||||
/// [spec]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933
|
||||
@_transparent // @_inlineable
|
||||
public var isCanonical: Bool {
|
||||
return real.isCanonical && imaginary.isCanonical
|
||||
}
|
||||
|
||||
/// A Boolean value indicating whether the instance's real and imaginary
|
||||
/// components are both finite.
|
||||
///
|
||||
/// All values other than NaN and infinity are considered finite.
|
||||
@_transparent // @_inlineable
|
||||
public var isFinite: Bool {
|
||||
return real.isFinite && imaginary.isFinite
|
||||
}
|
||||
|
||||
/// A Boolean value indicating whether the instance's real and/or imaginary
|
||||
/// components are infinite.
|
||||
///
|
||||
/// Note that `isFinite` and `isInfinite` do not form a dichotomy because NaN
|
||||
/// is neither finite nor infinite.
|
||||
@_transparent // @_inlineable
|
||||
public var isInfinite: Bool {
|
||||
return real.isInfinite || imaginary.isInfinite
|
||||
}
|
||||
|
||||
/// A Boolean value indicating whether the instance's real and/or imaginary
|
||||
/// components are NaN ("not a number").
|
||||
///
|
||||
/// Because NaN is not equal to any value, including NaN, use this property
|
||||
/// instead of the equal-to operator (`==`) or not-equal-to operator (`!=`) to
|
||||
/// test whether a value is or is not NaN.
|
||||
///
|
||||
/// This property is `true` for both quiet and signaling NaNs.
|
||||
@_transparent // @_inlineable
|
||||
public var isNaN: Bool {
|
||||
return real.isNaN || imaginary.isNaN
|
||||
}
|
||||
|
||||
/// A Boolean value indicating whether the instance's real and/or imaginary
|
||||
/// components are signaling NaNs.
|
||||
///
|
||||
/// Signaling NaNs typically raise the Invalid flag when used in general
|
||||
/// computing operations.
|
||||
@_transparent // @_inlineable
|
||||
public var isSignalingNaN: Bool {
|
||||
return real.isSignalingNaN || imaginary.isSignalingNaN
|
||||
}
|
||||
|
||||
/// A Boolean value indicating whether the instance is equal to zero.
|
||||
///
|
||||
/// The `isZero` property of a value `z` is `true` when both real and
|
||||
/// imaginary components represent either `-0.0` or `+0.0`.
|
||||
@_transparent // @_inlineable
|
||||
public var isZero: Bool {
|
||||
return real.isZero && imaginary.isZero
|
||||
}
|
||||
|
||||
/// The magnitude (modulus, absolute value) of this value.
|
||||
///
|
||||
/// Special cases are handled as if calling `T.hypot(real, imaginary)`.
|
||||
@_transparent // @_inlineable
|
||||
public var magnitude: T {
|
||||
return T.hypot(real, imaginary)
|
||||
}
|
||||
|
||||
/// The polar coordinates representing this value, equivalent to
|
||||
/// `(r: magnitude, theta: argument)`.
|
||||
@_transparent // @_inlineable
|
||||
public var polar: (r: T, theta: T) {
|
||||
return (r: magnitude, theta: argument)
|
||||
}
|
||||
|
||||
/// The squared magnitude (field norm, absolute square) of this value.
|
||||
///
|
||||
/// This is less costly to compute than `magnitude` and, in some cases, can be
|
||||
/// used in its place. For example, if `a.magnitude > b.magnitude`, then
|
||||
/// `a.squaredMagnitude > b.squaredMagnitude`.
|
||||
@_transparent // @_inlineable
|
||||
public var squaredMagnitude: T {
|
||||
if real.isInfinite { return abs(real) }
|
||||
if imaginary.isInfinite { return abs(imaginary) }
|
||||
return real * real + imaginary * imaginary
|
||||
}
|
||||
|
||||
/// Returns the complex conjugate of this value, obtained by reversing the
|
||||
/// sign of the imaginary component.
|
||||
@_transparent // @_inlineable
|
||||
public func conjugate() -> Complex {
|
||||
return Complex(real: real, imaginary: -imaginary)
|
||||
}
|
||||
|
||||
/// Returns the projection of this value onto the Riemann sphere.
|
||||
///
|
||||
/// For most values `z`, `z.projection() == z`. The projection of any complex
|
||||
/// infinity is positive real infinity. The sign of the imaginary component is
|
||||
/// preserved in the sign of zero; that is,
|
||||
/// `z.projection().imaginary.sign == z.imaginary.sign`.
|
||||
@_transparent // @_inlineable
|
||||
public func projection() -> Complex {
|
||||
if real.isInfinite || imaginary.isInfinite {
|
||||
return Complex(
|
||||
real: .infinity, imaginary: T(signOf: imaginary, magnitudeOf: 0)
|
||||
)
|
||||
}
|
||||
return self
|
||||
}
|
||||
|
||||
/// Returns the reciprocal (multiplicative inverse) of this value.
|
||||
@_transparent // @_inlineable
|
||||
public func reciprocal() -> Complex {
|
||||
let denominator = squaredMagnitude
|
||||
return Complex(
|
||||
real: real / denominator, imaginary: -imaginary / denominator
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extension Complex : ExpressibleByFloatLiteral {
|
||||
@_transparent // @_inlineable
|
||||
public init(floatLiteral value: T) {
|
||||
self.real = value
|
||||
self.imaginary = 0
|
||||
}
|
||||
}
|
||||
|
||||
extension Complex : ExpressibleByIntegerLiteral {
|
||||
@_transparent // @_inlineable
|
||||
public init(integerLiteral value: Int) {
|
||||
self.real = T(value)
|
||||
self.imaginary = 0
|
||||
}
|
||||
}
|
||||
|
||||
extension Complex : CustomStringConvertible {
|
||||
@_transparent // @_inlineable
|
||||
public var description: String {
|
||||
return "\(real) + \(imaginary)i"
|
||||
}
|
||||
}
|
||||
|
||||
extension Complex : Equatable {
|
||||
@_transparent // @_inlineable
|
||||
public static func == (lhs: Complex, rhs: Complex) -> Bool {
|
||||
return lhs.real == rhs.real && lhs.imaginary == rhs.imaginary
|
||||
}
|
||||
}
|
||||
|
||||
extension Complex : Hashable {
|
||||
// @_transparent // @_inlineable
|
||||
public var hashValue: Int {
|
||||
return _fnv1a(real, imaginary)
|
||||
}
|
||||
}
|
||||
|
||||
public typealias Complex64 = Complex<Float>
|
||||
public typealias Complex128 = Complex<Double>
|
|
@ -1,32 +0,0 @@
|
|||
//
|
||||
// Exponentiation.swift
|
||||
// NumericAnnex
|
||||
//
|
||||
// Created by Xiaodi Wu on 4/24/17.
|
||||
//
|
||||
|
||||
extension BinaryInteger {
|
||||
/// Returns the result of raising `base` to the power of `exponent`, rounded
|
||||
/// to a representable value.
|
||||
// @_transparent // @_inlineable
|
||||
public static func pow(_ base: Self, _ exponent: Self) -> Self {
|
||||
var x = base, n = exponent
|
||||
if Self.isSigned && n < 0 {
|
||||
x = 1 / x
|
||||
n = 0 - n
|
||||
} else if n == 0 {
|
||||
return 1
|
||||
}
|
||||
// Exponentiate by iterative squaring.
|
||||
var y = 1 as Self
|
||||
while n > 1 {
|
||||
if n % 2 == 1 {
|
||||
y *= x
|
||||
n -= 1
|
||||
}
|
||||
x *= x
|
||||
n /= 2
|
||||
}
|
||||
return x * y
|
||||
}
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
//
|
||||
// Factoring.swift
|
||||
// NumericAnnex
|
||||
//
|
||||
// Created by Xiaodi Wu on 4/15/17.
|
||||
//
|
||||
|
||||
extension UnsignedInteger {
|
||||
/// Returns the greatest common divisor of `a` and `b`.
|
||||
// @_transparent // @_inlineable
|
||||
public static func gcd(_ a: Self, _ b: Self) -> Self {
|
||||
// An iterative version of Stein's algorithm.
|
||||
if a == 0 { return b } // gcd(0, b) == b
|
||||
if b == 0 { return a } // gcd(a, 0) == a
|
||||
|
||||
var a = a, b = b, shift = 0 as Self
|
||||
while ((a | b) & 1) == 0 {
|
||||
a &>>= 1
|
||||
b &>>= 1
|
||||
shift += 1
|
||||
}
|
||||
// Now, shift is equal to log2(k), where k is the greatest power of 2
|
||||
// dividing a and b.
|
||||
while (a & 1) == 0 { a &>>= 1 } // Now, a is odd.
|
||||
repeat {
|
||||
while (b & 1) == 0 { b &>>= 1 } // Now, b is odd.
|
||||
if a > b { swap(&a, &b) } // Now, a < b.
|
||||
b -= a
|
||||
} while b != 0
|
||||
// Restore common factors of 2.
|
||||
return a &<< shift
|
||||
}
|
||||
|
||||
/// Returns the least common multiple of `a` and `b`.
|
||||
@_transparent // @_inlineable
|
||||
public static func lcm(_ a: Self, _ b: Self) -> Self {
|
||||
if a == 0 || b == 0 { return 0 }
|
||||
return a / .gcd(a, b) * b
|
||||
}
|
||||
}
|
||||
|
||||
extension UnsignedInteger where Self : FixedWidthInteger {
|
||||
/// Returns the least common multiple of `a` and `b` and a flag to indicate
|
||||
/// whether overflow occurred during the operation.
|
||||
// @_transparent // @_inlineable
|
||||
public static func lcmReportingOverflow(_ a: Self, _ b: Self)
|
||||
-> (partialValue: Self, overflow: ArithmeticOverflow) {
|
||||
if a == 0 || b == 0 { return (partialValue: 0, overflow: .none) }
|
||||
return (a / .gcd(a, b)).multipliedReportingOverflow(by: b)
|
||||
}
|
||||
|
||||
/// Returns the high and low parts of the least common multiple of `a` and `b`
|
||||
/// computed using full-width arithmetic.
|
||||
// @_transparent // @_inlineable
|
||||
public static func lcmFullWidth(_ a: Self, _ b: Self)
|
||||
-> (high: Self, low: Self.Magnitude) {
|
||||
if a == 0 || b == 0 { return (0, 0) }
|
||||
return (a / .gcd(a, b)).multipliedFullWidth(by: b)
|
||||
}
|
||||
}
|
||||
|
||||
extension BinaryInteger where Magnitude : UnsignedInteger {
|
||||
/// Returns the greatest common divisor of `a` and `b`.
|
||||
@_transparent // @_inlineable
|
||||
public static func gcd(_ a: Self, _ b: Self) -> Self {
|
||||
return Self(Magnitude.gcd(a.magnitude, b.magnitude))
|
||||
}
|
||||
|
||||
/// Returns the least common multiple of `a` and `b`.
|
||||
@_transparent // @_inlineable
|
||||
public static func lcm(_ a: Self, _ b: Self) -> Self {
|
||||
return Self(Magnitude.lcm(a.magnitude, b.magnitude))
|
||||
}
|
||||
}
|
||||
|
||||
// `BinaryInteger where Self : FixedWidthInteger` may seem superfluous, but it
|
||||
// is necessary to disambiguate calls to `Magnitude.lcmReportingOverflow(_:_:)`
|
||||
// and `Magnitude.lcmFullWidth(_:_:)`.
|
||||
extension BinaryInteger
|
||||
where Self : FixedWidthInteger, Magnitude : FixedWidthInteger & UnsignedInteger,
|
||||
Magnitude.Magnitude == Magnitude {
|
||||
/// Returns the greatest common divisor of `a` and `b` and a flag to indicate
|
||||
/// whether overflow occurred during the operation.
|
||||
// @_transparent // @_inlineable
|
||||
public static func gcdReportingOverflow(_ a: Self, _ b: Self)
|
||||
-> (partialValue: Self, overflow: ArithmeticOverflow) {
|
||||
let t = Self(extendingOrTruncating: Magnitude.gcd(a.magnitude, b.magnitude))
|
||||
return (
|
||||
partialValue: t,
|
||||
overflow: ArithmeticOverflow(t < 0)
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns the least common multiple of `a` and `b` and a flag to indicate
|
||||
/// whether overflow occurred during the operation.
|
||||
// @_transparent // @_inlineable
|
||||
public static func lcmReportingOverflow(_ a: Self, _ b: Self)
|
||||
-> (partialValue: Self, overflow: ArithmeticOverflow) {
|
||||
let (t, overflow) = Magnitude.lcmReportingOverflow(a.magnitude, b.magnitude)
|
||||
let u = Self(extendingOrTruncating: t)
|
||||
return (
|
||||
partialValue: u,
|
||||
overflow: ArithmeticOverflow(overflow == .overflow || u < 0)
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns the high and low parts of the least common multiple of `a` and `b`
|
||||
/// computed using full-width arithmetic.
|
||||
// @_transparent // @_inlineable
|
||||
public static func lcmFullWidth(_ a: Self, _ b: Self)
|
||||
-> (high: Self, low: Self.Magnitude) {
|
||||
let t = Magnitude.lcmFullWidth(a.magnitude, b.magnitude)
|
||||
return (high: Self(t.high), low: t.low)
|
||||
}
|
||||
}
|
|
@ -1,670 +0,0 @@
|
|||
//
|
||||
// FloatingPointMath.swift
|
||||
// NumericAnnex
|
||||
//
|
||||
// Created by Xiaodi Wu on 4/1/17.
|
||||
//
|
||||
|
||||
#if os(Linux)
|
||||
import Glibc
|
||||
#else
|
||||
import Darwin.C
|
||||
#endif
|
||||
|
||||
/// A floating-point type that provides a selection of special functions.
|
||||
///
|
||||
/// The `FloatingPointMath` protocol provides a suitable basis for writing
|
||||
/// functions that work on any floating-point type that provides the required
|
||||
/// functions.
|
||||
public protocol FloatingPointMath : Math, FloatingPoint /*, Hashable */ {
|
||||
/// Creates a new value from the given rational value, after rounding the
|
||||
/// whole part and the numerator and denominator of the fractional part each
|
||||
/// to the closest possible representation.
|
||||
///
|
||||
/// If two representable values are equally close, the result is the value
|
||||
/// with more trailing zeros in its significand bit pattern.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - value: The rational value to convert to a floating-point value.
|
||||
init(_ value: Rational<Int>)
|
||||
|
||||
/// Creates a new value from the given rational value, after rounding the
|
||||
/// whole part and the numerator and denominator of the fractional part each
|
||||
/// to the closest possible representation.
|
||||
///
|
||||
/// If two representable values are equally close, the result is the value
|
||||
/// with more trailing zeros in its significand bit pattern.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - value: The rational value to convert to a floating-point value.
|
||||
init(_ value: Rational<Int8>)
|
||||
|
||||
/// Creates a new value from the given rational value, after rounding the
|
||||
/// whole part and the numerator and denominator of the fractional part each
|
||||
/// to the closest possible representation.
|
||||
///
|
||||
/// If two representable values are equally close, the result is the value
|
||||
/// with more trailing zeros in its significand bit pattern.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - value: The rational value to convert to a floating-point value.
|
||||
init(_ value: Rational<Int16>)
|
||||
|
||||
/// Creates a new value from the given rational value, after rounding the
|
||||
/// whole part and the numerator and denominator of the fractional part each
|
||||
/// to the closest possible representation.
|
||||
///
|
||||
/// If two representable values are equally close, the result is the value
|
||||
/// with more trailing zeros in its significand bit pattern.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - value: The rational value to convert to a floating-point value.
|
||||
init(_ value: Rational<Int32>)
|
||||
|
||||
/// Creates a new value from the given rational value, after rounding the
|
||||
/// whole part and the numerator and denominator of the fractional part each
|
||||
/// to the closest possible representation.
|
||||
///
|
||||
/// If two representable values are equally close, the result is the value
|
||||
/// with more trailing zeros in its significand bit pattern.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - value: The rational value to convert to a floating-point value.
|
||||
init(_ value: Rational<Int64>)
|
||||
|
||||
// FIXME: If corresponding requirements are added to FloatingPoint
|
||||
// add init<U : SignedInteger>(_: Rational<U>) as well as
|
||||
// init?<U : SignedInteger>(exactly: Rational<U>).
|
||||
|
||||
/// Returns the hypotenuse of a right-angle triangle with legs (catheti) of
|
||||
/// length `x` and `y`, preventing avoidable arithmetic overflow and
|
||||
/// underflow. The return value is the square root of the sum of squares of
|
||||
/// the arguments.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - x: The length of one leg (cathetus) of a right-angle triangle.
|
||||
/// - y: The length of the other leg (cathetus) of a right-angle triangle.
|
||||
static func hypot(_ x: Self, _ y: Self) -> Self
|
||||
|
||||
/// Returns the inverse tangent of `self / other`, using the signs of `self`
|
||||
/// and `other` to determine the quadrant of the computed angle.
|
||||
///
|
||||
/// If `self == 0 && other == 0`, the return value is still finite.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - other: The divisor by which to divide `self`.
|
||||
///
|
||||
/// - SeeAlso: `atan2(_:_:)`
|
||||
func inverseTangent(dividingBy other: Self) -> Self
|
||||
|
||||
/// Returns the value of the [error function][dfn] of `self`.
|
||||
///
|
||||
/// [dfn]: http://mathworld.wolfram.com/Erf.html
|
||||
///
|
||||
/// - SeeAlso: `erf(_:)`
|
||||
func error() -> Self
|
||||
|
||||
/// Returns the value of the [complementary error function][dfn] of `self`.
|
||||
///
|
||||
/// [dfn]: http://mathworld.wolfram.com/Erfc.html
|
||||
///
|
||||
/// - SeeAlso: `erfc(_:)`
|
||||
func complementaryError() -> Self
|
||||
|
||||
/// Returns the value of the [gamma function][dfn] of `self`.
|
||||
///
|
||||
/// [dfn]: http://mathworld.wolfram.com/GammaFunction.html
|
||||
///
|
||||
/// - SeeAlso: `tgamma(_:)`
|
||||
func gamma() -> Self
|
||||
|
||||
/// Returns the value of the [logarithmic gamma function][dfn] of `self`.
|
||||
///
|
||||
/// [dfn]: http://mathworld.wolfram.com/LogGammaFunction.html
|
||||
///
|
||||
/// - SeeAlso: `lgamma(_:)`
|
||||
func logarithmicGamma() -> Self
|
||||
}
|
||||
|
||||
extension FloatingPointMath {
|
||||
public init(_ value: Rational<Int>) {
|
||||
let (whole, fraction) = value.mixed
|
||||
self = Self(whole) + Self(fraction.numerator) / Self(fraction.denominator)
|
||||
}
|
||||
|
||||
public init(_ value: Rational<Int8>) {
|
||||
let (whole, fraction) = value.mixed
|
||||
self = Self(whole) + Self(fraction.numerator) / Self(fraction.denominator)
|
||||
}
|
||||
|
||||
public init(_ value: Rational<Int16>) {
|
||||
let (whole, fraction) = value.mixed
|
||||
self = Self(whole) + Self(fraction.numerator) / Self(fraction.denominator)
|
||||
}
|
||||
|
||||
public init(_ value: Rational<Int32>) {
|
||||
let (whole, fraction) = value.mixed
|
||||
self = Self(whole) + Self(fraction.numerator) / Self(fraction.denominator)
|
||||
}
|
||||
|
||||
public init(_ value: Rational<Int64>) {
|
||||
let (whole, fraction) = value.mixed
|
||||
self = Self(whole) + Self(fraction.numerator) / Self(fraction.denominator)
|
||||
}
|
||||
|
||||
public static func hypot(_ x: Self, _ y: Self) -> Self {
|
||||
var x = abs(x), y = abs(y)
|
||||
if x < y {
|
||||
swap(&x, &y)
|
||||
}
|
||||
let ratio = y / x
|
||||
return x * .sqrt(1 + ratio * ratio)
|
||||
}
|
||||
|
||||
public func inverseTangent(dividingBy other: Self) -> Self {
|
||||
let y = self, x = other
|
||||
if y.isInfinite {
|
||||
if x.isInfinite {
|
||||
switch (y.sign, x.sign) {
|
||||
case (.minus, .minus): return -.pi * 3 / 4
|
||||
case (.plus, .minus): return .pi * 3 / 4
|
||||
case (.minus, .plus): return -.pi / 4
|
||||
case (.plus, .plus): return .pi / 4
|
||||
}
|
||||
}
|
||||
return y.sign == .minus ? -.pi / 2 : .pi / 2
|
||||
}
|
||||
if x > 0 {
|
||||
return 2 * .atan(y / (.sqrt(x * x + y * y) + x))
|
||||
}
|
||||
if y != 0 {
|
||||
return 2 * .atan((.sqrt(x * x + y * y) - x) / y)
|
||||
}
|
||||
if x.sign == .minus /* && y == 0 */ {
|
||||
return y.sign == .minus ? -.pi : .pi
|
||||
}
|
||||
/* x.sign == .plus && y == 0 */
|
||||
return y.sign == .minus ? -(0 as Self) : 0
|
||||
}
|
||||
}
|
||||
|
||||
extension FloatingPointMath {
|
||||
/// Returns the inverse tangent of `y / x`, using the signs of `y` and `x` to
|
||||
/// determine the quadrant of the computed angle.
|
||||
///
|
||||
/// If `x == 0 && y == 0`, the return value is still finite.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - y: The value to divide.
|
||||
/// - x: The divisor by which to divide `y`.
|
||||
///
|
||||
/// - SeeAlso: `inverseTangent(dividingBy:)`
|
||||
@_transparent // @_inlineable
|
||||
public static func atan2(_ y: Self, _ x: Self) -> Self {
|
||||
// Note the order of the internal names `y` and `x`, which is deliberate: a
|
||||
// minority of programming languages vend functions that reverse the order
|
||||
// of the arguments, but all refer to the denominator as `x` and the
|
||||
// numerator as `y`.
|
||||
return y.inverseTangent(dividingBy: x)
|
||||
}
|
||||
|
||||
/// Returns the value of the [error function][dfn] of `x`.
|
||||
///
|
||||
/// [dfn]: http://mathworld.wolfram.com/Erf.html
|
||||
///
|
||||
/// - SeeAlso: `error()`
|
||||
@_transparent // @_inlineable
|
||||
public static func erf(_ x: Self) -> Self {
|
||||
return x.error()
|
||||
}
|
||||
|
||||
/// Returns the value of the [complementary error function][dfn] of `x`.
|
||||
///
|
||||
/// [dfn]: http://mathworld.wolfram.com/Erfc.html
|
||||
///
|
||||
/// - SeeAlso: `complementaryError()`
|
||||
@_transparent // @_inlineable
|
||||
public static func erfc(_ x: Self) -> Self {
|
||||
return x.complementaryError()
|
||||
}
|
||||
|
||||
/// Returns the value of the [gamma function][dfn] of `x`.
|
||||
///
|
||||
/// [dfn]: http://mathworld.wolfram.com/GammaFunction.html
|
||||
///
|
||||
/// - SeeAlso: `gamma()`
|
||||
@_transparent // @_inlineable
|
||||
public static func tgamma(_ x: Self) -> Self {
|
||||
return x.gamma()
|
||||
}
|
||||
|
||||
/// Returns the value of the [logarithmic gamma function][dfn] of `x`.
|
||||
///
|
||||
/// [dfn]: http://mathworld.wolfram.com/LogGammaFunction.html
|
||||
///
|
||||
/// - SeeAlso: `logarithmicGamma()`
|
||||
@_transparent // @_inlineable
|
||||
public static func lgamma(_ x: Self) -> Self {
|
||||
return x.logarithmicGamma()
|
||||
}
|
||||
}
|
||||
|
||||
extension Float : FloatingPointMath {
|
||||
@_transparent
|
||||
public static var e: Float {
|
||||
return Float(0x1.5bf0a8p1)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public static var phi: Float {
|
||||
return Float(0x1.9e377ap0)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func naturalExponential() -> Float {
|
||||
return expf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func binaryExponential() -> Float {
|
||||
return exp2f(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func commonExponential() -> Float {
|
||||
#if os(Linux)
|
||||
return exp10f(self)
|
||||
#else
|
||||
return __exp10f(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func naturalExponentialMinusOne() -> Float {
|
||||
return expm1f(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func naturalLogarithm() -> Float {
|
||||
return logf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func binaryLogarithm() -> Float {
|
||||
return log2f(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func commonLogarithm() -> Float {
|
||||
return log10f(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func naturalLogarithmOnePlus() -> Float {
|
||||
return log1pf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func cubeRoot() -> Float {
|
||||
return cbrtf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func power(of base: Float) -> Float {
|
||||
return powf(base, self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func sine() -> Float {
|
||||
return sinf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func cosine() -> Float {
|
||||
return cosf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func tangent() -> Float {
|
||||
return tanf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func inverseSine() -> Float {
|
||||
return asinf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func inverseCosine() -> Float {
|
||||
return acosf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func inverseTangent() -> Float {
|
||||
return atanf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func hyperbolicSine() -> Float {
|
||||
return sinhf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func hyperbolicCosine() -> Float {
|
||||
return coshf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func hyperbolicTangent() -> Float {
|
||||
return tanhf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func inverseHyperbolicSine() -> Float {
|
||||
return asinhf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func inverseHyperbolicCosine() -> Float {
|
||||
return acoshf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func inverseHyperbolicTangent() -> Float {
|
||||
return atanhf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public static func hypot(_ x: Float, _ y: Float) -> Float {
|
||||
return hypotf(x, y)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func inverseTangent(dividingBy other: Float) -> Float {
|
||||
return atan2f(self, other)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func error() -> Float {
|
||||
return erff(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func complementaryError() -> Float {
|
||||
return erfcf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func gamma() -> Float {
|
||||
return tgammaf(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func logarithmicGamma() -> Float {
|
||||
return lgammaf(self)
|
||||
}
|
||||
}
|
||||
|
||||
extension Double : FloatingPointMath {
|
||||
@_transparent
|
||||
public static var e: Double {
|
||||
return Double(0x1.5bf0a8b145769p1)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public static var phi: Double {
|
||||
return Double(0x1.9e3779b97f4a8p0)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func naturalExponential() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.exp(self)
|
||||
#else
|
||||
return Darwin.exp(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func binaryExponential() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.exp2(self)
|
||||
#else
|
||||
return Darwin.exp2(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func commonExponential() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.exp10(self)
|
||||
#else
|
||||
return __exp10(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func naturalExponentialMinusOne() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.expm1(self)
|
||||
#else
|
||||
return Darwin.expm1(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func naturalLogarithm() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.log(self)
|
||||
#else
|
||||
return Darwin.log(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func binaryLogarithm() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.log2(self)
|
||||
#else
|
||||
return Darwin.log2(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func commonLogarithm() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.log10(self)
|
||||
#else
|
||||
return Darwin.log10(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func naturalLogarithmOnePlus() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.log1p(self)
|
||||
#else
|
||||
return Darwin.log1p(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func cubeRoot() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.cbrt(self)
|
||||
#else
|
||||
return Darwin.cbrt(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func power(of base: Double) -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.pow(base, self)
|
||||
#else
|
||||
return Darwin.pow(base, self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func sine() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.sin(self)
|
||||
#else
|
||||
return Darwin.sin(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func cosine() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.cos(self)
|
||||
#else
|
||||
return Darwin.cos(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func tangent() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.tan(self)
|
||||
#else
|
||||
return Darwin.tan(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func inverseSine() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.asin(self)
|
||||
#else
|
||||
return Darwin.asin(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func inverseCosine() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.acos(self)
|
||||
#else
|
||||
return Darwin.acos(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func inverseTangent() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.atan(self)
|
||||
#else
|
||||
return Darwin.atan(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func hyperbolicSine() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.sinh(self)
|
||||
#else
|
||||
return Darwin.sinh(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func hyperbolicCosine() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.cosh(self)
|
||||
#else
|
||||
return Darwin.cosh(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func hyperbolicTangent() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.tanh(self)
|
||||
#else
|
||||
return Darwin.tanh(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func inverseHyperbolicSine() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.asinh(self)
|
||||
#else
|
||||
return Darwin.asinh(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func inverseHyperbolicCosine() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.acosh(self)
|
||||
#else
|
||||
return Darwin.acosh(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func inverseHyperbolicTangent() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.atanh(self)
|
||||
#else
|
||||
return Darwin.atanh(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public static func hypot(_ x: Double, _ y: Double) -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.hypot(x, y)
|
||||
#else
|
||||
return Darwin.hypot(x, y)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func inverseTangent(dividingBy other: Double) -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.atan2(self, other)
|
||||
#else
|
||||
return Darwin.atan2(self, other)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func error() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.erf(self)
|
||||
#else
|
||||
return Darwin.erf(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func complementaryError() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.erfc(self)
|
||||
#else
|
||||
return Darwin.erfc(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func gamma() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.tgamma(self)
|
||||
#else
|
||||
return Darwin.tgamma(self)
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
public func logarithmicGamma() -> Double {
|
||||
#if os(Linux)
|
||||
return Glibc.lgamma(self)
|
||||
#else
|
||||
return Darwin.lgamma(self)
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
//
|
||||
// Hash.swift
|
||||
// NumericAnnex
|
||||
//
|
||||
// Created by Xiaodi Wu on 4/1/17.
|
||||
//
|
||||
|
||||
// @_versioned
|
||||
internal func _fnv1a(_ data: AnyHashable...) -> Int {
|
||||
let basis, prime: UInt
|
||||
switch MemoryLayout<UInt>.size {
|
||||
case 4:
|
||||
basis = 2166136261
|
||||
prime = 16777619
|
||||
case 8:
|
||||
basis = 14695981039346656037
|
||||
prime = 1099511628211
|
||||
/*
|
||||
case 16:
|
||||
basis = 144066263297769815596495629667062367629
|
||||
prime = 309485009821345068724781371
|
||||
*/
|
||||
default:
|
||||
fatalError("Unsupported UInt bit width for FNV hash")
|
||||
}
|
||||
|
||||
let result = data.reduce(basis) { partialResult, element in
|
||||
var h = element.hashValue
|
||||
return withUnsafeBytes(of: &h) { bytes in
|
||||
bytes.reduce(partialResult) { ($0 ^ UInt($1)) &* prime }
|
||||
}
|
||||
}
|
||||
return Int(bitPattern: result)
|
||||
}
|
|
@ -1,460 +0,0 @@
|
|||
//
|
||||
// Math.swift
|
||||
// NumericAnnex
|
||||
//
|
||||
// Created by Xiaodi Wu on 3/31/17.
|
||||
//
|
||||
|
||||
/// A signed numeric type that provides square root, cube root, and elementary
|
||||
/// transcendental functions.
|
||||
///
|
||||
/// The `Math` protocol provides a suitable basis for writing functions that
|
||||
/// work on any real or complex floating-point type which provides the required
|
||||
/// functions.
|
||||
public protocol Math : SignedNumeric {
|
||||
/// The mathematical constant pi (_π_).
|
||||
///
|
||||
/// This value should be rounded toward zero to keep user computations with
|
||||
/// angles from inadvertently ending up in the wrong quadrant. A type that
|
||||
/// conforms to the `Math` protocol provides the value for `pi` at its best
|
||||
/// possible precision.
|
||||
static var pi: Self { get }
|
||||
|
||||
/// The mathematical constant _e_, or Euler's number.
|
||||
static var e: Self { get }
|
||||
|
||||
/// The mathematical constant phi (_φ_), or golden ratio.
|
||||
static var phi: Self { get }
|
||||
|
||||
/// Returns the quotient obtained by dividing the first value by the second,
|
||||
/// rounded to a representable value.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - lhs: The value to divide.
|
||||
/// - rhs: The value by which to divide `lhs`.
|
||||
static func / (lhs: Self, rhs: Self) -> Self
|
||||
|
||||
/// Divides the left-hand side by the right-hand side and stores the quotient
|
||||
/// in the left-hand side, rounded to a representable value.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - lhs: The value to divide.
|
||||
/// - rhs: The value by which to divide `lhs`.
|
||||
static func /= (lhs: inout Self, rhs: Self)
|
||||
|
||||
/// Returns the natural exponential of the value, rounded to a representable
|
||||
/// value.
|
||||
///
|
||||
/// The natural exponential of a value `x` is _e_ (2.7182818...) raised to the
|
||||
/// power of `x`.
|
||||
///
|
||||
/// - SeeAlso: `exp(_:)`
|
||||
func naturalExponential() -> Self
|
||||
|
||||
/// Returns the binary exponential of the value, rounded to a representable
|
||||
/// value.
|
||||
///
|
||||
/// The binary exponential of a value `x` is 2 raised to the power of `x`.
|
||||
///
|
||||
/// - SeeAlso: `exp2(_:)`
|
||||
func binaryExponential() -> Self
|
||||
|
||||
/// Returns the common exponential of the value, rounded to a representable
|
||||
/// value.
|
||||
///
|
||||
/// The common exponential of a value `x` is 10 raised to the power of `x`.
|
||||
///
|
||||
/// - SeeAlso: `exp10(_:)`
|
||||
func commonExponential() -> Self
|
||||
|
||||
/// Returns the result of subtracting one from the natural exponential of the
|
||||
/// value, rounded to a representable value.
|
||||
///
|
||||
/// The natural exponential of a value `x` is _e_ (2.7182818...) raised to the
|
||||
/// power of `x`.
|
||||
///
|
||||
/// This function is more accurate than `x.naturalExponential() - 1` for
|
||||
/// values of `x` close to zero.
|
||||
///
|
||||
/// - SeeAlso: `expm1(_:)`
|
||||
func naturalExponentialMinusOne() -> Self
|
||||
|
||||
/// Returns the natural (base _e_) logarithm of the value, rounded to a
|
||||
/// representable value.
|
||||
///
|
||||
/// - SeeAlso: `log(_:)`
|
||||
func naturalLogarithm() -> Self
|
||||
|
||||
/// Returns the binary (base 2) logarithm of the value, rounded to a
|
||||
/// representable value.
|
||||
///
|
||||
/// - SeeAlso: `log2(_:)`
|
||||
func binaryLogarithm() -> Self
|
||||
|
||||
/// Returns the common (base 10) logarithm of the value, rounded to a
|
||||
/// representable value.
|
||||
///
|
||||
/// - SeeAlso: `log10(_:)`
|
||||
func commonLogarithm() -> Self
|
||||
|
||||
/// Returns the natural (base _e_) logarithm of the result of adding one to
|
||||
/// the value, rounded to a representable value.
|
||||
///
|
||||
/// - SeeAlso: `log1p(_:)`
|
||||
func naturalLogarithmOnePlus() -> Self
|
||||
|
||||
/// Returns the square root of the value, rounded to a representable value.
|
||||
///
|
||||
/// - SeeAlso: `sqrt(_:)`
|
||||
func squareRoot() -> Self
|
||||
|
||||
/// Returns the cube root of the value, rounded to a representable value.
|
||||
///
|
||||
/// - SeeAlso: `cbrt(_:)`
|
||||
func cubeRoot() -> Self
|
||||
|
||||
/// Returns the result of raising `base` to the power of the value, rounded to
|
||||
/// a representable value.
|
||||
///
|
||||
/// - Note: The argument is the _base_ and the receiver is the _exponent_.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - base: The base.
|
||||
///
|
||||
/// - SeeAlso: `pow(_:_:)`
|
||||
func power(of base: Self) -> Self
|
||||
|
||||
/// Returns the sine of the value (given in radians), rounded to a
|
||||
/// representable value.
|
||||
///
|
||||
/// - SeeAlso: `sin(_:)`
|
||||
func sine() -> Self
|
||||
|
||||
/// Returns the cosine of the value (given in radians), rounded to a
|
||||
/// representable value.
|
||||
///
|
||||
/// - SeeAlso: `cos(_:)`
|
||||
func cosine() -> Self
|
||||
|
||||
/// Returns the tangent of the value (given in radians), rounded to a
|
||||
/// representable value.
|
||||
///
|
||||
/// - SeeAlso: `tan(_:)`
|
||||
func tangent() -> Self
|
||||
|
||||
/// Returns the principal value of the inverse sine of the value, rounded to a
|
||||
/// representable value.
|
||||
///
|
||||
/// - SeeAlso: `asin(_:)`
|
||||
func inverseSine() -> Self
|
||||
|
||||
/// Returns the principal value of the inverse cosine of the value, rounded to
|
||||
/// a representable value.
|
||||
///
|
||||
/// - SeeAlso: `acos(_:)`
|
||||
func inverseCosine() -> Self
|
||||
|
||||
/// Returns the principal value of the inverse tangent of the value, rounded
|
||||
/// to a representable value.
|
||||
///
|
||||
/// - SeeAlso: `atan(_:)`
|
||||
func inverseTangent() -> Self
|
||||
|
||||
/// Returns the hyperbolic sine of the value, rounded to a representable
|
||||
/// value.
|
||||
///
|
||||
/// - SeeAlso: `sinh(_:)`
|
||||
func hyperbolicSine() -> Self
|
||||
|
||||
/// Returns the hyperbolic cosine of the value, rounded to a representable
|
||||
/// value.
|
||||
///
|
||||
/// - SeeAlso: `cosh(_:)`
|
||||
func hyperbolicCosine() -> Self
|
||||
|
||||
/// Returns the hyperbolic tangent of the value, rounded to a representable
|
||||
/// value.
|
||||
///
|
||||
/// - SeeAlso: `tanh(_:)`
|
||||
func hyperbolicTangent() -> Self
|
||||
|
||||
/// Returns the principal value of the inverse hyperbolic sine of the value,
|
||||
/// rounded to a representable value.
|
||||
///
|
||||
/// - SeeAlso: `asinh(_:)`
|
||||
func inverseHyperbolicSine() -> Self
|
||||
|
||||
/// Returns the principal value of the inverse hyperbolic cosine of the value,
|
||||
/// rounded to a representable value.
|
||||
///
|
||||
/// - SeeAlso: `acosh(_:)`
|
||||
func inverseHyperbolicCosine() -> Self
|
||||
|
||||
/// Returns the principal value of the inverse hyperbolic tangent of the
|
||||
/// value, rounded to a representable value.
|
||||
///
|
||||
/// - SeeAlso: `atanh(_:)`
|
||||
func inverseHyperbolicTangent() -> Self
|
||||
}
|
||||
|
||||
extension Math {
|
||||
// @_transparent
|
||||
public static var e: Self {
|
||||
return Self.exp(1 as Self)
|
||||
}
|
||||
|
||||
// @_transparent
|
||||
public static var phi: Self {
|
||||
return Self.sqrt(((1 as Self) + Self.sqrt(5 as Self)) / (2 as Self))
|
||||
}
|
||||
|
||||
public func binaryExponential() -> Self {
|
||||
return Self.exp(self * Self.log(2 as Self))
|
||||
}
|
||||
|
||||
public func commonExponential() -> Self {
|
||||
return Self.exp(self * Self.log(10 as Self))
|
||||
}
|
||||
|
||||
public func naturalExponentialMinusOne() -> Self {
|
||||
return Self.exp(self) - (1 as Self)
|
||||
}
|
||||
|
||||
public func binaryLogarithm() -> Self {
|
||||
return Self.log(self) / Self.log(2 as Self)
|
||||
}
|
||||
|
||||
public func commonLogarithm() -> Self {
|
||||
return Self.log(self) / Self.log(10 as Self)
|
||||
}
|
||||
|
||||
public func naturalLogarithmOnePlus() -> Self {
|
||||
return Self.log(self + (1 as Self))
|
||||
}
|
||||
|
||||
public func cubeRoot() -> Self {
|
||||
return Self.pow(self, 1 / 3 as Self)
|
||||
}
|
||||
|
||||
public func tangent() -> Self {
|
||||
return sine() / cosine()
|
||||
}
|
||||
|
||||
public func hyperbolicTangent() -> Self {
|
||||
return hyperbolicSine() / hyperbolicCosine()
|
||||
}
|
||||
}
|
||||
|
||||
extension Math {
|
||||
/// Returns the natural exponential of `x`, rounded to a representable value.
|
||||
///
|
||||
/// The natural exponential of a value `x` is _e_ (2.7182818...) raised to the
|
||||
/// power of `x`.
|
||||
///
|
||||
/// - SeeAlso: `naturalExponential()`
|
||||
@_transparent // @_inlineable
|
||||
public static func exp(_ x: Self) -> Self {
|
||||
return x.naturalExponential()
|
||||
}
|
||||
|
||||
/// Returns the binary exponential of `x`, rounded to a representable value.
|
||||
///
|
||||
/// The binary exponential of a value `x` is 2 raised to the power of `x`.
|
||||
///
|
||||
/// - SeeAlso: `binaryExponential()`
|
||||
@_transparent // @_inlineable
|
||||
public static func exp2(_ x: Self) -> Self {
|
||||
return x.binaryExponential()
|
||||
}
|
||||
|
||||
/// Returns the common exponential of `x`, rounded to a representable value.
|
||||
///
|
||||
/// The common exponential of a value `x` is 10 raised to the power of `x`.
|
||||
///
|
||||
/// - SeeAlso: `commonExponential()`
|
||||
@_transparent // @_inlineable
|
||||
public static func exp10(_ x: Self) -> Self {
|
||||
return x.commonExponential()
|
||||
}
|
||||
|
||||
/// Returns the result of subtracting one from the natural exponential of `x`,
|
||||
/// rounded to a representable value.
|
||||
///
|
||||
/// The natural exponential of a value `x` is _e_ (2.7182818...) raised to the
|
||||
/// power of `x`.
|
||||
///
|
||||
/// This function is more accurate than `.exp(x) - 1` for values of `x` close
|
||||
/// to zero.
|
||||
///
|
||||
/// - SeeAlso: `naturalExponentialMinusOne()`
|
||||
@_transparent // @_inlineable
|
||||
public static func expm1(_ x: Self) -> Self {
|
||||
return x.naturalExponentialMinusOne()
|
||||
}
|
||||
|
||||
/// Returns the natural (base _e_) logarithm of `x`, rounded to a
|
||||
/// representable value.
|
||||
///
|
||||
/// - SeeAlso: `naturalLogarithm()`
|
||||
@_transparent // @_inlineable
|
||||
public static func log(_ x: Self) -> Self {
|
||||
return x.naturalLogarithm()
|
||||
}
|
||||
|
||||
/// Returns the binary (base 2) logarithm of `x`, rounded to a representable
|
||||
/// value.
|
||||
///
|
||||
/// - SeeAlso: `binaryLogarithm()`
|
||||
@_transparent // @_inlineable
|
||||
public static func log2(_ x: Self) -> Self {
|
||||
return x.binaryLogarithm()
|
||||
}
|
||||
|
||||
/// Returns the common (base 10) logarithm of `x`, rounded to a representable
|
||||
/// value.
|
||||
///
|
||||
/// - SeeAlso: `commonLogarithm()`
|
||||
@_transparent // @_inlineable
|
||||
public static func log10(_ x: Self) -> Self {
|
||||
return x.commonLogarithm()
|
||||
}
|
||||
|
||||
/// Returns the natural (base _e_) logarithm of the result of adding one to
|
||||
/// `x`, rounded to a representable value.
|
||||
///
|
||||
/// - SeeAlso: `naturalLogarithmOfOnePlus()`
|
||||
@_transparent // @_inlineable
|
||||
public static func log1p(_ x: Self) -> Self {
|
||||
return x.naturalLogarithmOnePlus()
|
||||
}
|
||||
|
||||
/// Returns the square root of `x`, rounded to a representable value.
|
||||
///
|
||||
/// - SeeAlso: `squareRoot()`
|
||||
@_transparent // @_inlineable
|
||||
public static func sqrt(_ x: Self) -> Self {
|
||||
return x.squareRoot()
|
||||
}
|
||||
|
||||
/// Returns the cube root of `x`, rounded to a representable value.
|
||||
///
|
||||
/// - SeeAlso: `cubeRoot()`
|
||||
@_transparent // @_inlineable
|
||||
public static func cbrt(_ x: Self) -> Self {
|
||||
return x.cubeRoot()
|
||||
}
|
||||
|
||||
/// Returns the result of raising `base` to the power of `exponent`, rounded
|
||||
/// to a representable value.
|
||||
///
|
||||
/// - SeeAlso: `power(of:)`
|
||||
@_transparent // @_inlineable
|
||||
public static func pow(_ base: Self, _ exponent: Self) -> Self {
|
||||
return exponent.power(of: base)
|
||||
}
|
||||
|
||||
/// Returns the sine of `x` (given in radians), rounded to a representable
|
||||
/// value.
|
||||
///
|
||||
/// - SeeAlso: `sine()`
|
||||
@_transparent // @_inlineable
|
||||
public static func sin(_ x: Self) -> Self {
|
||||
return x.sine()
|
||||
}
|
||||
|
||||
/// Returns the cosine of `x` (given in radians), rounded to a representable
|
||||
/// value.
|
||||
///
|
||||
/// - SeeAlso: `cosine()`
|
||||
@_transparent // @_inlineable
|
||||
public static func cos(_ x: Self) -> Self {
|
||||
return x.cosine()
|
||||
}
|
||||
|
||||
/// Returns the tangent of `x` (given in radians), rounded to a representable
|
||||
/// value.
|
||||
///
|
||||
/// - SeeAlso: `tangent()`
|
||||
@_transparent // @_inlineable
|
||||
public static func tan(_ x: Self) -> Self {
|
||||
return x.tangent()
|
||||
}
|
||||
|
||||
/// Returns the principal value of the inverse sine of `x`, rounded to a
|
||||
/// representable value.
|
||||
///
|
||||
/// - SeeAlso: `inverseSine()`
|
||||
@_transparent // @_inlineable
|
||||
public static func asin(_ x: Self) -> Self {
|
||||
return x.inverseSine()
|
||||
}
|
||||
|
||||
/// Returns the principal value of the inverse cosine of `x`, rounded to a
|
||||
/// representable value.
|
||||
///
|
||||
/// - SeeAlso: `inverseCosine()`
|
||||
@_transparent // @_inlineable
|
||||
public static func acos(_ x: Self) -> Self {
|
||||
return x.inverseCosine()
|
||||
}
|
||||
|
||||
/// Returns the principal value of the inverse tangent of `x`, rounded to a
|
||||
/// representable value.
|
||||
///
|
||||
/// - SeeAlso: `inverseTangent()`
|
||||
@_transparent // @_inlineable
|
||||
public static func atan(_ x: Self) -> Self {
|
||||
return x.inverseTangent()
|
||||
}
|
||||
|
||||
/// Returns the hyperbolic sine of `x`, rounded to a representable value.
|
||||
///
|
||||
/// - SeeAlso: `hyperbolicSine()`
|
||||
@_transparent // @_inlineable
|
||||
public static func sinh(_ x: Self) -> Self {
|
||||
return x.hyperbolicSine()
|
||||
}
|
||||
|
||||
/// Returns the hyperbolic cosine of `x`, rounded to a representable value.
|
||||
///
|
||||
/// - SeeAlso: `hyperbolicCosine()`
|
||||
@_transparent // @_inlineable
|
||||
public static func cosh(_ x: Self) -> Self {
|
||||
return x.hyperbolicCosine()
|
||||
}
|
||||
|
||||
/// Returns the hyperbolic tangent of `x`, rounded to a representable value.
|
||||
///
|
||||
/// - SeeAlso: `hyperbolicTangent()`
|
||||
@_transparent // @_inlineable
|
||||
public static func tanh(_ x: Self) -> Self {
|
||||
return x.hyperbolicTangent()
|
||||
}
|
||||
|
||||
/// Returns the principal value of the inverse hyperbolic sine of `x`, rounded
|
||||
/// to a representable value.
|
||||
///
|
||||
/// - SeeAlso: `inverseHyperbolicSine()`
|
||||
@_transparent // @_inlineable
|
||||
public static func asinh(_ x: Self) -> Self {
|
||||
return x.inverseHyperbolicSine()
|
||||
}
|
||||
|
||||
/// Returns the principal value of the inverse hyperbolic cosine of `x`,
|
||||
/// rounded to a representable value.
|
||||
///
|
||||
/// - SeeAlso: `inverseHyperbolicCosine()`
|
||||
@_transparent // @_inlineable
|
||||
public static func acosh(_ x: Self) -> Self {
|
||||
return x.inverseHyperbolicCosine()
|
||||
}
|
||||
|
||||
/// Returns the principal value of the inverse hyperbolic tangent of `x`,
|
||||
/// rounded to a representable value.
|
||||
///
|
||||
/// - SeeAlso: `inverseHyperbolicTangent()`
|
||||
@_transparent // @_inlineable
|
||||
public static func atanh(_ x: Self) -> Self {
|
||||
return x.inverseHyperbolicTangent()
|
||||
}
|
||||
}
|
|
@ -1,460 +0,0 @@
|
|||
//
|
||||
// PRNG.swift
|
||||
// NumericAnnex
|
||||
//
|
||||
// Created by Xiaodi Wu on 5/15/17.
|
||||
//
|
||||
|
||||
#if os(Linux)
|
||||
import Glibc
|
||||
#else
|
||||
import Security
|
||||
#endif
|
||||
|
||||
/// A pseudo-random number generator.
|
||||
public protocol PRNG : class, IteratorProtocol, Sequence
|
||||
where Element : FixedWidthInteger & UnsignedInteger, SubSequence : Sequence,
|
||||
/* Element == Iterator.Element, Element == SubSequence.Iterator.Element, */
|
||||
Element == SubSequence.Element {
|
||||
/// A type that can represent the internal state of the pseudo-random number
|
||||
/// generator.
|
||||
associatedtype State
|
||||
|
||||
/// The maximum value that may be generated by the pseudo-random number
|
||||
/// generator.
|
||||
static var max: Element { get }
|
||||
|
||||
/// The minimum value that may be generated by the pseudo-random number
|
||||
/// generator.
|
||||
static var min: Element { get }
|
||||
|
||||
/// The internal state of the pseudo-random number generator.
|
||||
var state: State { get set }
|
||||
|
||||
/// Creates a pseudo-random number generator with the given internal state.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - state: The value to be used as the generator's internal state.
|
||||
init(state: State)
|
||||
|
||||
/// Creates a pseudo-random number generator with an internal state seeded
|
||||
/// using cryptographically secure random bytes.
|
||||
///
|
||||
/// If cryptographically secure random bytes are unavailable, the result is
|
||||
/// `nil`.
|
||||
init?()
|
||||
}
|
||||
|
||||
extension PRNG {
|
||||
public static var max: Element { return Element.max }
|
||||
|
||||
public static var min: Element { return Element.min }
|
||||
|
||||
/// The number of pseudo-random bits available from a value generated by the
|
||||
/// pseudo-random number generator.
|
||||
public static var _randomBitWidth: Int {
|
||||
let difference = Self.max - Self.min
|
||||
guard difference < Element.max else { return Element.bitWidth }
|
||||
return Element.bitWidth - (difference + 1).leadingZeroBitCount - 1
|
||||
}
|
||||
|
||||
/// Returns a value filled with data from a source of cryptographically secure
|
||||
/// random bytes, or `nil` if a sufficient number of cryptographically secure
|
||||
/// random bytes is unavailable.
|
||||
public static func _entropy<
|
||||
T : FixedWidthInteger & UnsignedInteger
|
||||
>(_: T.Type = T.self) -> T? {
|
||||
let size = MemoryLayout<T>.size
|
||||
var value = T()
|
||||
#if os(Linux)
|
||||
// Read from `urandom`.
|
||||
// https://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers/
|
||||
guard let file = fopen("/dev/urandom", "rb") else { return nil }
|
||||
defer { fclose(file) }
|
||||
let read = fread(&value, size, 1, file)
|
||||
guard read == 1 else { return nil }
|
||||
#else
|
||||
// Sandboxing can make `urandom` unavailable.
|
||||
let result = withUnsafeMutableBytes(of: &value) { ptr -> Int32 in
|
||||
let bytes = ptr.baseAddress!.bindMemory(to: UInt8.self, capacity: size)
|
||||
defer { ptr.baseAddress!.bindMemory(to: T.self, capacity: 1) }
|
||||
return SecRandomCopyBytes(nil, size, bytes)
|
||||
}
|
||||
guard result == errSecSuccess else { return nil }
|
||||
#endif
|
||||
return value
|
||||
}
|
||||
|
||||
/// Returns an array of `count` values filled with data from a source of
|
||||
/// cryptographically secure random bytes, or `nil` if a sufficient number of
|
||||
/// cryptographically secure random bytes is unavailable.
|
||||
public static func _entropy<
|
||||
T : FixedWidthInteger & UnsignedInteger
|
||||
>(_: T.Type = T.self, count: Int) -> [T]? {
|
||||
let stride = MemoryLayout<T>.stride
|
||||
var value = [T](repeating: 0, count: count)
|
||||
#if os(Linux)
|
||||
guard let file = fopen("/dev/urandom", "rb") else { return nil }
|
||||
defer { fclose(file) }
|
||||
let read = fread(&value, stride, count, file)
|
||||
guard read == count else { return nil }
|
||||
#else
|
||||
let result = value.withUnsafeMutableBytes { ptr -> Int32 in
|
||||
let n = stride * count
|
||||
let bytes = ptr.baseAddress!.bindMemory(to: UInt8.self, capacity: n)
|
||||
defer { ptr.baseAddress!.bindMemory(to: T.self, capacity: count) }
|
||||
return SecRandomCopyBytes(nil, n, bytes)
|
||||
}
|
||||
guard result == errSecSuccess else { return nil }
|
||||
#endif
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
extension PRNG {
|
||||
/// Generates a pseudo-random unsigned integer of type `T` in the range from 0
|
||||
/// to `2 ** min(bitCount, T.bitWidth)` (exclusive), where `**` is the
|
||||
/// exponentiation operator.
|
||||
public func _random<T : FixedWidthInteger & UnsignedInteger>(
|
||||
_: T.Type = T.self, bitCount: Int = T.bitWidth
|
||||
) -> T {
|
||||
let randomBitWidth = Self._randomBitWidth
|
||||
let bitCount = Swift.min(bitCount, T.bitWidth)
|
||||
if T.bitWidth == Element.bitWidth &&
|
||||
randomBitWidth == Element.bitWidth &&
|
||||
bitCount == T.bitWidth {
|
||||
// It is an awkward way of spelling `next()`, but it is necessary.
|
||||
guard let next = first(where: { _ in true }) else { fatalError() }
|
||||
return T(extendingOrTruncating: next)
|
||||
}
|
||||
|
||||
let (quotient, remainder) =
|
||||
bitCount.quotientAndRemainder(dividingBy: randomBitWidth)
|
||||
let max = (Element.max &>> (Element.bitWidth - randomBitWidth)) + Self.min
|
||||
var temporary = 0 as T
|
||||
// Call `next()` at least `quotient` times.
|
||||
for i in 0..<quotient {
|
||||
guard let next = first(where: { $0 <= max }) else { fatalError() }
|
||||
temporary +=
|
||||
T(extendingOrTruncating: next) &<< (randomBitWidth * i)
|
||||
}
|
||||
// If `remainder != 0`, call `next()` at least one more time.
|
||||
if remainder != 0 {
|
||||
guard let next = first(where: { $0 <= max }) else { fatalError() }
|
||||
let mask = Element.max &>> (Element.bitWidth - remainder)
|
||||
temporary +=
|
||||
T(extendingOrTruncating: next & mask) &<< (randomBitWidth * quotient)
|
||||
}
|
||||
return temporary
|
||||
}
|
||||
|
||||
/// Generates a pseudo-random unsigned integer of type `T` in the range from
|
||||
/// `a` through `b` (inclusive) from the discrete uniform distribution.
|
||||
public func uniform<T : FixedWidthInteger & UnsignedInteger>(
|
||||
_: T.Type = T.self, a: T, b: T
|
||||
) -> T {
|
||||
precondition(
|
||||
b >= a,
|
||||
"Discrete uniform distribution parameter b should not be less than a"
|
||||
)
|
||||
guard a != b else { return a }
|
||||
|
||||
let difference = b - a
|
||||
guard difference < T.max else {
|
||||
return _random() + a
|
||||
}
|
||||
let bitCount = T.bitWidth - difference.leadingZeroBitCount
|
||||
var temporary: T
|
||||
repeat {
|
||||
temporary = _random(bitCount: bitCount)
|
||||
} while temporary > difference
|
||||
return temporary + a
|
||||
}
|
||||
|
||||
/// Generates a pseudo-random unsigned integer of type `T` in the range from
|
||||
/// `T.min` through `T.max` (inclusive) from the discrete uniform
|
||||
/// distribution.
|
||||
@_transparent // @_inlineable
|
||||
public func uniform<T : FixedWidthInteger & UnsignedInteger>(
|
||||
_: T.Type = T.self
|
||||
) -> T {
|
||||
return uniform(a: T.min, b: T.max)
|
||||
}
|
||||
|
||||
/// Generates a sequence of `count` pseudo-random unsigned integers of type
|
||||
/// `T` in the range from `a` through `b` (inclusive) from the discrete
|
||||
/// uniform distribution.
|
||||
@_transparent // @_inlineable
|
||||
public func uniform<T : FixedWidthInteger & UnsignedInteger>(
|
||||
_: T.Type = T.self, a: T, b: T, count: Int
|
||||
) -> UnfoldSequence<T, Int> {
|
||||
precondition(count >= 0, "Element count should be non-negative")
|
||||
return sequence(state: 0) { (state: inout Int) -> T? in
|
||||
state += 1
|
||||
return state > count ? nil : self.uniform(a: a, b: b)
|
||||
}
|
||||
}
|
||||
|
||||
/// Generates a sequence of `count` pseudo-random unsigned integers of type
|
||||
/// `T` in the range from `T.min` through `T.max` (inclusive) from the
|
||||
/// discrete uniform distribution.
|
||||
@_transparent // @_inlineable
|
||||
public func uniform<T : FixedWidthInteger & UnsignedInteger>(
|
||||
_: T.Type = T.self, count: Int
|
||||
) -> UnfoldSequence<T, Int> {
|
||||
return uniform(a: T.min, b: T.max, count: count)
|
||||
}
|
||||
|
||||
/// Generates a pseudo-random signed integer of type `T` in the range from `a`
|
||||
/// through `b` (inclusive) from the discrete uniform distribution.
|
||||
public func uniform<T : FixedWidthInteger & SignedInteger>(
|
||||
_: T.Type = T.self, a: T, b: T
|
||||
) -> T where T.Magnitude : FixedWidthInteger & UnsignedInteger {
|
||||
precondition(
|
||||
b >= a,
|
||||
"Discrete uniform distribution parameter b should not be less than a"
|
||||
)
|
||||
guard a != b else { return a }
|
||||
|
||||
let test = a.signum() < 0
|
||||
let difference = test
|
||||
? (b.signum() < 0 ? a.magnitude - b.magnitude : b.magnitude + a.magnitude)
|
||||
: b.magnitude - a.magnitude
|
||||
guard difference < T.Magnitude.max else {
|
||||
return test ? T(_random() - a.magnitude) : T(_random() + a.magnitude)
|
||||
}
|
||||
let bitCount = T.Magnitude.bitWidth - difference.leadingZeroBitCount
|
||||
var temporary: T.Magnitude
|
||||
repeat {
|
||||
temporary = _random(bitCount: bitCount)
|
||||
} while temporary > difference
|
||||
return test ? T(temporary - a.magnitude) : T(temporary + a.magnitude)
|
||||
}
|
||||
|
||||
/// Generates a pseudo-random signed integer of type `T` in the range from
|
||||
/// `T.min` through `T.max` (inclusive) from the discrete uniform
|
||||
/// distribution.
|
||||
@_transparent // @_inlineable
|
||||
public func uniform<T : FixedWidthInteger & SignedInteger>(
|
||||
_: T.Type = T.self
|
||||
) -> T where T.Magnitude : FixedWidthInteger & UnsignedInteger {
|
||||
return uniform(a: T.min, b: T.max)
|
||||
}
|
||||
|
||||
/// Generates a sequence of `count` pseudo-random signed integers of type `T`
|
||||
/// in the range from `a` through `b` (inclusive) from the discrete uniform
|
||||
/// distribution.
|
||||
@_transparent // @_inlineable
|
||||
public func uniform<T : FixedWidthInteger & SignedInteger>(
|
||||
_: T.Type = T.self, a: T, b: T, count: Int
|
||||
) -> UnfoldSequence<T, Int>
|
||||
where T.Magnitude : FixedWidthInteger & UnsignedInteger {
|
||||
precondition(count >= 0, "Element count should be non-negative")
|
||||
return sequence(state: 0) { (state: inout Int) -> T? in
|
||||
state += 1
|
||||
return state > count ? nil : self.uniform(a: a, b: b)
|
||||
}
|
||||
}
|
||||
|
||||
/// Generates a sequence of `count` pseudo-random signed integers of type `T`
|
||||
/// in the range from `T.min` through `T.max` (inclusive) from the discrete
|
||||
/// uniform distribution.
|
||||
@_transparent // @_inlineable
|
||||
public func uniform<T : FixedWidthInteger & SignedInteger>(
|
||||
_: T.Type = T.self, count: Int
|
||||
) -> UnfoldSequence<T, Int>
|
||||
where T.Magnitude : FixedWidthInteger & UnsignedInteger {
|
||||
return uniform(a: T.min, b: T.max, count: count)
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: If `FloatingPoint.init(_: FixedWidthInteger)` is added
|
||||
// then it becomes possible to remove the constraint `Element == UInt64`.
|
||||
extension PRNG where Element == UInt64 {
|
||||
/// Generates a pseudo-random binary floating-point value of type `T` in the
|
||||
/// range from 0 to 1 (exclusive) with `min(bitCount, T.significandBitCount)`
|
||||
/// bits of precision.
|
||||
public func _random<T : BinaryFloatingPoint>(
|
||||
_: T.Type = T.self, bitCount: Int = T.significandBitCount
|
||||
) -> T {
|
||||
let bitCount = Swift.min(bitCount, T.significandBitCount)
|
||||
let (quotient, remainder) =
|
||||
bitCount.quotientAndRemainder(dividingBy: Self._randomBitWidth)
|
||||
let k = Swift.max(1, remainder == 0 ? quotient : quotient + 1)
|
||||
let step = T(Self.max - Self.min)
|
||||
let initial = (0 as T, 1 as T)
|
||||
// Call `next()` exactly `k` times.
|
||||
let (dividend, divisor) = prefix(k).reduce(initial) { partial, next in
|
||||
let x = partial.0 + T(next - Self.min) * partial.1
|
||||
let y = partial.1 + step * partial.1
|
||||
return (x, y)
|
||||
}
|
||||
return dividend / divisor
|
||||
}
|
||||
|
||||
/// Generates a pseudo-random binary floating-point value of type `T` in the
|
||||
/// range from `a` to `b` (exclusive) from the uniform distribution.
|
||||
public func uniform<T : BinaryFloatingPoint>(
|
||||
_: T.Type = T.self, a: T, b: T
|
||||
) -> T {
|
||||
precondition(
|
||||
b > a,
|
||||
"Uniform distribution parameter b should be greater than a"
|
||||
)
|
||||
var temporary: T
|
||||
repeat {
|
||||
temporary = (b - a) * _random() + a
|
||||
} while temporary == b
|
||||
return temporary
|
||||
}
|
||||
|
||||
/// Generates a pseudo-random binary floating-point value of type `T` in the
|
||||
/// range from 0 to 1 (exclusive) from the uniform distribution.
|
||||
@_transparent // @_inlineable
|
||||
public func uniform<T : BinaryFloatingPoint>(_: T.Type = T.self) -> T {
|
||||
return uniform(a: 0, b: 1)
|
||||
}
|
||||
|
||||
/// Generates a sequence of `count` pseudo-random binary floating-point values
|
||||
/// of type `T` in the range from `a` to `b` (exclusive) from the uniform
|
||||
/// distribution.
|
||||
@_transparent // @_inlineable
|
||||
public func uniform<T : BinaryFloatingPoint>(
|
||||
_: T.Type = T.self, a: T, b: T, count: Int
|
||||
) -> UnfoldSequence<T, Int> {
|
||||
precondition(count >= 0, "Element count should be non-negative")
|
||||
return sequence(state: 0) { (state: inout Int) -> T? in
|
||||
state += 1
|
||||
return state > count ? nil : self.uniform(a: a, b: b)
|
||||
}
|
||||
}
|
||||
|
||||
/// Generates a sequence of `count` pseudo-random binary floating-point values
|
||||
/// of type `T` in the range from 0 to 1 (exclusive) from the uniform
|
||||
/// distribution.
|
||||
@_transparent // @_inlineable
|
||||
public func uniform<T : BinaryFloatingPoint>(
|
||||
_: T.Type = T.self, count: Int
|
||||
) -> UnfoldSequence<T, Int> {
|
||||
return uniform(a: 0, b: 1, count: count)
|
||||
}
|
||||
}
|
||||
|
||||
#if false
|
||||
extension PRNG where Element == UInt64 {
|
||||
public func bernoulli<T : BinaryFloatingPoint>(
|
||||
_: Bool.Type = Bool.self, p: T
|
||||
) -> Bool {
|
||||
precondition(
|
||||
p >= 0 && p <= 1,
|
||||
"Bernoulli distribution parameter p should be between zero and one"
|
||||
)
|
||||
var temporary: T
|
||||
repeat {
|
||||
temporary = _random()
|
||||
} while temporary == 1
|
||||
return temporary < p
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func bernoulli(_: Bool.Type = Bool.self) -> Bool {
|
||||
return bernoulli(p: 0.5)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func bernoulli<T : BinaryFloatingPoint>(
|
||||
_: Bool.Type = Bool.self, p: T, count: Int
|
||||
) -> UnfoldSequence<Bool, Int> {
|
||||
precondition(count >= 0, "Element count should be non-negative")
|
||||
return sequence(state: 0) { (state: inout Int) -> Bool? in
|
||||
state += 1
|
||||
return state > count ? nil : self.bernoulli(p: p)
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func bernoulli(
|
||||
_: Bool.Type = Bool.self, count: Int
|
||||
) -> UnfoldSequence<Bool, Int> {
|
||||
return bernoulli(p: 0.5, count: count)
|
||||
}
|
||||
|
||||
public func exponential<T : BinaryFloatingPoint & FloatingPointMath>(
|
||||
_: T.Type = T.self, lambda: T
|
||||
) -> T {
|
||||
precondition(
|
||||
lambda > 0 && lambda < .infinity,
|
||||
"Exponential distribution parameter lambda should be positive and finite"
|
||||
)
|
||||
var temporary: T
|
||||
repeat {
|
||||
temporary = -.log(1 - _random()) / lambda
|
||||
} while temporary == .infinity
|
||||
return temporary
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func exponential<T : BinaryFloatingPoint & FloatingPointMath>(
|
||||
_: T.Type = T.self
|
||||
) -> T {
|
||||
return exponential(lambda: 1)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func exponential<T : BinaryFloatingPoint & FloatingPointMath>(
|
||||
_: T.Type = T.self, lambda: T, count: Int
|
||||
) -> UnfoldSequence<T, Int> {
|
||||
precondition(count >= 0, "Element count should be non-negative")
|
||||
return sequence(state: 0) { (state: inout Int) -> T? in
|
||||
state += 1
|
||||
return state > count ? nil : self.exponential(lambda: lambda)
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func exponential<T : BinaryFloatingPoint & FloatingPointMath>(
|
||||
_: T.Type = T.self, count: Int
|
||||
) -> UnfoldSequence<T, Int> {
|
||||
return exponential(lambda: 1, count: count)
|
||||
}
|
||||
|
||||
public func weibull<T : BinaryFloatingPoint & FloatingPointMath>(
|
||||
_: T.Type = T.self, lambda: T, kappa: T
|
||||
) -> T {
|
||||
precondition(
|
||||
lambda > 0 && lambda < .infinity && kappa > 0 && kappa < .infinity,
|
||||
"Weibull distribution parameters should be positive and finite"
|
||||
)
|
||||
var temporary: T
|
||||
repeat {
|
||||
temporary = lambda * .pow(-.log(1 - _random()), 1 / kappa)
|
||||
} while temporary == .infinity
|
||||
return temporary
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func weibull<T : BinaryFloatingPoint & FloatingPointMath>(
|
||||
_: T.Type = T.self
|
||||
) -> T {
|
||||
return weibull(lambda: 1, kappa: 1)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func weibull<T : BinaryFloatingPoint & FloatingPointMath>(
|
||||
_: T.Type = T.self, lambda: T, kappa: T, count: Int
|
||||
) -> UnfoldSequence<T, Int> {
|
||||
precondition(count >= 0, "Element count should be non-negative")
|
||||
return sequence(state: 0) { (state: inout Int) -> T? in
|
||||
state += 1
|
||||
return state > count ? nil : self.weibull(lambda: lambda, kappa: kappa)
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func weibull<T : BinaryFloatingPoint & FloatingPointMath>(
|
||||
_: T.Type = T.self, count: Int
|
||||
) -> UnfoldSequence<T, Int> {
|
||||
return weibull(lambda: 1, kappa: 1, count: count)
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -1,43 +0,0 @@
|
|||
//
|
||||
// Random.Xoroshiro.swift
|
||||
// NumericAnnex
|
||||
//
|
||||
// Created by Xiaodi Wu on 5/16/17.
|
||||
//
|
||||
|
||||
extension Random {
|
||||
/// A pseudo-random number generator that implements [`xoroshiro128+`], a
|
||||
/// successor to `xorshift128+` devised by S. Vigna and D. Blackman.
|
||||
public final class Xoroshiro : PRNG {
|
||||
public var state: (UInt64, UInt64)
|
||||
|
||||
// TODO: Document this function.
|
||||
// @_versioned
|
||||
internal static func _rotl(_ value: UInt64, _ count: Int) -> UInt64 {
|
||||
return (value &<< count) | (value &>> (64 &- count))
|
||||
}
|
||||
|
||||
public func next() -> UInt64? {
|
||||
let x = state.0
|
||||
var y = state.1
|
||||
let result = x &+ y
|
||||
y ^= x
|
||||
state.0 = Xoroshiro._rotl(x, 55) ^ y ^ (y &<< 14)
|
||||
state.1 = Xoroshiro._rotl(y, 36)
|
||||
return result
|
||||
}
|
||||
|
||||
public init(state: (UInt64, UInt64)) {
|
||||
self.state = state
|
||||
}
|
||||
|
||||
public init?() {
|
||||
repeat {
|
||||
guard let entropy = Xoroshiro._entropy(UInt64.self, count: 2) else {
|
||||
return nil
|
||||
}
|
||||
self.state = (entropy[0], entropy[1])
|
||||
} while self.state == (0, 0)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
//
|
||||
// Random.swift
|
||||
// NumericAnnex
|
||||
//
|
||||
// Created by Xiaodi Wu on 5/13/17.
|
||||
//
|
||||
|
||||
/// A pseudo-random number generator that implements [`xorshift128+`][ref], an
|
||||
/// efficient linear-feedback shift register.
|
||||
///
|
||||
/// [ref]: http://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf
|
||||
public final class Random : PRNG {
|
||||
public var state: (UInt64, UInt64)
|
||||
|
||||
public func next() -> UInt64? {
|
||||
#if true
|
||||
// An updated version of xorshift128+.
|
||||
//
|
||||
// This version adds the two halves of the current state, which allows for
|
||||
// better parallelization.
|
||||
var x = state.0
|
||||
let y = state.1
|
||||
let result = x &+ y
|
||||
state.0 = y
|
||||
x ^= x &<< 23
|
||||
state.1 = x ^ y ^ (x &>> 18) ^ (y &>> 5)
|
||||
return result
|
||||
#else
|
||||
// A previous version of xorshift128+.
|
||||
var x = state.0
|
||||
let y = state.1
|
||||
state.0 = y
|
||||
x ^= x &<< 23
|
||||
state.1 = x ^ y ^ (x &>> 17) ^ (y &>> 26)
|
||||
return state.1 &+ y
|
||||
#endif
|
||||
}
|
||||
|
||||
public init(state: (UInt64, UInt64)) {
|
||||
self.state = state
|
||||
}
|
||||
|
||||
public init?() {
|
||||
repeat {
|
||||
guard let entropy = Random._entropy(UInt64.self, count: 2) else {
|
||||
return nil
|
||||
}
|
||||
self.state = (entropy[0], entropy[1])
|
||||
} while self.state == (0, 0)
|
||||
}
|
||||
}
|
|
@ -1,268 +0,0 @@
|
|||
//
|
||||
// Rational+SignedNumeric.swift
|
||||
// NumericAnnex
|
||||
//
|
||||
// Created by Xiaodi Wu on 4/15/17.
|
||||
//
|
||||
|
||||
extension Rational : Numeric {
|
||||
// @_transparent // @_inlineable
|
||||
public init?<U>(exactly source: U) where U : BinaryInteger {
|
||||
guard let t = T(exactly: source) else { return nil }
|
||||
// Ensure that `t.magnitude` is representable as a `T`.
|
||||
guard let _ = T(exactly: t.magnitude) else { return nil }
|
||||
self.numerator = t
|
||||
self.denominator = 1
|
||||
}
|
||||
|
||||
// @_transparent // @_inlineable
|
||||
public static func + (lhs: Rational, rhs: Rational) -> Rational {
|
||||
if lhs.denominator == 0 {
|
||||
if rhs.denominator != 0 || lhs.numerator == 0 { return lhs }
|
||||
if lhs.numerator > 0 { return rhs.numerator < 0 ? .nan : rhs }
|
||||
return rhs.numerator > 0 ? .nan : rhs
|
||||
}
|
||||
if rhs.denominator == 0 { return rhs }
|
||||
|
||||
let ldm = lhs.denominator.magnitude
|
||||
let rdm = rhs.denominator.magnitude
|
||||
let gcd = T.Magnitude.gcd(ldm, rdm)
|
||||
let a = T(rdm / gcd * lhs.numerator.magnitude)
|
||||
let b = T(ldm / gcd * rhs.numerator.magnitude)
|
||||
let n = lhs.sign == .plus
|
||||
? (rhs.sign == .plus ? a + b : a - b)
|
||||
: (rhs.sign == .plus ? b - a : -a - b)
|
||||
let d = T(ldm / gcd * rdm)
|
||||
return Rational(numerator: n, denominator: d).canonical
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public static func += (lhs: inout Rational, rhs: Rational) {
|
||||
lhs = lhs + rhs
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public static func - (lhs: Rational, rhs: Rational) -> Rational {
|
||||
return lhs + (-rhs)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public static func -= (lhs: inout Rational, rhs: Rational) {
|
||||
lhs = lhs + (-rhs)
|
||||
}
|
||||
|
||||
// @_transparent // @_inlineable
|
||||
public static func * (lhs: Rational, rhs: Rational) -> Rational {
|
||||
if lhs.denominator == 0 {
|
||||
if rhs.numerator == 0 { return .nan }
|
||||
return rhs.sign == .plus ? lhs : -lhs
|
||||
}
|
||||
if rhs.denominator == 0 {
|
||||
if lhs.numerator == 0 { return .nan }
|
||||
return lhs.sign == .plus ? rhs : -rhs
|
||||
}
|
||||
|
||||
let lnm = lhs.numerator.magnitude, ldm = lhs.denominator.magnitude
|
||||
let rnm = rhs.numerator.magnitude, rdm = rhs.denominator.magnitude
|
||||
// Note that if `T` is a signed fixed-width integer type, `gcd(lnm, rdm)` or
|
||||
// `gcd(rnm, ldm)` could be equal to `-T.min`, which is not representable as
|
||||
// a `T`. This is why the following arithmetic is performed with values of
|
||||
// type `T.Magnitude`.
|
||||
let a = T.Magnitude.gcd(lnm, rdm)
|
||||
let b = T.Magnitude.gcd(rnm, ldm)
|
||||
let n = lhs.sign == rhs.sign
|
||||
? T(lnm / a * (rnm / b))
|
||||
: -T(lnm / a * (rnm / b))
|
||||
let d = T(ldm / b * (rdm / a))
|
||||
return Rational(numerator: n, denominator: d)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public static func *= (lhs: inout Rational, rhs: Rational) {
|
||||
lhs = lhs * rhs
|
||||
}
|
||||
}
|
||||
|
||||
extension BinaryInteger {
|
||||
/// Creates a new binary integer from the given rational value, if it can be
|
||||
/// represented exactly.
|
||||
///
|
||||
/// If `source` is not representable exactly, the result is `nil`.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - source: A rational value to convert to a binary integer.
|
||||
@_transparent // @_inlineable
|
||||
public init?<U>(exactly source: Rational<U>) {
|
||||
let (whole, fraction) = source.mixed
|
||||
guard fraction.isZero, let exact = Self(exactly: whole) else { return nil }
|
||||
self = exact
|
||||
}
|
||||
|
||||
/// Creates a new binary integer from the given rational value, truncating any
|
||||
/// fractional part.
|
||||
///
|
||||
/// If `source` is outside the bounds of this type after truncation, a runtime
|
||||
/// error may occur.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - source: A rational value to convert to a binary integer.
|
||||
@_transparent // @_inlineable
|
||||
public init<U>(_ source: Rational<U>) {
|
||||
self = Self(source.mixed.whole)
|
||||
}
|
||||
}
|
||||
|
||||
extension Rational : SignedNumeric {
|
||||
@_transparent // @_inlineable
|
||||
public static prefix func - (operand: Rational) -> Rational {
|
||||
return Rational(
|
||||
numerator: -operand.numerator, denominator: operand.denominator
|
||||
)
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public mutating func negate() {
|
||||
numerator.negate()
|
||||
}
|
||||
}
|
||||
|
||||
extension Rational {
|
||||
/// Returns the quotient obtained by dividing the first value by the second,
|
||||
/// trapping in case of arithmetic overflow.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - lhs: The value to divide.
|
||||
/// - rhs: The value by which to divide `lhs`.
|
||||
@_transparent // @_inlineable
|
||||
public static func / (lhs: Rational, rhs: Rational) -> Rational {
|
||||
return lhs * rhs.reciprocal()
|
||||
}
|
||||
|
||||
/// Divides the left-hand side by the right-hand side and stores the quotient
|
||||
/// in the left-hand side, trapping in case of arithmetic overflow.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - lhs: The value to divide.
|
||||
/// - rhs: The value by which to divide `lhs`.
|
||||
@_transparent // @_inlineable
|
||||
public static func /= (lhs: inout Rational, rhs: Rational) {
|
||||
lhs = lhs * rhs.reciprocal()
|
||||
}
|
||||
|
||||
/// Returns this value rounded to an integral value using the specified
|
||||
/// rounding rule.
|
||||
///
|
||||
/// ```swift
|
||||
/// let x = 7 / 2 as Rational<Int>
|
||||
/// print(x.rounded()) // Prints "4"
|
||||
/// print(x.rounded(.towardZero)) // Prints "3"
|
||||
/// print(x.rounded(.up)) // Prints "4"
|
||||
/// print(x.rounded(.down)) // Prints "3"
|
||||
/// ```
|
||||
///
|
||||
/// See the `FloatingPointRoundingRule` enumeration for more information about
|
||||
/// the available rounding rules.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - rule: The rounding rule to use.
|
||||
///
|
||||
/// - SeeAlso: `round(_:)`, `FloatingPointRoundingRule`
|
||||
@_transparent // @_inlineable
|
||||
public func rounded(
|
||||
_ rule: RoundingRule = .toNearestOrAwayFromZero
|
||||
) -> Rational {
|
||||
var t = self
|
||||
t.round(rule)
|
||||
return t
|
||||
}
|
||||
|
||||
/// Rounds the value to an integral value using the specified rounding rule.
|
||||
///
|
||||
/// ```swift
|
||||
/// var x = 7 / 2 as Rational<Int>
|
||||
/// x.round() // x == 4
|
||||
///
|
||||
/// var x = 7 / 2 as Rational<Int>
|
||||
/// x.round(.towardZero) // x == 3
|
||||
///
|
||||
/// var x = 7 / 2 as Rational<Int>
|
||||
/// x.round(.up) // x == 4
|
||||
///
|
||||
/// var x = 7 / 2 as Rational<Int>
|
||||
/// x.round(.down) // x == 3
|
||||
/// ```
|
||||
///
|
||||
/// See the `FloatingPointRoundingRule` enumeration for more information about
|
||||
/// the available rounding rules.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - rule: The rounding rule to use.
|
||||
///
|
||||
/// - SeeAlso: `round(_:)`, `FloatingPointRoundingRule`
|
||||
@_transparent // @_inlineable
|
||||
public mutating func round(_ rule: RoundingRule = .toNearestOrAwayFromZero) {
|
||||
if denominator == 0 { return }
|
||||
|
||||
let f: T
|
||||
(numerator, f) = numerator.quotientAndRemainder(dividingBy: denominator)
|
||||
// Rounding rules only come into play if the fractional part is non-zero.
|
||||
if f != 0 {
|
||||
switch rule {
|
||||
case .toNearestOrAwayFromZero:
|
||||
fallthrough
|
||||
case .toNearestOrEven:
|
||||
switch denominator.magnitude.quotientAndRemainder(
|
||||
dividingBy: f.magnitude
|
||||
) {
|
||||
case (2, 0): // Tie.
|
||||
if rule == .toNearestOrEven && numerator % 2 == 0 { break }
|
||||
fallthrough
|
||||
case (1, _): // Nearest is away from zero.
|
||||
if f > 0 { numerator += 1 } else { numerator -= 1 }
|
||||
default: // Nearest is toward zero.
|
||||
break
|
||||
}
|
||||
case .up:
|
||||
if f > 0 { numerator += 1 }
|
||||
case .down:
|
||||
if f < 0 { numerator -= 1 }
|
||||
case .towardZero:
|
||||
break
|
||||
case .awayFromZero:
|
||||
if f > 0 { numerator += 1 } else { numerator -= 1 }
|
||||
}
|
||||
}
|
||||
denominator = 1
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the absolute value (magnitude) of `x`.
|
||||
@_transparent
|
||||
public func abs<T>(_ x: Rational<T>) -> Rational<T> {
|
||||
return x.magnitude
|
||||
}
|
||||
|
||||
/// Returns the closest integral value greater than or equal to `x`.
|
||||
@_transparent
|
||||
public func ceil<T>(_ x: Rational<T>) -> Rational<T> {
|
||||
return x.rounded(.up)
|
||||
}
|
||||
|
||||
/// Returns the closest integral value less than or equal to `x`.
|
||||
@_transparent
|
||||
public func floor<T>(_ x: Rational<T>) -> Rational<T> {
|
||||
return x.rounded(.down)
|
||||
}
|
||||
|
||||
/// Returns the closest integral value; if two values are equally close, returns
|
||||
/// the one with greater magnitude.
|
||||
@_transparent
|
||||
public func round<T>(_ x: Rational<T>) -> Rational<T> {
|
||||
return x.rounded()
|
||||
}
|
||||
|
||||
/// Returns the closest integral value with magnitude less than or equal to `x`.
|
||||
@_transparent
|
||||
public func trunc<T>(_ x: Rational<T>) -> Rational<T> {
|
||||
return x.rounded(.towardZero)
|
||||
}
|
|
@ -1,426 +0,0 @@
|
|||
//
|
||||
// Rational.swift
|
||||
// NumericAnnex
|
||||
//
|
||||
// Created by Xiaodi Wu on 4/15/17.
|
||||
//
|
||||
|
||||
/// A type to represent a rational value.
|
||||
///
|
||||
/// - Note: `Ratio` is a type alias for `Rational<Int>`.
|
||||
///
|
||||
/// Create new instances of `Rational<T>` by using integer literals and the
|
||||
/// division (`/`) operator. For example:
|
||||
///
|
||||
/// ```swift
|
||||
/// let x = 1 / 3 as Ratio // `x` is of type `Rational<Int>`
|
||||
/// let y = 2 as Ratio // `y` is of type `Rational<Int>`
|
||||
/// let z: Ratio = 2 / 3 // `z` is also of type `Rational<Int>`
|
||||
///
|
||||
/// print(x + y + z) // Prints "3"
|
||||
/// ```
|
||||
///
|
||||
/// You can create an unreduced fraction by using the initializer
|
||||
/// `Rational<T>.init(numerator:denominator:)`. For example:
|
||||
///
|
||||
/// ```swift
|
||||
/// let a = Ratio(numerator: 3, denominator: 3)
|
||||
/// print(a) // Prints "3/3"
|
||||
/// ```
|
||||
///
|
||||
/// All arithmetic operations with values in canonical form (i.e. reduced to
|
||||
/// lowest terms) return results in canonical form. However, operations with
|
||||
/// values not in canonical form may or may not return results that are
|
||||
/// themselves in canonical form. The property `canonicalized` is the canonical
|
||||
/// form of any value.
|
||||
///
|
||||
/// Additional Considerations
|
||||
/// =========================
|
||||
///
|
||||
/// Special Values
|
||||
/// --------------
|
||||
///
|
||||
/// `Rational<T>` does not prohibit zero as a denominator. Any instance with a
|
||||
/// positive numerator and zero denominator represents (positive) infinity; any
|
||||
/// instance with a negative numerator and zero denominator represents negative
|
||||
/// infinity; and any instance with zero numerator and zero denominator
|
||||
/// represents NaN ("not a number").
|
||||
///
|
||||
/// As with floating-point types, `Rational<T>.infinity` compares greater than
|
||||
/// every finite value and negative infinity, and `-Rational<T>.infinity`
|
||||
/// compares less than every finite value and positive infinity. Infinite values
|
||||
/// of the same sign compare equal to each other.
|
||||
///
|
||||
/// As with floating-point types, `Rational<T>.nan` does not compare equal to
|
||||
/// any other value, including another NaN. Use the property `isNaN` to test if
|
||||
/// a value is NaN. `Rational<T>` arithmetic operations are intended to
|
||||
/// propagate NaN in the same manner as analogous floating-point operations.
|
||||
///
|
||||
/// Fixed-Width Binary Parts
|
||||
/// ------------------------
|
||||
///
|
||||
/// When a value of type `Rational<T>` is in canonical form, the sign of the
|
||||
/// numerator is the sign of the value; that is, in canonical form, the sign of
|
||||
/// the denominator is always positive. Therefore, `-1 / T.min` cannot be
|
||||
/// represented as a value of type `Rational<T>` because `abs(T.min)` cannot be
|
||||
/// represented as a value of type `T`.
|
||||
///
|
||||
/// To ensure that every representable value of type `Rational<T>` has a
|
||||
/// representable magnitude and reciprocal of the same type, an overflow trap
|
||||
/// occurs when the division (`/`) operator is used to create a value of type
|
||||
/// `Rational<T>` with numerator `T.min`.
|
||||
@_fixed_layout
|
||||
public struct Rational<T : SignedInteger>
|
||||
where T : _ExpressibleByBuiltinIntegerLiteral, T.Magnitude : UnsignedInteger,
|
||||
T.Magnitude.Magnitude == T.Magnitude {
|
||||
/// The numerator of the rational value.
|
||||
public var numerator: T
|
||||
|
||||
/// The denominator of the rational value.
|
||||
public var denominator: T
|
||||
|
||||
/// Creates a new value from the given numerator and denominator without
|
||||
/// computing its canonical form (i.e., without reducing to lowest terms).
|
||||
///
|
||||
/// To create a value reduced to lowest terms, use the division (`/`)
|
||||
/// operator. For example:
|
||||
///
|
||||
/// ```swift
|
||||
/// let x = 3 / 3 as Rational<Int>
|
||||
/// print(x) // Prints "1"
|
||||
/// ```
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - numerator: The new value's numerator.
|
||||
/// - denominator: The new value's denominator.
|
||||
@_transparent // @_inlineable
|
||||
public init(numerator: T, denominator: T) {
|
||||
self.numerator = numerator
|
||||
self.denominator = denominator
|
||||
}
|
||||
|
||||
/// Positive infinity.
|
||||
///
|
||||
/// Infinity compares greater than all finite numbers and equal to other
|
||||
/// (positive) infinite values.
|
||||
@_transparent // @_inlineable
|
||||
public static var infinity: Rational {
|
||||
return Rational(numerator: 1, denominator: 0)
|
||||
}
|
||||
|
||||
/// A quiet NaN ("not a number").
|
||||
///
|
||||
/// A NaN compares not equal, not greater than, and not less than every value,
|
||||
/// including itself. Passing a NaN to an operation generally results in NaN.
|
||||
@_transparent // @_inlineable
|
||||
public static var nan: Rational {
|
||||
return Rational(numerator: 0, denominator: 0)
|
||||
}
|
||||
}
|
||||
|
||||
extension Rational {
|
||||
// TODO: Document this initializer.
|
||||
// @_transparent // @_inlineable
|
||||
public init<Source : BinaryInteger>(_ source: Source) {
|
||||
let t = T(source)
|
||||
// Ensure that `t.magnitude` is representable as a `T`.
|
||||
_ = T(t.magnitude)
|
||||
self.numerator = t
|
||||
self.denominator = 1
|
||||
}
|
||||
|
||||
// TODO: Document this initializer.
|
||||
// @_transparent // @_inlineable
|
||||
public init<Source : BinaryFloatingPoint>(_ source: Source) {
|
||||
if source.isNaN { self = .nan; return }
|
||||
if source == .infinity { self = .infinity; return }
|
||||
if source == -.infinity { self = -.infinity; return }
|
||||
if source.isZero { self = 0; return }
|
||||
|
||||
let exponent = source.exponent
|
||||
let significandWidth = source.significandWidth
|
||||
if significandWidth <= exponent {
|
||||
self.numerator = T(source)
|
||||
self.denominator = 1
|
||||
return
|
||||
}
|
||||
let shift = significandWidth - Int(exponent)
|
||||
let numerator = T(source * Source(1 &<< shift))
|
||||
// Ensure that `numerator.magnitude` is representable as a `T`.
|
||||
_ = T(numerator.magnitude)
|
||||
let denominator = T(1 &<< shift)
|
||||
// Ensure that `denominator.magnitude` is representable as a `T`.
|
||||
_ = T(denominator.magnitude)
|
||||
self.numerator = numerator
|
||||
self.denominator = denominator
|
||||
}
|
||||
}
|
||||
|
||||
extension Rational {
|
||||
/// Compares the (finite) magnitude of two finite values, returning -1 if
|
||||
/// `lhs.magnitude` is less than `rhs.magnitude`, 0 if `lhs.magnitude` is
|
||||
/// equal to `rhs.magnitude`, or 1 if `lhs.magnitude` is greater than
|
||||
/// `rhs.magnitude`.
|
||||
// @_versioned
|
||||
internal static func _compareFiniteMagnitude(
|
||||
_ lhs: Rational, _ rhs: Rational
|
||||
) -> Int {
|
||||
let ldm = lhs.denominator.magnitude
|
||||
let rdm = rhs.denominator.magnitude
|
||||
let gcd = T.Magnitude.gcd(ldm, rdm)
|
||||
let a = rdm / gcd * lhs.numerator.magnitude
|
||||
let b = ldm / gcd * rhs.numerator.magnitude
|
||||
return a == b ? 0 : (a < b ? -1 : 1)
|
||||
// FIXME: Use full-width multiplication to avoid trapping on overflow
|
||||
// where `T : FixedWidthInteger, T.Magnitude : FixedWidthInteger`.
|
||||
/*
|
||||
let a = (rdm / gcd).multipliedFullWidth(by: lhs.numerator.magnitude)
|
||||
let b = (ldm / gcd).multipliedFullWidth(by: rhs.numerator.magnitude)
|
||||
return a.high == b.high
|
||||
? (a.low == b.low ? 0 : (a.low < b.low ? -1 : 1))
|
||||
: (a.high < b.high ? -1 : 1)
|
||||
*/
|
||||
}
|
||||
|
||||
/// The canonical representation of this value.
|
||||
// @_transparent // @_inlineable
|
||||
public var canonical: Rational {
|
||||
let nm = numerator.magnitude, dm = denominator.magnitude
|
||||
// Note that if `T` is a signed fixed-width integer type, `gcd(nm, dm)`
|
||||
// could be equal to `-T.min`, which is not representable as a `T`. This is
|
||||
// why the following arithmetic is performed with values of type
|
||||
// `T.Magnitude`.
|
||||
let gcd = T.Magnitude.gcd(nm, dm)
|
||||
guard gcd != 0 else { return self }
|
||||
let n = sign == .plus ? T(nm / gcd) : -T(nm / gcd)
|
||||
let d = T(dm / gcd)
|
||||
return Rational(numerator: n, denominator: d)
|
||||
}
|
||||
|
||||
/// A Boolean value indicating whether the instance's representation is in
|
||||
/// canonical form.
|
||||
@_transparent // @_inlineable
|
||||
public var isCanonical: Bool {
|
||||
if denominator > 0 {
|
||||
return T.Magnitude.gcd(numerator.magnitude, denominator.magnitude) == 1
|
||||
}
|
||||
return denominator == 0 && numerator.magnitude <= 1
|
||||
}
|
||||
|
||||
/// A Boolean value indicating whether the instance is finite.
|
||||
///
|
||||
/// All values other than NaN and infinity are considered finite.
|
||||
@_transparent // @_inlineable
|
||||
public var isFinite: Bool {
|
||||
return denominator != 0
|
||||
}
|
||||
|
||||
/// A Boolean value indicating whether the instance is infinite.
|
||||
///
|
||||
/// Note that `isFinite` and `isInfinite` do not form a dichotomy because NaN
|
||||
/// is neither finite nor infinite.
|
||||
@_transparent // @_inlineable
|
||||
public var isInfinite: Bool {
|
||||
return denominator == 0 && numerator != 0
|
||||
}
|
||||
|
||||
/// A Boolean value indicating whether the instance is NaN ("not a number").
|
||||
///
|
||||
/// Because NaN is not equal to any value, including NaN, use this property
|
||||
/// instead of the equal-to operator (`==`) or not-equal-to operator (`!=`) to
|
||||
/// test whether a value is or is not NaN.
|
||||
@_transparent // @_inlineable
|
||||
public var isNaN: Bool {
|
||||
return denominator == 0 && numerator == 0
|
||||
}
|
||||
|
||||
/// A Boolean value indicating whether the instance is a proper fraction.
|
||||
///
|
||||
/// A fraction `p / q` is proper iff `p > 0`, `q > 0`, and `p < q`.
|
||||
@_transparent // @_inlineable
|
||||
public var isProper: Bool {
|
||||
return numerator > 0 && denominator > 0 && numerator < denominator
|
||||
}
|
||||
|
||||
/// A Boolean value indicating whether the instance is equal to zero.
|
||||
@_transparent // @_inlineable
|
||||
public var isZero: Bool {
|
||||
return denominator != 0 && numerator == 0
|
||||
}
|
||||
|
||||
/// The magnitude (absolute value) of this value.
|
||||
@_transparent // @_inlineable
|
||||
public var magnitude: Rational {
|
||||
return sign == .minus ? -self : self
|
||||
}
|
||||
|
||||
/// The mixed form representing this value.
|
||||
///
|
||||
/// If the value is not finite, the mixed form has zero as its whole part and
|
||||
/// the value as its fractional part.
|
||||
@_transparent // @_inlineable
|
||||
public var mixed: (whole: T, fractional: Rational) {
|
||||
if denominator == 0 { return (whole: 0, fractional: self) }
|
||||
let t = numerator.quotientAndRemainder(dividingBy: denominator)
|
||||
return (
|
||||
whole: t.quotient,
|
||||
fractional: Rational(numerator: t.remainder, denominator: denominator)
|
||||
)
|
||||
}
|
||||
|
||||
/// The sign of this value.
|
||||
@_transparent // @_inlineable
|
||||
public var sign: Sign {
|
||||
return numerator == 0 || (denominator < 0) == (numerator < 0)
|
||||
? .plus
|
||||
: .minus
|
||||
}
|
||||
|
||||
/// Returns the reciprocal (multiplicative inverse) of this value.
|
||||
@_transparent // @_inlineable
|
||||
public func reciprocal() -> Rational {
|
||||
return numerator < 0
|
||||
? Rational(numerator: -denominator, denominator: -numerator)
|
||||
: Rational(numerator: denominator, denominator: numerator)
|
||||
}
|
||||
}
|
||||
|
||||
extension Rational : ExpressibleByIntegerLiteral {
|
||||
@_transparent // @_inlineable
|
||||
public init(integerLiteral value: T) {
|
||||
self.numerator = value
|
||||
self.denominator = 1
|
||||
}
|
||||
}
|
||||
|
||||
extension Rational : CustomStringConvertible {
|
||||
@_transparent // @_inlineable
|
||||
public var description: String {
|
||||
if numerator == 0 { return denominator == 0 ? "nan" : "0" }
|
||||
if denominator == 0 { return numerator < 0 ? "-inf" : "inf" }
|
||||
return denominator == 1 ? "\(numerator)" : "\(numerator)/\(denominator)"
|
||||
}
|
||||
}
|
||||
|
||||
extension Rational : Equatable {
|
||||
// @_transparent // @_inlineable
|
||||
public static func == (lhs: Rational, rhs: Rational) -> Bool {
|
||||
if lhs.denominator == 0 {
|
||||
if lhs.numerator == 0 { return false }
|
||||
if lhs.numerator > 0 { return rhs.denominator == 0 && rhs.numerator > 0 }
|
||||
return rhs.denominator == 0 && rhs.numerator < 0
|
||||
}
|
||||
if rhs.denominator == 0 { return false }
|
||||
|
||||
return lhs.sign == rhs.sign && _compareFiniteMagnitude(lhs, rhs) == 0
|
||||
}
|
||||
}
|
||||
|
||||
extension Rational : Hashable {
|
||||
// @_transparent // @_inlineable
|
||||
public var hashValue: Int {
|
||||
let t = canonical
|
||||
return _fnv1a(t.numerator, t.denominator)
|
||||
}
|
||||
}
|
||||
|
||||
extension Rational : Comparable {
|
||||
// @_transparent // @_inlineable
|
||||
public static func < (lhs: Rational, rhs: Rational) -> Bool {
|
||||
if lhs.denominator == 0 {
|
||||
if lhs.numerator >= 0 { return false }
|
||||
return rhs.denominator != 0 || rhs.numerator > 0
|
||||
}
|
||||
if rhs.denominator == 0 { return rhs.numerator > 0 }
|
||||
|
||||
switch (lhs.sign, rhs.sign) {
|
||||
case (.plus, .minus):
|
||||
return false
|
||||
case (.minus, .plus):
|
||||
return true
|
||||
case (.plus, .plus):
|
||||
return _compareFiniteMagnitude(lhs, rhs) < 0
|
||||
case (.minus, .minus):
|
||||
return _compareFiniteMagnitude(lhs, rhs) > 0
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public static func > (lhs: Rational, rhs: Rational) -> Bool {
|
||||
return rhs < lhs
|
||||
}
|
||||
|
||||
// @_transparent // @_inlineable
|
||||
public static func <= (lhs: Rational, rhs: Rational) -> Bool {
|
||||
if lhs.denominator == 0 {
|
||||
if lhs.numerator == 0 { return false }
|
||||
if lhs.numerator > 0 { return rhs.denominator == 0 && rhs.numerator > 0 }
|
||||
return rhs.denominator != 0 || rhs.numerator != 0
|
||||
}
|
||||
if rhs.denominator == 0 { return rhs.numerator > 0 }
|
||||
|
||||
switch (lhs.sign, rhs.sign) {
|
||||
case (.plus, .minus):
|
||||
return false
|
||||
case (.minus, .plus):
|
||||
return true
|
||||
case (.plus, .plus):
|
||||
return _compareFiniteMagnitude(lhs, rhs) <= 0
|
||||
case (.minus, .minus):
|
||||
return _compareFiniteMagnitude(lhs, rhs) >= 0
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public static func >= (lhs: Rational, rhs: Rational) -> Bool {
|
||||
return rhs <= lhs
|
||||
}
|
||||
}
|
||||
|
||||
extension Rational : Strideable, _Strideable {
|
||||
@_transparent // @_inlineable
|
||||
public func distance(to other: Rational) -> Rational {
|
||||
return other - self
|
||||
}
|
||||
|
||||
@_transparent // @_inlineable
|
||||
public func advanced(by amount: Rational) -> Rational {
|
||||
return self + amount
|
||||
}
|
||||
}
|
||||
|
||||
extension Rational
|
||||
where T : FixedWidthInteger, T.Magnitude : FixedWidthInteger {
|
||||
// TODO: Document this initializer.
|
||||
// @_transparent // @_inlineable
|
||||
public init?<Source : BinaryFloatingPoint>(exactly source: Source) {
|
||||
if source.isNaN { self = .nan; return }
|
||||
if source == .infinity { self = .infinity; return }
|
||||
if source == -.infinity { self = -.infinity; return }
|
||||
if source.isZero { self = 0; return } // Consider -0.0 to be exactly 0.
|
||||
|
||||
let exponent = source.exponent
|
||||
let significandWidth = source.significandWidth
|
||||
let bitWidth = T.bitWidth
|
||||
if significandWidth <= exponent {
|
||||
guard exponent + 1 < bitWidth else { return nil }
|
||||
self.numerator = T(source)
|
||||
self.denominator = 1
|
||||
return
|
||||
}
|
||||
let shift = significandWidth - Int(exponent)
|
||||
guard significandWidth + 1 < bitWidth && shift < bitWidth else {
|
||||
return nil
|
||||
}
|
||||
let numerator = T(source * Source(1 &<< shift))
|
||||
// Ensure that `numerator.magnitude` is representable as a `T`.
|
||||
guard let _ = T(exactly: numerator.magnitude) else { return nil }
|
||||
let denominator = T(1 &<< shift)
|
||||
// Ensure that `denominator.magnitude` is representable as a `T`.
|
||||
guard let _ = T(exactly: denominator.magnitude) else { return nil }
|
||||
self.numerator = numerator
|
||||
self.denominator = denominator
|
||||
}
|
||||
}
|
||||
|
||||
public typealias Ratio = Rational<Int>
|
|
@ -1,9 +0,0 @@
|
|||
//
|
||||
// RoundingRule.swift
|
||||
// NumericAnnex
|
||||
//
|
||||
// Created by Xiaodi Wu on 5/7/17.
|
||||
//
|
||||
|
||||
/// A rule for rounding a number.
|
||||
public typealias RoundingRule = FloatingPointRoundingRule
|
|
@ -1,9 +0,0 @@
|
|||
//
|
||||
// Sign.swift
|
||||
// NumericAnnex
|
||||
//
|
||||
// Created by Xiaodi Wu on 4/30/17.
|
||||
//
|
||||
|
||||
/// The mathematical sign of a number.
|
||||
public typealias Sign = FloatingPointSign
|
|
@ -0,0 +1,337 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Structures 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 title="Structures 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Structures</h1>
|
||||
<p>The following structures are available globally.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex7ComplexV">Complex</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex8RationalV">Rational</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex7ComplexV"></a>
|
||||
<a name="//apple_ref/swift/Struct/Complex" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Complex</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>A type to represent a complex value in Cartesian form.</p>
|
||||
<div class="aside aside-note">
|
||||
<p class="aside-title">Note</p>
|
||||
<code>Complex64</code> is a type alias for <code>Complex<Float></code> and <code>Complex128</code> is
|
||||
a type alias for <code>Complex<Double></code>.
|
||||
|
||||
</div>
|
||||
|
||||
<p>Create new instances of <code>Complex<T></code> using integer or floating-point
|
||||
literals and the imaginary unit <code><a href="Structs/Complex.html#/s:12NumericAnnex7ComplexV1iACyxGvZ">Complex<T>.i</a></code>. For example:</p>
|
||||
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">x</span> <span class="o">=</span> <span class="mi">2</span> <span class="o">+</span> <span class="mi">4</span> <span class="o">*</span> <span class="o">.</span><span class="n">i</span> <span class="c1">// `x` is of type `Complex<Double>`</span>
|
||||
<span class="k">let</span> <span class="nv">y</span> <span class="o">=</span> <span class="mf">3.5</span> <span class="o">+</span> <span class="mi">7</span> <span class="o">*</span> <span class="o">.</span><span class="n">i</span> <span class="c1">// `y` is of type `Complex<Double>`</span>
|
||||
|
||||
<span class="k">let</span> <span class="nv">z</span><span class="p">:</span> <span class="kt">Complex64</span> <span class="o">=</span> <span class="o">.</span><span class="n">e</span> <span class="o">+</span> <span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="o">.</span><span class="n">i</span> <span class="c1">// `z` is of type `Complex<Float>`</span>
|
||||
</code></pre>
|
||||
<h2 id='additional-considerations' class='heading'>Additional Considerations</h2>
|
||||
|
||||
<p>Floating-point types have special values that represent infinity or NaN
|
||||
(<q>not a number</q>). Complex functions in different languages may return
|
||||
different results when working with special values.</p>
|
||||
|
||||
<p>Many complex functions have <a href="http://mathworld.wolfram.com/BranchCut.html">branch cuts</a>, which are curves in the
|
||||
complex plane across which a function is discontinuous. Different languages
|
||||
may adopt different branch cut structures for the same complex function.</p>
|
||||
|
||||
<p>Implementations in <code>Complex<T></code> adhere to the <a href="http://www.open-std.org/JTC1/SC22/WG14/www/standards.html#9899">C standard</a> (Annex G) as
|
||||
closely as possible with respect to special values and branch cuts.</p>
|
||||
|
||||
<p>To users unfamiliar with complex functions, the principal value returned by
|
||||
some complex functions may be unexpected. For example,
|
||||
<code>Double.cbrt(-8) == -2</code>, which is the <strong>real root</strong>, while
|
||||
<code>Complex.cbrt(-8) == 2 * Complex.exp(.i * .pi / 3)</code>, which is the
|
||||
<strong>principal root</strong>.</p>
|
||||
|
||||
<a href="Structs/Complex.html">See more…</a>
|
||||
</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">struct</span> <span class="kt">Complex</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt"><a href="Protocols/Real.html">Real</a></span><span class="o">></span> <span class="p">:</span> <span class="kt">Codable</span>
|
||||
<span class="k">where</span> <span class="kt">T</span> <span class="p">:</span> <span class="kt">Codable</span> <span class="o">&</span> <span class="n">_ExpressibleByBuiltinFloatLiteral</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex8RationalV"></a>
|
||||
<a name="//apple_ref/swift/Struct/Rational" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Rational</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>A type to represent a rational value.</p>
|
||||
<div class="aside aside-note">
|
||||
<p class="aside-title">Note</p>
|
||||
<code>Ratio</code> is a type alias for <code>Rational<Int></code>.
|
||||
|
||||
</div>
|
||||
|
||||
<p>Create new instances of <code>Rational<T></code> by using integer literals and the
|
||||
division (<code>/</code>) operator. For example:</p>
|
||||
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">x</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">/</span> <span class="mi">3</span> <span class="k">as</span> <span class="kt">Ratio</span> <span class="c1">// `x` is of type `Rational<Int>`</span>
|
||||
<span class="k">let</span> <span class="nv">y</span> <span class="o">=</span> <span class="mi">2</span> <span class="k">as</span> <span class="kt">Ratio</span> <span class="c1">// `y` is of type `Rational<Int>`</span>
|
||||
<span class="k">let</span> <span class="nv">z</span><span class="p">:</span> <span class="kt">Ratio</span> <span class="o">=</span> <span class="mi">2</span> <span class="o">/</span> <span class="mi">3</span> <span class="c1">// `z` is also of type `Rational<Int>`</span>
|
||||
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span> <span class="o">+</span> <span class="n">z</span><span class="p">)</span> <span class="c1">// Prints "3"</span>
|
||||
</code></pre>
|
||||
|
||||
<p>You can create an unreduced fraction by using the initializer
|
||||
<code><a href="Structs/Rational.html#/s:12NumericAnnex8RationalVACyxGx9numerator_x11denominatortcfc">Rational<T>.init(numerator:denominator:)</a></code>. For example:</p>
|
||||
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">a</span> <span class="o">=</span> <span class="kt">Ratio</span><span class="p">(</span><span class="nv">numerator</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span> <span class="nv">denominator</span><span class="p">:</span> <span class="mi">3</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> <span class="c1">// Prints "3/3"</span>
|
||||
</code></pre>
|
||||
|
||||
<p>All arithmetic operations on values in canonical form (i.e. reduced to
|
||||
lowest terms) return results in canonical form. However, operations on
|
||||
values not in canonical form may or may not return results that are
|
||||
themselves in canonical form. The property <code>canonicalized</code> is the canonical
|
||||
form of any value.</p>
|
||||
<h2 id='additional-considerations' class='heading'>Additional Considerations</h2>
|
||||
<h3 id='special-values' class='heading'>Special Values</h3>
|
||||
|
||||
<p><code>Rational<T></code> does not prohibit zero as a denominator. Any instance with a
|
||||
positive numerator and zero denominator represents (positive) infinity; any
|
||||
instance with a negative numerator and zero denominator represents negative
|
||||
infinity; and any instance with zero numerator and zero denominator
|
||||
represents NaN (<q>not a number</q>).</p>
|
||||
|
||||
<p>As with floating-point types, <code><a href="Structs/Rational.html#/s:12NumericAnnex8RationalV8infinityACyxGvZ">Rational<T>.infinity</a></code> compares greater than
|
||||
every finite value and negative infinity, and <code>-Rational<T>.infinity</code>
|
||||
compares less than every finite value and positive infinity. Infinite values
|
||||
of the same sign compare equal to each other.</p>
|
||||
|
||||
<p>As with floating-point types, <code><a href="Structs/Rational.html#/s:12NumericAnnex8RationalV3nanACyxGvZ">Rational<T>.nan</a></code> does not compare equal to
|
||||
any other value, including another NaN. Use the property <code>isNaN</code> to test if
|
||||
a value is NaN. <code>Rational<T></code> arithmetic operations are intended to
|
||||
propagate NaN in the same manner as analogous floating-point operations.</p>
|
||||
<h3 id='numerical-limits' class='heading'>Numerical Limits</h3>
|
||||
|
||||
<p>When a value of type <code>Rational<T></code> is in canonical form, the sign of the
|
||||
numerator is the sign of the value; that is, in canonical form, the sign of
|
||||
the denominator is always positive. Therefore, <code>-1 / T.min</code> cannot be
|
||||
represented as a value of type <code>Rational<T></code> because <code>abs(T.min)</code> cannot be
|
||||
represented as a value of type <code>T</code>.</p>
|
||||
|
||||
<p>To ensure that every representable value of type <code>Rational<T></code> has a
|
||||
representable magnitude and reciprocal of the same type, an overflow trap
|
||||
occurs when the division (<code>/</code>) operator is used to create a value of type
|
||||
<code>Rational<T></code> with numerator <code>T.min</code>.</p>
|
||||
|
||||
<a href="Structs/Rational.html">See more…</a>
|
||||
</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">struct</span> <span class="kt">Rational</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">SignedInteger</span><span class="o">></span> <span class="p">:</span> <span class="kt">Codable</span>
|
||||
<span class="k">where</span> <span class="kt">T</span> <span class="p">:</span> <span class="kt">Codable</span> <span class="o">&</span> <span class="n">_ExpressibleByBuiltinIntegerLiteral</span><span class="p">,</span>
|
||||
<span class="kt">T</span><span class="o">.</span><span class="kt">Magnitude</span> <span class="p">:</span> <span class="kt">UnsignedInteger</span><span class="p">,</span>
|
||||
<span class="kt">T</span><span class="o">.</span><span class="kt">Magnitude</span><span class="o">.</span><span class="kt">Magnitude</span> <span class="o">==</span> <span class="kt">T</span><span class="o">.</span><span class="kt">Magnitude</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,10 +0,0 @@
|
|||
import XCTest
|
||||
@testable import NumericAnnexTests
|
||||
|
||||
XCTMain([
|
||||
testCase(FactoringTests.allTests),
|
||||
testCase(RationalTests.allTests),
|
||||
testCase(ComplexTests.allTests),
|
||||
testCase(RandomXorshiftTests.allTests),
|
||||
testCase(RandomXoroshiroTests.allTests),
|
||||
])
|
|
@ -1,723 +0,0 @@
|
|||
import XCTest
|
||||
@testable import NumericAnnex
|
||||
|
||||
class ComplexTests: XCTestCase {
|
||||
let pzpz = Complex(real: +0.0, imaginary: +0.0)
|
||||
let pznz = Complex(real: +0.0, imaginary: -0.0)
|
||||
let nzpz = Complex(real: -0.0, imaginary: +0.0)
|
||||
let nznz = Complex(real: -0.0, imaginary: -0.0)
|
||||
|
||||
let pipi = Complex(real: Double.infinity, imaginary: .infinity)
|
||||
let pini = Complex(real: Double.infinity, imaginary: -.infinity)
|
||||
let nipi = Complex(real: -Double.infinity, imaginary: .infinity)
|
||||
let nini = Complex(real: -Double.infinity, imaginary: -.infinity)
|
||||
|
||||
let pipz = Complex(real: .infinity, imaginary: +0.0)
|
||||
let nipz = Complex(real: -.infinity, imaginary: +0.0)
|
||||
let pinz = Complex(real: .infinity, imaginary: -0.0)
|
||||
let ninz = Complex(real: -.infinity, imaginary: -0.0)
|
||||
|
||||
let pzpi = Complex(real: +0.0, imaginary: .infinity)
|
||||
|
||||
let pxpi = Complex(real: +2.0, imaginary: .infinity)
|
||||
let pxni = Complex(real: +2.0, imaginary: -.infinity)
|
||||
let pipy = Complex(real: .infinity, imaginary: +2.0)
|
||||
let nipy = Complex(real: -.infinity, imaginary: +2.0)
|
||||
|
||||
let pzpn = Complex(real: +0.0, imaginary: .nan)
|
||||
let nzpn = Complex(real: -0.0, imaginary: .nan)
|
||||
let pnpz = Complex(real: .nan, imaginary: +0.0)
|
||||
let pnnz = Complex(real: .nan, imaginary: -0.0)
|
||||
|
||||
let pxpn = Complex(real: +2.0, imaginary: .nan)
|
||||
let nxpn = Complex(real: -2.0, imaginary: .nan)
|
||||
let pnpy = Complex(real: .nan, imaginary: +2.0)
|
||||
let pnny = Complex(real: .nan, imaginary: -2.0)
|
||||
|
||||
let pipn = Complex(real: Double.infinity, imaginary: .nan)
|
||||
let nipn = Complex(real: -Double.infinity, imaginary: .nan)
|
||||
let pnpi = Complex(real: Double.nan, imaginary: .infinity)
|
||||
let pnni = Complex(real: Double.nan, imaginary: -.infinity)
|
||||
|
||||
let pnpn = Complex(real: Double.nan, imaginary: .nan)
|
||||
|
||||
func testComplexInitialization() {
|
||||
let foo = Complex128(42 as Double)
|
||||
let bar = 42 as Complex128
|
||||
XCTAssertEqual(foo, bar)
|
||||
}
|
||||
|
||||
func testComplexAddition() {
|
||||
let foo: Complex128 = 1.0 + 2.0 * .i
|
||||
let bar: Complex128 = 2 + 4 * .i
|
||||
XCTAssertEqual(foo + bar, 3 + 6 * .i)
|
||||
|
||||
let baz: Complex64 = 1 + 2 * .i
|
||||
let boo: Complex64 = 2.0 + 4.0 * .i
|
||||
XCTAssertEqual((foo + bar).real, Double((baz + boo).real))
|
||||
XCTAssertEqual((foo + bar).imaginary, Double((baz + boo).imaginary))
|
||||
|
||||
let moo: Complex64 = .pi + .e * .i
|
||||
XCTAssertEqual(moo.real, .pi)
|
||||
XCTAssertEqual(moo.imaginary, .e)
|
||||
}
|
||||
|
||||
func testComplexDivision() {
|
||||
let a = 3 + 2 * Complex128.i
|
||||
let b = 4 - 3 * Complex128.i
|
||||
let c = a / b
|
||||
XCTAssertEqual(c.real, 6/25)
|
||||
XCTAssertEqual(c.imaginary, 17/25)
|
||||
}
|
||||
|
||||
func testComplexLogarithm() {
|
||||
let a = Complex128(r: 1, theta: .pi / 4)
|
||||
XCTAssertEqual(Complex.log(a).real, 0)
|
||||
XCTAssertEqual(Complex.log(a).imaginary, a.argument)
|
||||
|
||||
let b = Complex128(r: 1, theta: .pi / 2)
|
||||
XCTAssertEqual(Complex.log(b).real, 0)
|
||||
XCTAssertEqual(Complex.log(b).imaginary, b.argument)
|
||||
|
||||
let c = Complex128(r: 1, theta: .pi)
|
||||
XCTAssertEqual(Complex.log(c).real, 0)
|
||||
XCTAssertEqual(Complex.log(c).imaginary, c.argument)
|
||||
|
||||
let d = Complex128(real: -1, imaginary: 0)
|
||||
XCTAssertEqual(Complex.log(d).real, 0)
|
||||
XCTAssertEqual(Complex.log(d).imaginary, d.argument)
|
||||
|
||||
let e = d.conjugate()
|
||||
XCTAssertEqual(Complex.log(e), Complex.log(d).conjugate())
|
||||
|
||||
// Test special values.
|
||||
var result: Complex128
|
||||
result = Complex.log(nzpz)
|
||||
XCTAssertEqual(result.real, -.infinity)
|
||||
XCTAssertEqual(result.imaginary, .pi)
|
||||
// Divide-by-zero flag should be raised.
|
||||
|
||||
result = Complex.log(pzpz)
|
||||
XCTAssertEqual(result.real, -.infinity)
|
||||
XCTAssertTrue(result.imaginary.isZero)
|
||||
XCTAssertTrue(result.imaginary.sign == .plus)
|
||||
// Divide-by-zero flag should be raised.
|
||||
|
||||
result = Complex.log(pxpi)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertEqual(result.imaginary, .pi / 2)
|
||||
|
||||
result = Complex.log(pxpn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.log(nipy)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertEqual(result.imaginary, .pi)
|
||||
|
||||
result = Complex.log(pipy)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertTrue(result.imaginary.isZero)
|
||||
XCTAssertTrue(result.imaginary.sign == .plus)
|
||||
|
||||
result = Complex.log(nipi)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertEqual(result.imaginary, .pi * 3 / 4)
|
||||
|
||||
result = Complex.log(pipi)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertEqual(result.imaginary, .pi / 4)
|
||||
|
||||
result = Complex.log(pipn)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.log(nipn)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.log(pnpy)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.log(pnpi)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.log(pnpn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
}
|
||||
|
||||
func testComplexSquareRoot() {
|
||||
let a: Complex128 = -4
|
||||
XCTAssertEqual(Complex.sqrt(a), 2 * .i)
|
||||
let b: Complex128 = 4
|
||||
XCTAssertEqual(Complex.sqrt(b), 2)
|
||||
|
||||
// Test special values.
|
||||
var result: Complex128
|
||||
result = Complex.sqrt(pzpz)
|
||||
XCTAssertTrue(result.isZero)
|
||||
XCTAssertTrue(result.real.sign == .plus)
|
||||
XCTAssertTrue(result.imaginary.sign == .plus)
|
||||
|
||||
result = Complex.sqrt(nzpz)
|
||||
XCTAssertTrue(result.isZero)
|
||||
XCTAssertTrue(result.real.sign == .plus)
|
||||
XCTAssertTrue(result.imaginary.sign == .plus)
|
||||
|
||||
result = Complex.sqrt(pxpi)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertEqual(result.imaginary, .infinity)
|
||||
|
||||
result = Complex.sqrt(pnpi)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertEqual(result.imaginary, .infinity)
|
||||
|
||||
result = Complex.sqrt(pxpn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.sqrt(nipy)
|
||||
XCTAssertEqual(result.real, 0)
|
||||
XCTAssertTrue(result.real.sign == .plus)
|
||||
XCTAssertEqual(result.imaginary, .infinity)
|
||||
|
||||
result = Complex.sqrt(pipy)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertEqual(result.imaginary, 0)
|
||||
XCTAssertTrue(result.imaginary.sign == .plus)
|
||||
|
||||
result = Complex.sqrt(nipn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isInfinite)
|
||||
// The sign of the imaginary part is unspecified.
|
||||
|
||||
result = Complex.sqrt(pipn)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.sqrt(pnpy)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.sqrt(pnpn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
}
|
||||
|
||||
func testComplexCubeRoot() {
|
||||
// Note that the principal cube root is not necessarily the real-valued
|
||||
// cube root.
|
||||
let a: Complex64 = -8
|
||||
XCTAssertEqualWithAccuracy(Complex.cbrt(a).real, 1, accuracy: 0.000001)
|
||||
XCTAssertEqualWithAccuracy(Complex.cbrt(a).imaginary,
|
||||
2 * Float.sin(.pi / 3), accuracy: 0.000001)
|
||||
|
||||
let b: Complex64 = 8
|
||||
XCTAssertEqual(Complex.cbrt(b), 2)
|
||||
|
||||
let c: Complex64 = -27 * .i
|
||||
XCTAssertEqualWithAccuracy(Complex.cbrt(c).real,
|
||||
3 * Float.cos(-.pi / 6), accuracy: 0.000001)
|
||||
XCTAssertEqualWithAccuracy(Complex.cbrt(c).imaginary,
|
||||
-1.5, accuracy: 0.000001)
|
||||
|
||||
let d: Complex64 = 27 * .i
|
||||
XCTAssertEqual(Complex.cbrt(d), Complex.cbrt(c).conjugate())
|
||||
|
||||
let e: Complex128 = -8
|
||||
XCTAssertEqual(Complex.cbrt(e), 2 * Complex.exp(.i * .pi / 3))
|
||||
}
|
||||
|
||||
func testComplexExponentiation() {
|
||||
let a = Complex(real: Double.log(42))
|
||||
let b = Complex.exp(a)
|
||||
XCTAssertEqualWithAccuracy(b.real, 42, accuracy: 0.00000000000001)
|
||||
|
||||
let i: Complex128 = .i
|
||||
let actual = i.power(of: i)
|
||||
XCTAssertEqual(actual.real, Double.exp(-Double.pi / 2))
|
||||
XCTAssertEqual(actual.imaginary, 0)
|
||||
|
||||
// Test special values.
|
||||
var result: Complex128
|
||||
var expected: Complex128
|
||||
|
||||
result = Complex.exp(pzpz)
|
||||
XCTAssertEqual(result.real, 1)
|
||||
XCTAssertEqual(result.imaginary, 0)
|
||||
XCTAssertTrue(result.imaginary.sign == .plus)
|
||||
|
||||
result = Complex.exp(nzpz)
|
||||
XCTAssertEqual(result.real, 1)
|
||||
XCTAssertEqual(result.imaginary, 0)
|
||||
XCTAssertTrue(result.imaginary.sign == .plus)
|
||||
|
||||
result = Complex.exp(pxpi)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
// Invalid flag should be raised.
|
||||
|
||||
result = Complex.exp(pxpn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.exp(pipz)
|
||||
XCTAssertTrue(result == pipz)
|
||||
XCTAssertTrue(result.imaginary.sign == .plus)
|
||||
|
||||
result = Complex.exp(nipy)
|
||||
expected = Complex(r: 0, theta: nipy.imaginary)
|
||||
XCTAssertEqual(result.real, expected.real)
|
||||
XCTAssertEqual(result.imaginary, expected.imaginary)
|
||||
|
||||
result = Complex.exp(pipy)
|
||||
expected = Complex(r: .infinity, theta: pipy.imaginary)
|
||||
XCTAssertEqual(result.real, expected.real)
|
||||
XCTAssertEqual(result.imaginary, expected.imaginary)
|
||||
|
||||
result = Complex.exp(nipi)
|
||||
XCTAssertTrue(result.isZero)
|
||||
// The signs of zero are unspecified.
|
||||
|
||||
result = Complex.exp(pipi)
|
||||
XCTAssertTrue(result.real.isInfinite)
|
||||
// The sign of the real part is unspecified.
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
// Invalid flag should be raised.
|
||||
|
||||
result = Complex.exp(nipn)
|
||||
XCTAssertTrue(result.isZero)
|
||||
// The signs of zero are unspecified.
|
||||
|
||||
result = Complex.exp(pipn)
|
||||
XCTAssertTrue(result.real.isInfinite)
|
||||
// The sign of the real part is unspecified.
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.exp(pnpz)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertEqual(result.imaginary, pnpz.imaginary)
|
||||
|
||||
result = Complex.exp(pnpy)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.exp(pnpn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
}
|
||||
|
||||
func testComplexTrigonometry() {
|
||||
let a: Complex128 = 1
|
||||
XCTAssertEqual(Complex.sin(a).real, Double.sin(1))
|
||||
XCTAssertTrue(Complex.sin(a).imaginary.isZero)
|
||||
XCTAssertEqual(Complex.cos(a).real, Double.cos(1))
|
||||
XCTAssertTrue(Complex.cos(a).imaginary.isZero)
|
||||
XCTAssertEqual(Complex.tan(a).real, Double.tan(1))
|
||||
XCTAssertTrue(Complex.tan(a).imaginary.isZero)
|
||||
|
||||
let b: Complex128 = a * .i
|
||||
XCTAssertTrue(Complex.sin(b).real.isZero)
|
||||
XCTAssertEqual(Complex.sin(b).imaginary, Double.sinh(1))
|
||||
XCTAssertEqual(Complex.cos(b).real, Double.cosh(1))
|
||||
XCTAssertTrue(Complex.cos(b).imaginary.isZero)
|
||||
XCTAssertTrue(Complex.tan(b).real.isZero)
|
||||
XCTAssertEqual(Complex.tan(b).imaginary, Double.tanh(1))
|
||||
|
||||
let c: Complex128 = -2
|
||||
let d: Complex128 = .pi + .i * Complex.log(2 - Complex.sqrt(3))
|
||||
let e: Complex128 = .pi / 2 - .i * Complex.log(2 + Complex.sqrt(3))
|
||||
|
||||
XCTAssertTrue(Complex.acos(c).real.sign == .plus)
|
||||
XCTAssertEqualWithAccuracy(abs(Complex.acos(c).real), abs(d.real),
|
||||
accuracy: 0.00000000000001)
|
||||
XCTAssertTrue(Complex.acos(c).imaginary.sign == .minus)
|
||||
XCTAssertEqualWithAccuracy(abs(Complex.acos(c).imaginary), abs(d.imaginary),
|
||||
accuracy: 0.00000000000001)
|
||||
|
||||
XCTAssertTrue(Complex.asin(c).real.sign == .minus)
|
||||
XCTAssertEqualWithAccuracy(abs(Complex.asin(c).real), abs(e.real),
|
||||
accuracy: 0.00000000000001)
|
||||
XCTAssertTrue(Complex.asin(c).imaginary.sign == .plus)
|
||||
XCTAssertEqualWithAccuracy(abs(Complex.asin(c).imaginary), abs(e.imaginary),
|
||||
accuracy: 0.00000000000001)
|
||||
|
||||
let f: Complex128 = c.conjugate()
|
||||
XCTAssertEqual(Complex.acos(f), Complex.acos(c).conjugate())
|
||||
XCTAssertEqual(Complex.asin(f), Complex.asin(c).conjugate())
|
||||
|
||||
let g: Complex128 = Complex(real: +0.0, imaginary: 2.0)
|
||||
let h: Complex128 = Complex(real: -0.0, imaginary: 2.0)
|
||||
let i: Complex128 = .pi / 2 + .i * Complex.log(3) / 2
|
||||
|
||||
XCTAssertTrue(Complex.atan(g).real.sign == .plus)
|
||||
XCTAssertEqualWithAccuracy(abs(Complex.atan(g).real), abs(i.real),
|
||||
accuracy: 0.00000000000001)
|
||||
XCTAssertTrue(Complex.atan(g).imaginary.sign == .plus)
|
||||
XCTAssertEqualWithAccuracy(abs(Complex.atan(g).imaginary), abs(i.imaginary),
|
||||
accuracy: 0.00000000000001)
|
||||
XCTAssertEqual(.i * Complex.atan(h), (.i * Complex.atan(g)).conjugate())
|
||||
|
||||
// Test special values.
|
||||
var result: Complex128
|
||||
result = Complex.acos(pzpz)
|
||||
XCTAssertEqual(result.real, .pi / 2)
|
||||
XCTAssertTrue(result.imaginary.isZero)
|
||||
XCTAssertTrue(result.imaginary.sign == .minus)
|
||||
|
||||
result = Complex.acos(nzpz)
|
||||
XCTAssertEqual(result.real, .pi / 2)
|
||||
XCTAssertTrue(result.imaginary.isZero)
|
||||
XCTAssertTrue(result.imaginary.sign == .minus)
|
||||
|
||||
result = Complex.acos(pzpn)
|
||||
XCTAssertEqual(result.real, .pi / 2)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.acos(nzpn)
|
||||
XCTAssertEqual(result.real, .pi / 2)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.acos(pxpi)
|
||||
XCTAssertEqual(result.real, .pi / 2)
|
||||
XCTAssertEqual(result.imaginary, -.infinity)
|
||||
|
||||
result = Complex.acos(pxpn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.acos(nipy)
|
||||
XCTAssertEqual(result.real, .pi)
|
||||
XCTAssertEqual(result.imaginary, -.infinity)
|
||||
|
||||
result = Complex.acos(pipy)
|
||||
XCTAssertTrue(result.real.isZero)
|
||||
XCTAssertTrue(result.real.sign == .plus)
|
||||
XCTAssertEqual(result.imaginary, -.infinity)
|
||||
|
||||
result = Complex.acos(nipi)
|
||||
XCTAssertEqual(result.real, .pi * 3 / 4)
|
||||
XCTAssertEqual(result.imaginary, -.infinity)
|
||||
|
||||
result = Complex.acos(pipi)
|
||||
XCTAssertEqual(result.real, .pi / 4)
|
||||
XCTAssertEqual(result.imaginary, -.infinity)
|
||||
|
||||
result = Complex.acos(pipn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isInfinite)
|
||||
// The sign of the imaginary part is unspecified.
|
||||
|
||||
result = Complex.acos(nipn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isInfinite)
|
||||
// The sign of the imaginary part is unspecified.
|
||||
|
||||
result = Complex.acos(pnpy)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.acos(pnpi)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertEqual(result.imaginary, -.infinity)
|
||||
|
||||
result = Complex.acos(pnpn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
}
|
||||
|
||||
func testComplexHyperbolicFunctions() {
|
||||
let a: Complex128 = Complex(real: 0.0, imaginary: -2.0)
|
||||
XCTAssertEqualWithAccuracy(Complex.asinh(a).real,
|
||||
Double.log(2 + Double.sqrt(3)),
|
||||
accuracy: 0.00000000000001)
|
||||
XCTAssertEqual(Complex.asinh(a).imaginary, -.pi / 2)
|
||||
|
||||
let b: Complex128 = Complex(real: -0.0, imaginary: -2.0)
|
||||
XCTAssertEqualWithAccuracy(Complex.asinh(b).real,
|
||||
-Double.log(2 + Double.sqrt(3)),
|
||||
accuracy: 0.00000000000001)
|
||||
XCTAssertEqual(Complex.asinh(b).imaginary, -.pi / 2)
|
||||
|
||||
let c: Complex128 = 1 + 2 * .i
|
||||
let d: Complex128 = Complex.log(c + Complex.sqrt(-2 + 4 * .i))
|
||||
XCTAssertEqualWithAccuracy(Complex.asinh(c).real, d.real,
|
||||
accuracy: 0.00000000000001)
|
||||
XCTAssertEqualWithAccuracy(Complex.asinh(c).imaginary, d.imaginary,
|
||||
accuracy: 0.00000000000001)
|
||||
XCTAssertEqualWithAccuracy(Complex.atanh(c).real,
|
||||
Double.log(8) / 4 - Double.log(2) / 2,
|
||||
accuracy: 0.00000000000001)
|
||||
XCTAssertEqual(Complex.atanh(c).imaginary, .pi * 3 / 8)
|
||||
|
||||
let e: Complex128 = 0.5
|
||||
XCTAssertEqual(Complex.acosh(e).real, 0)
|
||||
XCTAssertEqualWithAccuracy(Complex.acosh(e).imaginary, 1.047197551196597746,
|
||||
accuracy: 0.00000000000001)
|
||||
|
||||
let f: Complex128 = e.conjugate()
|
||||
XCTAssertTrue(Complex.acosh(f).real.sign == Complex.acosh(e).real.sign)
|
||||
XCTAssertEqual(Complex.acosh(f).real, 0)
|
||||
XCTAssertEqual(Complex.acosh(f).imaginary, -Complex.acosh(e).imaginary)
|
||||
|
||||
let g: Complex128 = 1 + .i
|
||||
let h: Complex128 =
|
||||
Complex.log(g + Complex.pow(-1, 1 / 4) * Complex.sqrt(2 + .i))
|
||||
XCTAssertEqual(Complex.acosh(g).real, h.real)
|
||||
XCTAssertEqual(Complex.acosh(g).imaginary, h.imaginary)
|
||||
|
||||
let i: Complex128 = .i * Complex.acos(g)
|
||||
XCTAssertEqual(Complex.acosh(g), i)
|
||||
|
||||
let j: Complex128 = 2
|
||||
XCTAssertEqual(Complex.atanh(j).real, Double.log(3) / 2)
|
||||
XCTAssertEqual(Complex.atanh(j).imaginary, .pi / 2)
|
||||
|
||||
let k: Complex128 = j.conjugate()
|
||||
XCTAssertEqual(Complex.atanh(k).real, Double.log(3) / 2)
|
||||
XCTAssertEqual(Complex.atanh(k).imaginary, -.pi / 2)
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// TODO: Test sinh, cosh, tanh.
|
||||
//
|
||||
// Per C11 DR 471:
|
||||
// ctanh(0, +inf) = (0, NaN) and raises the invalid flag
|
||||
// ctanh(0, NaN) = (0, NaN) and does not raise the invalid flag
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// Test special values.
|
||||
var result: Complex128
|
||||
var expected: Complex128
|
||||
|
||||
result = Complex.asinh(pzpz)
|
||||
XCTAssertEqual(result, pzpz)
|
||||
XCTAssertTrue(result.real.sign == .plus)
|
||||
XCTAssertTrue(result.imaginary.sign == .plus)
|
||||
|
||||
result = Complex.asinh(pxpi)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertEqual(result.imaginary, .pi / 2)
|
||||
|
||||
result = Complex.asinh(pxpn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.asinh(pipy)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertTrue(result.imaginary.sign == .plus)
|
||||
XCTAssertTrue(result.imaginary.isZero)
|
||||
|
||||
result = Complex.asinh(pipi)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertEqual(result.imaginary, .pi / 4)
|
||||
|
||||
result = Complex.asinh(pipn)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.asinh(pnpz)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.sign == .plus)
|
||||
XCTAssertTrue(result.imaginary.isZero)
|
||||
|
||||
result = Complex.asinh(pnpy)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.asinh(pnpi)
|
||||
XCTAssertTrue(result.real.isInfinite)
|
||||
// The sign of the real part is unspecified.
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.asinh(pnpn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.acosh(pzpz)
|
||||
XCTAssertTrue(result.real.sign == .plus)
|
||||
XCTAssertTrue(result.real.isZero)
|
||||
XCTAssertEqual(result.imaginary, .pi / 2)
|
||||
|
||||
result = Complex.acosh(nzpz)
|
||||
XCTAssertTrue(result.real.sign == .plus)
|
||||
XCTAssertTrue(result.real.isZero)
|
||||
XCTAssertEqual(result.imaginary, .pi / 2)
|
||||
|
||||
result = Complex.acosh(pxpi)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertEqual(result.imaginary, .pi / 2)
|
||||
|
||||
result = Complex.acosh(pxpn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.acosh(pzpn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertEqual(result.imaginary, .pi / 2) // See C11 DR 471.
|
||||
|
||||
result = Complex.acosh(nipy)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertEqual(result.imaginary, .pi)
|
||||
|
||||
result = Complex.acosh(pipy)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertTrue(result.imaginary.sign == .plus)
|
||||
XCTAssertTrue(result.imaginary.isZero)
|
||||
|
||||
result = Complex.acosh(nipi)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertEqual(result.imaginary, .pi * 3 / 4)
|
||||
|
||||
result = Complex.acosh(pipi)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertEqual(result.imaginary, .pi / 4)
|
||||
|
||||
result = Complex.acosh(pipn)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.acosh(nipn)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.acosh(pnpy)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.acosh(pnpi)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.acosh(pnpn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.atanh(pzpz)
|
||||
XCTAssertEqual(result, pzpz)
|
||||
XCTAssertTrue(result.real.sign == .plus)
|
||||
XCTAssertTrue(result.imaginary.sign == .plus)
|
||||
|
||||
result = Complex.atanh(pzpn)
|
||||
XCTAssertTrue(result.real.sign == .plus)
|
||||
XCTAssertTrue(result.real.isZero)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.atanh(1)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertTrue(result.imaginary.sign == .plus)
|
||||
XCTAssertTrue(result.imaginary.isZero)
|
||||
// Divide-by-zero flag should be raised.
|
||||
|
||||
result = Complex.atanh(pxpi)
|
||||
XCTAssertTrue(result.real.sign == .plus)
|
||||
XCTAssertTrue(result.real.isZero)
|
||||
XCTAssertEqual(result.imaginary, .pi / 2)
|
||||
|
||||
result = Complex.atanh(pxpn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.atanh(pipy)
|
||||
XCTAssertTrue(result.real.sign == .plus)
|
||||
XCTAssertTrue(result.real.isZero)
|
||||
XCTAssertEqual(result.imaginary, .pi / 2)
|
||||
|
||||
result = Complex.atanh(pipi)
|
||||
XCTAssertTrue(result.real.sign == .plus)
|
||||
XCTAssertTrue(result.real.isZero)
|
||||
XCTAssertEqual(result.imaginary, .pi / 2)
|
||||
|
||||
result = Complex.atanh(pipn)
|
||||
XCTAssertTrue(result.real.sign == .plus)
|
||||
XCTAssertTrue(result.real.isZero)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.atanh(pnpy)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.atanh(pnpi)
|
||||
XCTAssertTrue(result.real.isZero)
|
||||
// The sign of the real part is unspecified.
|
||||
XCTAssertEqual(result.imaginary, .pi / 2)
|
||||
|
||||
result = Complex.atanh(pnpn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.sinh(pzpz)
|
||||
XCTAssertTrue(result.real.sign == .plus)
|
||||
XCTAssertTrue(result.real.isZero)
|
||||
XCTAssertTrue(result.imaginary.sign == .plus)
|
||||
XCTAssertTrue(result.imaginary.isZero)
|
||||
|
||||
result = Complex.sinh(pzpi)
|
||||
XCTAssertTrue(result.real.isZero)
|
||||
// The sign of the real part is unspecified.
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
// Invalid flag should be raised.
|
||||
|
||||
result = Complex.sinh(pzpn)
|
||||
XCTAssertTrue(result.real.isZero)
|
||||
// The sign of the real part is unspecified (?).
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.sinh(pxpi)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
// Invalid flag should be raised.
|
||||
|
||||
result = Complex.sinh(pxpn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.sinh(pipz)
|
||||
XCTAssertEqual(result.real, .infinity)
|
||||
XCTAssertTrue(result.imaginary.sign == .plus)
|
||||
XCTAssertTrue(result.imaginary.isZero)
|
||||
|
||||
result = Complex.sinh(pipy)
|
||||
expected = Complex(r: .infinity, theta: pipy.imaginary)
|
||||
XCTAssertEqual(result.real, expected.real)
|
||||
XCTAssertEqual(result.imaginary, expected.imaginary)
|
||||
|
||||
result = Complex.sinh(pipi)
|
||||
XCTAssertTrue(result.real.isInfinite)
|
||||
// The sign of the real part is unspecified.
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
// Invalid flag should be raised.
|
||||
|
||||
result = Complex.sinh(pipn)
|
||||
XCTAssertTrue(result.real.isInfinite)
|
||||
// The sign of the real part is unspecified.
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.sinh(pnpz)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.sign == .plus)
|
||||
XCTAssertTrue(result.imaginary.isZero)
|
||||
|
||||
result = Complex.sinh(pnpy)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
|
||||
result = Complex.sinh(pnpn)
|
||||
XCTAssertTrue(result.real.isNaN)
|
||||
XCTAssertTrue(result.imaginary.isNaN)
|
||||
}
|
||||
|
||||
static var allTests = [
|
||||
("testComplexInitialization", testComplexInitialization),
|
||||
("testComplexAddition", testComplexAddition),
|
||||
("testComplexDivision", testComplexDivision),
|
||||
("testComplexLogarithm", testComplexLogarithm),
|
||||
("testComplexSquareRoot", testComplexSquareRoot),
|
||||
("testComplexCubeRoot", testComplexCubeRoot),
|
||||
("testComplexExponentiation", testComplexExponentiation),
|
||||
("testComplexTrigonometry", testComplexTrigonometry),
|
||||
("testComplexHyperbolicFunctions", testComplexHyperbolicFunctions),
|
||||
]
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
import XCTest
|
||||
@testable import NumericAnnex
|
||||
|
||||
class FactoringTests: XCTestCase {
|
||||
func testGCD() {
|
||||
XCTAssertEqual(UInt.gcd(18, 84), 6)
|
||||
XCTAssertEqual(UInt.gcd(24, 60), 12)
|
||||
XCTAssertEqual(UInt.gcd(42, 56), 14)
|
||||
|
||||
// Test special values.
|
||||
XCTAssertEqual(UInt.gcd(0, 42), 42)
|
||||
XCTAssertEqual(UInt.gcd(42, 0), 42)
|
||||
XCTAssertEqual(UInt.gcd(0, 0), 0)
|
||||
|
||||
XCTAssertTrue(Int8.gcdReportingOverflow(-128, -128).overflow == .overflow)
|
||||
}
|
||||
|
||||
func testLCM() {
|
||||
XCTAssertEqual(UInt.lcm(4, 6), 12)
|
||||
XCTAssertEqual(UInt.lcm(6, 21), 42)
|
||||
|
||||
// Test special values.
|
||||
XCTAssertEqual(UInt.lcm(0, 42), 0)
|
||||
XCTAssertEqual(UInt.lcm(42, 0), 0)
|
||||
XCTAssertEqual(UInt.lcm(0, 0), 0)
|
||||
}
|
||||
|
||||
static var allTests = [
|
||||
("testGCD", testGCD),
|
||||
("testLCM", testLCM),
|
||||
]
|
||||
}
|
|
@ -1,433 +0,0 @@
|
|||
import XCTest
|
||||
@testable import NumericAnnex
|
||||
|
||||
class RandomXoroshiroTests: XCTestCase {
|
||||
func test_1_2() {
|
||||
let rng = Random.Xoroshiro(state: (1, 2))
|
||||
// Values were generated using the reference implementation found at:
|
||||
// http://xoroshiro.di.unimi.it/xoroshiro128plus.c
|
||||
let expected: [UInt64] = [
|
||||
3,
|
||||
36029003177443331,
|
||||
78883775479546723,
|
||||
11565523463456473958,
|
||||
4242646275387589636,
|
||||
256749404433942852,
|
||||
11014892026844973196,
|
||||
9059353499452950543,
|
||||
8597521241247625872,
|
||||
4693915028112570637,
|
||||
7013278354776644264,
|
||||
7324551527405749817,
|
||||
5536070250743279847,
|
||||
14551654802141766561,
|
||||
16502220822753139053,
|
||||
9169458631996292866,
|
||||
8255063232684103966,
|
||||
4985613803055290144,
|
||||
8873762385537109026,
|
||||
7955442200162942054,
|
||||
10038983008978924840,
|
||||
16556838790008055993,
|
||||
1445216410056612069,
|
||||
11648404329028311521,
|
||||
11968528621191360117,
|
||||
378994045525309041,
|
||||
15533848123981932311,
|
||||
17810787280139321748,
|
||||
8698105432054197087,
|
||||
3039374059427402804,
|
||||
6000419305548865286,
|
||||
5555673801313513616,
|
||||
14832631808895921712,
|
||||
15269786733006210781,
|
||||
18192816199346518081,
|
||||
9227630901375587864,
|
||||
13636270006546584644,
|
||||
10048331387000224533,
|
||||
5881842723816098216,
|
||||
2759740862732559190,
|
||||
7198729811037598577,
|
||||
2536130127161171247,
|
||||
9244050483868404095,
|
||||
4471143257962844606,
|
||||
6826378813747079941,
|
||||
8311102247454864474,
|
||||
8030254548075018734,
|
||||
4856383866562462327,
|
||||
2146425163792814156,
|
||||
678709922273904935,
|
||||
14153046072826725166,
|
||||
13096693794621671407,
|
||||
3167365684852107430,
|
||||
7035944759741560501,
|
||||
4327331733683539348,
|
||||
4331384222358257785,
|
||||
11778493022454179159,
|
||||
6436799581831663489,
|
||||
5199453391521163130,
|
||||
13866358363722915963,
|
||||
10490459205808868365,
|
||||
8942744637306013108,
|
||||
13330606527360361965,
|
||||
15114450932505609455,
|
||||
10484962763089362709,
|
||||
8486043591433584489,
|
||||
1244312731768254023,
|
||||
1423652513934467700,
|
||||
7202410701832789339,
|
||||
4247336634893478223,
|
||||
2761260300685838243,
|
||||
3026641667955338198,
|
||||
11726045602658466327,
|
||||
15986288544570028551,
|
||||
1140902651811776482,
|
||||
3031375389759955929,
|
||||
10251211885453078785,
|
||||
3805832680344220010,
|
||||
6901351005802427116,
|
||||
327749723378156456,
|
||||
3850130685063866272,
|
||||
395616431473633113,
|
||||
1006002813608848610,
|
||||
13567214008324118923,
|
||||
8234626684467576068,
|
||||
12325748354848861738,
|
||||
13876857058316077328,
|
||||
5575055431371035091,
|
||||
1001747845116129793,
|
||||
1911249420570102675,
|
||||
11307478254871521778,
|
||||
11741813699519564532,
|
||||
18249690205084409006,
|
||||
4141904051068235945,
|
||||
8007541499524410059,
|
||||
11522483542545463294,
|
||||
12843807877472758944,
|
||||
4036354428928582882,
|
||||
3568160883062227481,
|
||||
7069228111761650618,
|
||||
12800820881038955908,
|
||||
12096397496417421560,
|
||||
18331638049296705373,
|
||||
14080565232358176996,
|
||||
11717911967111159659,
|
||||
5236417326714399775,
|
||||
896860817366679607,
|
||||
1103175799875588730,
|
||||
5624452808649533921,
|
||||
14074612223815901137,
|
||||
12560226745213461489,
|
||||
8693158002233621656,
|
||||
13522197534225561183,
|
||||
17543423602239517471,
|
||||
9007394771080283032,
|
||||
13751257602651261054,
|
||||
10523437980156934525,
|
||||
3939326514580989433,
|
||||
4009481458773474577,
|
||||
5605944737217646703,
|
||||
11357362020001843015,
|
||||
6496864033205151805,
|
||||
8784505647222405488,
|
||||
6539787485601627798,
|
||||
14223996719628965531,
|
||||
11820130316034487593,
|
||||
9216825067157709454,
|
||||
13450820975868246163,
|
||||
13582660326201054082,
|
||||
7274082025836619686,
|
||||
5139824568063119565,
|
||||
15809486898860438280,
|
||||
10511273953872056519,
|
||||
8550850887347653734,
|
||||
4982865717503297021,
|
||||
16768400430211288709,
|
||||
5532507867727508336,
|
||||
3461217932251647116,
|
||||
7937630382825106010,
|
||||
8428419650246743539,
|
||||
13756581925356151789,
|
||||
12850941715331890900,
|
||||
17583375651346257957,
|
||||
14212940247871282486,
|
||||
2939312478589591003,
|
||||
9113217020860214630,
|
||||
15037155367836561944,
|
||||
5106936154711971714,
|
||||
7731881123454188381,
|
||||
8800799748666791518,
|
||||
5334921694098114980,
|
||||
16976572882617606055,
|
||||
10733445809727535171,
|
||||
18071763238883705179,
|
||||
12390417336872755007,
|
||||
4675767129793818894,
|
||||
4624990676514788078,
|
||||
13985922235308181354,
|
||||
18199410361023570910,
|
||||
11100295634832328716,
|
||||
14349833775752484419,
|
||||
2635828052976710695,
|
||||
13494215123457180093,
|
||||
824431475002587115,
|
||||
16362343995287574060,
|
||||
12565374284554722892,
|
||||
3400506694682569059,
|
||||
9678328826858469760,
|
||||
2356773772080043977,
|
||||
6660327511171829851,
|
||||
7003621798856571358,
|
||||
13678900301532284938,
|
||||
10328133941778183218,
|
||||
18415851989001661946,
|
||||
164983221740675978,
|
||||
12091409703168792651,
|
||||
16023813642563214154,
|
||||
13146064085390259297,
|
||||
16830016805105752873,
|
||||
12909765344649172761,
|
||||
18132040913220627960,
|
||||
13428079187771868408,
|
||||
13253065382531928412,
|
||||
5597099400358632931,
|
||||
15048470487608189234,
|
||||
13965835027251694013,
|
||||
16488001888584899979,
|
||||
6774957755200087230,
|
||||
9420290878387669954,
|
||||
18103357232511502336,
|
||||
7958521771342382343,
|
||||
7946005055385189225,
|
||||
7459466188094139112,
|
||||
12160219491927961419,
|
||||
10303458678974273963,
|
||||
15164880279874615320,
|
||||
8229476507371032858,
|
||||
8299451873416872397,
|
||||
14240369133888159195,
|
||||
14259674009027384056,
|
||||
]
|
||||
|
||||
for (index, value) in zip(0..., rng.prefix(expected.count)) {
|
||||
XCTAssertEqual(expected[index], value)
|
||||
}
|
||||
}
|
||||
|
||||
func test_42_42() {
|
||||
let rng = Random.Xoroshiro(state: (42, 42))
|
||||
// Values were generated using the reference implementation found at:
|
||||
// http://xoroshiro.di.unimi.it/xoroshiro128plus.c
|
||||
let expected: [UInt64] = [
|
||||
84,
|
||||
1513209474796486656,
|
||||
1516164967689093120,
|
||||
13042513867470012437,
|
||||
12360923703050654741,
|
||||
1540629971893098580,
|
||||
16526710497398440032,
|
||||
6385704233003790657,
|
||||
11168422736538991365,
|
||||
4445263159897632708,
|
||||
3623790067483698302,
|
||||
16679083957109345764,
|
||||
2328362623729376304,
|
||||
11959586146887887947,
|
||||
1397979073127807009,
|
||||
2057082927736384432,
|
||||
9405332975393492225,
|
||||
8930172824755803710,
|
||||
15806946208844633572,
|
||||
13763125990787205877,
|
||||
3588104897035227753,
|
||||
16535253711858701559,
|
||||
1756777986788515775,
|
||||
3260086412739166738,
|
||||
2968118814995357638,
|
||||
10401021566468687067,
|
||||
10396793383754549895,
|
||||
7751583068336470633,
|
||||
18199822703658045417,
|
||||
18106278619996331558,
|
||||
11555865454533205083,
|
||||
11019066312200696059,
|
||||
14691523452735343350,
|
||||
8374833488214025190,
|
||||
5144857991660071778,
|
||||
4303754754246322002,
|
||||
7833483779443332279,
|
||||
9537057695470270940,
|
||||
15360815301067540763,
|
||||
8680872279790622784,
|
||||
5061961432584221634,
|
||||
13845413006391880255,
|
||||
9347406936646547437,
|
||||
9936035123032424105,
|
||||
7762742561483885717,
|
||||
6225100736029176021,
|
||||
12384612707518261907,
|
||||
6932426897081241028,
|
||||
12622735902618443507,
|
||||
16497181272706281681,
|
||||
4175144421792863622,
|
||||
7187519007501887217,
|
||||
1296625689586954249,
|
||||
9756008725656319610,
|
||||
13415925134280955255,
|
||||
7869611265653995342,
|
||||
15802320767156340368,
|
||||
9917057770149375021,
|
||||
6602199518275499834,
|
||||
15985761826175804236,
|
||||
6348789404701085358,
|
||||
13882066392163471251,
|
||||
6823376289545817014,
|
||||
2440555314667442152,
|
||||
8120581271152580867,
|
||||
5962305562057075398,
|
||||
8624786735003738880,
|
||||
17278456019734296413,
|
||||
8810594517455747061,
|
||||
3308252836812617218,
|
||||
11509046657648993076,
|
||||
4526424802255960286,
|
||||
11368279899573388309,
|
||||
17164649625755550542,
|
||||
17756655439803178301,
|
||||
1790544258914355261,
|
||||
16936001771718971059,
|
||||
6604464130005614382,
|
||||
4599098751468689332,
|
||||
5595709687219398019,
|
||||
7782673445638093156,
|
||||
11625849522136425098,
|
||||
17545728945788535376,
|
||||
1086103391208514655,
|
||||
6757121107432662022,
|
||||
7110671459349670034,
|
||||
14243248346778391217,
|
||||
6293180738376339946,
|
||||
82698844051683738,
|
||||
9016754545624797992,
|
||||
12686910675574395757,
|
||||
11377577519711600987,
|
||||
2421687222153439150,
|
||||
5062679022650701181,
|
||||
5366991913210349668,
|
||||
17763749207842542169,
|
||||
15150310935153524353,
|
||||
8753573200416713058,
|
||||
14717915573524068736,
|
||||
4976419370494142329,
|
||||
15950649534319229916,
|
||||
14729183728516038958,
|
||||
14130494893011053825,
|
||||
484607939216453498,
|
||||
11916622920760767819,
|
||||
6235630645739181768,
|
||||
3311677611128604917,
|
||||
15387119495745197491,
|
||||
18407483842959607091,
|
||||
13443654906141944091,
|
||||
7336989792155624100,
|
||||
4969837398812759230,
|
||||
4690320617290695452,
|
||||
7922943443598648642,
|
||||
7261933739777886868,
|
||||
1428233557480945068,
|
||||
13405045269283977471,
|
||||
8264480103292844317,
|
||||
3636005412915626226,
|
||||
14531131283728793534,
|
||||
1554317509710298241,
|
||||
5671084098303337046,
|
||||
2329626881373043482,
|
||||
9843173781615930848,
|
||||
11631854473490224468,
|
||||
1971235111135032481,
|
||||
16500865010222116014,
|
||||
15716915215378368203,
|
||||
9800201135256065410,
|
||||
15826078301157734671,
|
||||
8086394309479137252,
|
||||
4024335468016869419,
|
||||
9607553477750614063,
|
||||
8476344891763358613,
|
||||
9598206907093120703,
|
||||
2222640063630506567,
|
||||
4748064424880786781,
|
||||
16133608208331438329,
|
||||
4841284499098320283,
|
||||
14366219220792192136,
|
||||
12340209151804320950,
|
||||
9394640533303495521,
|
||||
9967177845151229775,
|
||||
1422411866393454331,
|
||||
1700294099603155803,
|
||||
3169743091038458854,
|
||||
1730162735865459074,
|
||||
7076023242537824502,
|
||||
9751492838437846300,
|
||||
5563389164091569554,
|
||||
14685081858851293124,
|
||||
17127988883180719048,
|
||||
13139712666856391346,
|
||||
16133760556311029769,
|
||||
16124042929298679518,
|
||||
15244317750072181250,
|
||||
16865140868997569773,
|
||||
3382895046112672233,
|
||||
3311493913432858434,
|
||||
6972003746672027210,
|
||||
10860730320333834349,
|
||||
13157555520059317901,
|
||||
18049794823806643433,
|
||||
4096188303889068959,
|
||||
5848535283123888736,
|
||||
14097084481779687678,
|
||||
5923531794703750167,
|
||||
8671735658329475473,
|
||||
12796338774024443025,
|
||||
17688950762314547996,
|
||||
17545970295496335826,
|
||||
18087282577194630790,
|
||||
6111642868515581430,
|
||||
9663837423353030300,
|
||||
5519877375598539571,
|
||||
198283696489934212,
|
||||
639923763610710485,
|
||||
9642279419743806424,
|
||||
12740328497763347702,
|
||||
5689966802246858055,
|
||||
2542424879537644225,
|
||||
4148468791004988526,
|
||||
15776468824412039713,
|
||||
9064289572460882470,
|
||||
8024516222176589607,
|
||||
13357280224400389184,
|
||||
6416386861523146761,
|
||||
2944019619063193966,
|
||||
15840065439036381038,
|
||||
8319915330237311105,
|
||||
12425399842755045103,
|
||||
11362128272172250003,
|
||||
7666439957252188840,
|
||||
17584644503297617903,
|
||||
18199845540565038844,
|
||||
16892202086104407413,
|
||||
11581668723621517396,
|
||||
7063743100798932176,
|
||||
16723393516470594016,
|
||||
15389111121968225194,
|
||||
]
|
||||
|
||||
for (index, value) in zip(0..., rng.prefix(expected.count)) {
|
||||
XCTAssertEqual(expected[index], value)
|
||||
}
|
||||
}
|
||||
|
||||
static var allTests = [
|
||||
("test_1_2", test_1_2),
|
||||
("test_42_42", test_42_42),
|
||||
]
|
||||
}
|
|
@ -1,433 +0,0 @@
|
|||
import XCTest
|
||||
@testable import NumericAnnex
|
||||
|
||||
class RandomXorshiftTests: XCTestCase {
|
||||
func test_1_2() {
|
||||
let rng = Random(state: (1, 2))
|
||||
// Values were generated using the reference implementation found at:
|
||||
// http://xoroshiro.di.unimi.it/xorshift128plus.c
|
||||
let expected: [UInt64] = [
|
||||
3,
|
||||
8388645,
|
||||
33816707,
|
||||
70368778527840,
|
||||
211106267172129,
|
||||
281552312399723,
|
||||
352084508939685,
|
||||
648800200157934532,
|
||||
2540241598295339419,
|
||||
2648407162339308712,
|
||||
2668752799858137237,
|
||||
2693699070923777171,
|
||||
4963962142036894822,
|
||||
11906738374415673757,
|
||||
9632391838565739090,
|
||||
2066554175270807792,
|
||||
2494022894752328945,
|
||||
1356498747469623086,
|
||||
11211414770921777427,
|
||||
10429009827004399351,
|
||||
2323958476090753392,
|
||||
3568022355029630745,
|
||||
66653323867787511,
|
||||
2202670577644624798,
|
||||
12857773250674142713,
|
||||
4201717447333134628,
|
||||
15638699059651815979,
|
||||
4364251867564744889,
|
||||
7660026492187243788,
|
||||
3800851612386782149,
|
||||
9605385339319476694,
|
||||
2406190703679268226,
|
||||
846469172938628641,
|
||||
5337113899023465296,
|
||||
15781852488115071549,
|
||||
15354462637857246627,
|
||||
11103786004116532909,
|
||||
10104343325409002424,
|
||||
12295544783831320534,
|
||||
9091324406814034890,
|
||||
6628842478985115447,
|
||||
12899089858988772368,
|
||||
16555193421103270775,
|
||||
5182223508147526313,
|
||||
1789523054416386623,
|
||||
8305247958687497212,
|
||||
4332901280696262112,
|
||||
4830599505179982300,
|
||||
16562699778378001540,
|
||||
4301002138587088699,
|
||||
16887648884050224867,
|
||||
8961088417938801842,
|
||||
18120357346625319699,
|
||||
5062957422512203146,
|
||||
14533691471387576319,
|
||||
17893283120539033726,
|
||||
8933729491225170482,
|
||||
7703252517382402300,
|
||||
4527677543428710360,
|
||||
11852647525519638421,
|
||||
14323485818621793660,
|
||||
1603981125980772416,
|
||||
10667357879029765177,
|
||||
12618821681808242380,
|
||||
15688459637854892994,
|
||||
16858336139413885781,
|
||||
8192223518607711332,
|
||||
15086078044025798325,
|
||||
7820396459134496922,
|
||||
10260666624710253760,
|
||||
12864353747813168684,
|
||||
3349112384258896183,
|
||||
17079950137619159659,
|
||||
13693940288920244054,
|
||||
4120914027243693443,
|
||||
16513947166147576873,
|
||||
7753202820822651981,
|
||||
6626804775540638270,
|
||||
6691531028144752467,
|
||||
1848899687106318854,
|
||||
13681393795236538282,
|
||||
16157808923290844879,
|
||||
14402137377069136975,
|
||||
10721861038970349125,
|
||||
11713871874537672148,
|
||||
17636397933591539986,
|
||||
4203420467318374,
|
||||
14279516174659940213,
|
||||
5030216290135979793,
|
||||
12431123221355774434,
|
||||
3353451983739559286,
|
||||
1982730773867159337,
|
||||
4287093158672282079,
|
||||
10427894759339841969,
|
||||
10992708284980487886,
|
||||
9826778016246262346,
|
||||
598098170064759435,
|
||||
5132675295537973900,
|
||||
2977953682469803199,
|
||||
7095603002820811521,
|
||||
14473363250705030589,
|
||||
5815164147694210911,
|
||||
893364492343289163,
|
||||
7223131833749622824,
|
||||
8283693734360236205,
|
||||
18098811217686597526,
|
||||
13472185143670172098,
|
||||
4921989762323275340,
|
||||
1122032220579367383,
|
||||
1580787425287478212,
|
||||
12971777770367737930,
|
||||
14141602702208488443,
|
||||
8934944843784058286,
|
||||
6607626240826326523,
|
||||
6849503334803588545,
|
||||
8945087483095516625,
|
||||
11138928521629212103,
|
||||
17790276629890369045,
|
||||
1578334294751373582,
|
||||
2806185787680672391,
|
||||
2659421138426664381,
|
||||
5725303483961243766,
|
||||
6184936954810297634,
|
||||
939427805219677289,
|
||||
7877825174927605138,
|
||||
17042809939415329651,
|
||||
7007032053414486723,
|
||||
708948147059678574,
|
||||
5807695797323831903,
|
||||
10654984825451839699,
|
||||
658076860194383956,
|
||||
6054460744441943985,
|
||||
18125771188890900160,
|
||||
12455829269468258300,
|
||||
7801377697876303864,
|
||||
1155650389744014674,
|
||||
14837203265123196363,
|
||||
14611150480548774776,
|
||||
11295561405428659877,
|
||||
14652736317255425712,
|
||||
10357309030900164003,
|
||||
11362376726255131814,
|
||||
17481625516190528824,
|
||||
10063769529741033785,
|
||||
10070196982447573973,
|
||||
10858208953628516990,
|
||||
8316996154212129605,
|
||||
1966992145466461251,
|
||||
9534492825751960063,
|
||||
17331020003238783005,
|
||||
4055301956728939736,
|
||||
15747646385425363016,
|
||||
5713890891727580694,
|
||||
16363438003468365099,
|
||||
6059680446507887551,
|
||||
15805989924395708713,
|
||||
7701919984793556335,
|
||||
10881930014020511227,
|
||||
16418946584288169403,
|
||||
149521899493351325,
|
||||
12534253806982171802,
|
||||
11139483896115829864,
|
||||
308345381091007206,
|
||||
11578160645028040120,
|
||||
16035213593244811876,
|
||||
2483577470144144779,
|
||||
2382343175518057727,
|
||||
4467734399270823599,
|
||||
6604294351011625227,
|
||||
8344523632028305909,
|
||||
13176362180825574816,
|
||||
5057251926377527702,
|
||||
4615034777510676815,
|
||||
716527652147291657,
|
||||
2255853362627944573,
|
||||
1040521049739732381,
|
||||
8767117186808380895,
|
||||
4542310411533510448,
|
||||
17298777313319151232,
|
||||
6001563173036790655,
|
||||
6632155663823324745,
|
||||
260008012886308771,
|
||||
8125529425889733497,
|
||||
8459386663958119024,
|
||||
478351272518501156,
|
||||
16245194212119991188,
|
||||
16067636681512186800,
|
||||
13291772728582610504,
|
||||
977325433216839797,
|
||||
316583137798752960,
|
||||
16331330055435573991,
|
||||
13872944562523015302,
|
||||
14073886698853620462,
|
||||
10932979021145220513,
|
||||
9767459346543799817,
|
||||
3499076079183291818,
|
||||
16794441505776618298,
|
||||
2728580826238923060,
|
||||
9982312178378568539,
|
||||
10174783523235389589,
|
||||
]
|
||||
|
||||
for (index, value) in zip(0..., rng.prefix(expected.count)) {
|
||||
XCTAssertEqual(expected[index], value)
|
||||
}
|
||||
}
|
||||
|
||||
func test_42_42() {
|
||||
let rng = Random(state: (42, 42))
|
||||
// Values were generated using the reference implementation found at:
|
||||
// http://xoroshiro.di.unimi.it/xorshift128plus.c
|
||||
let expected: [UInt64] = [
|
||||
84,
|
||||
352322923,
|
||||
363332930,
|
||||
2955487621802017,
|
||||
5910974877560714,
|
||||
5984590265422244,
|
||||
3102369235448484,
|
||||
8794055518707935431,
|
||||
11715271280642458577,
|
||||
11121097408281568494,
|
||||
11123324466519438486,
|
||||
11813657815484460077,
|
||||
15967982470865911351,
|
||||
16027149834536272202,
|
||||
14579330570455427858,
|
||||
17901094324785512346,
|
||||
7299173581280891606,
|
||||
9598572314193889241,
|
||||
6321253227128400616,
|
||||
12069832686681671119,
|
||||
8362407854952761049,
|
||||
4240112657210925663,
|
||||
8298289508193808350,
|
||||
5492533585219385488,
|
||||
3424077862959065976,
|
||||
16763914594806242130,
|
||||
1218199477047421836,
|
||||
7673362999398496465,
|
||||
5794997430478554395,
|
||||
7270864472693218401,
|
||||
6217237324811287380,
|
||||
5931838762482735489,
|
||||
2650854048920189469,
|
||||
15912113305156886344,
|
||||
12742758016124380936,
|
||||
4295159997148736665,
|
||||
377715972074097257,
|
||||
2850808977988091172,
|
||||
8491599958789257052,
|
||||
9324795365995984871,
|
||||
8211242245495735455,
|
||||
17422811286952683550,
|
||||
13418142500587507919,
|
||||
5930788801560645895,
|
||||
6741187258797332316,
|
||||
10118554851581664695,
|
||||
115595561983548771,
|
||||
8043906809085936116,
|
||||
11823913423613696098,
|
||||
14518129458877160117,
|
||||
8343257749050278180,
|
||||
13733556794904034707,
|
||||
8684565082910747967,
|
||||
3120612299320189264,
|
||||
12303575766779633627,
|
||||
12795815681716387847,
|
||||
9809457554914526522,
|
||||
8920375781289094670,
|
||||
1993124226495641609,
|
||||
1733459562229749526,
|
||||
17111289711044275575,
|
||||
17744781264274534442,
|
||||
8365870118406280068,
|
||||
3394993270264399372,
|
||||
17743599368353179843,
|
||||
10866568771989044846,
|
||||
5256627558940251261,
|
||||
1523012312127918050,
|
||||
4830133096723200725,
|
||||
15678901288667906426,
|
||||
12456461226754166128,
|
||||
11853493959818320069,
|
||||
12499595671348820672,
|
||||
1087309203085082628,
|
||||
8913015614641765480,
|
||||
7628423184432057398,
|
||||
3580904369680909773,
|
||||
803445358366289622,
|
||||
11594309456042139689,
|
||||
4033442513255026894,
|
||||
1433661196805234850,
|
||||
12192207108666652295,
|
||||
14586722686201389331,
|
||||
6181944170276831130,
|
||||
764669472652961289,
|
||||
889048737081245825,
|
||||
12138836305257926083,
|
||||
888086957463834642,
|
||||
2390515631187897836,
|
||||
2446868417045655461,
|
||||
11015187241185530986,
|
||||
10036793306822931734,
|
||||
12334486703513775025,
|
||||
5108691882609665754,
|
||||
9514819673388488194,
|
||||
2273142206574835406,
|
||||
14437507437202006078,
|
||||
3730714957717498326,
|
||||
2872726062891204564,
|
||||
3798333342152566218,
|
||||
16669861045337712380,
|
||||
13102670696856779254,
|
||||
10908263394212623530,
|
||||
10676532138494980932,
|
||||
15489857964433950539,
|
||||
7937142546638092754,
|
||||
13417642705898345692,
|
||||
13600811864162143445,
|
||||
9477162617086519863,
|
||||
10624389419236725677,
|
||||
7441007177458375221,
|
||||
16546523980542070736,
|
||||
17024880117250866739,
|
||||
18039589907068853828,
|
||||
17555160936737332920,
|
||||
7083735549926373853,
|
||||
4420365159915317578,
|
||||
16029263747729017986,
|
||||
9972633967851497325,
|
||||
7138346049748499288,
|
||||
13270188884066368590,
|
||||
9463122843754064712,
|
||||
11942301208543755374,
|
||||
2622930306965644834,
|
||||
17433830334026038459,
|
||||
8169816655638087827,
|
||||
12836491954871888680,
|
||||
14528181774076346116,
|
||||
15183710998958962615,
|
||||
4028984353527250283,
|
||||
11816946909171962632,
|
||||
4065563158656645039,
|
||||
15930560328422184085,
|
||||
10849511457716257195,
|
||||
12483535526530318894,
|
||||
11367233570755787020,
|
||||
17859411692174119294,
|
||||
1306416274365004041,
|
||||
3368018692405648683,
|
||||
2913934462501646291,
|
||||
5248772458214493708,
|
||||
1765279421221167687,
|
||||
3394064100077089893,
|
||||
3629895405441912055,
|
||||
12299657979994244302,
|
||||
16008402201086829007,
|
||||
5458106375116620038,
|
||||
16730533680684926710,
|
||||
505844743719408298,
|
||||
4843472813567170388,
|
||||
12363442002524133152,
|
||||
11170145896500987331,
|
||||
8329207398927125713,
|
||||
11036379913765865888,
|
||||
2618306290991370477,
|
||||
1741543416193582741,
|
||||
5146591056299389583,
|
||||
7865421083469608492,
|
||||
7071530335411999512,
|
||||
9836070694521579615,
|
||||
8260774949340336056,
|
||||
551175967640246701,
|
||||
2030281209927081181,
|
||||
16417504261929240858,
|
||||
14442013933768465970,
|
||||
3838236631860248808,
|
||||
16071916515461671872,
|
||||
12960610862896350943,
|
||||
5289632148835048055,
|
||||
1827674498314689410,
|
||||
10789868859655831854,
|
||||
11210908846547680913,
|
||||
13945725155205586140,
|
||||
10261895380415373153,
|
||||
4016205272160740838,
|
||||
16497458846534660898,
|
||||
9795538644692598039,
|
||||
18053416664331168520,
|
||||
3256852140039313454,
|
||||
12501759108812025258,
|
||||
7098503516961967472,
|
||||
11650064198712856478,
|
||||
1593512087519278921,
|
||||
10264399986535021899,
|
||||
3537643041203047414,
|
||||
5650861041254369406,
|
||||
15204856943036229121,
|
||||
14012199752722101339,
|
||||
9164702022019181819,
|
||||
17759817422978365807,
|
||||
9543001839860678976,
|
||||
11899169602608869168,
|
||||
1442073933760388807,
|
||||
11121798007280630550,
|
||||
6079263746152188428,
|
||||
11994280689457877647,
|
||||
7959160577587456781,
|
||||
2831973816179963895,
|
||||
309986269562773395,
|
||||
6500631040839990712,
|
||||
]
|
||||
|
||||
for (index, value) in zip(0..., rng.prefix(expected.count)) {
|
||||
XCTAssertEqual(expected[index], value)
|
||||
}
|
||||
}
|
||||
|
||||
static var allTests = [
|
||||
("test_1_2", test_1_2),
|
||||
("test_42_42", test_42_42),
|
||||
]
|
||||
}
|
|
@ -1,266 +0,0 @@
|
|||
import XCTest
|
||||
@testable import NumericAnnex
|
||||
|
||||
class RationalTests: XCTestCase {
|
||||
func testRational() {
|
||||
let a = 6 / 4 as Rational<Int>
|
||||
XCTAssertEqual(a.description, "3/2")
|
||||
XCTAssertEqual(a, 3 / 2 as Rational<Int>)
|
||||
|
||||
let b = 5 / 3 as Rational<Int>
|
||||
XCTAssertEqual(b.description, "5/3")
|
||||
XCTAssertLessThan(a, b)
|
||||
|
||||
XCTAssertEqual(a + b, 19 / 6 as Ratio)
|
||||
XCTAssertEqual(b + a, 19 / 6 as Ratio)
|
||||
XCTAssertEqual(a - b, -1 / 6 as Ratio)
|
||||
XCTAssertEqual(b - a, 1 / 6 as Ratio)
|
||||
XCTAssertEqual(a * b, 5 / 2 as Ratio)
|
||||
XCTAssertEqual(b * a, 5 / 2 as Ratio)
|
||||
XCTAssertEqual(a / b, 9 / 10 as Ratio)
|
||||
XCTAssertEqual(b / a, 10 / 9 as Ratio)
|
||||
|
||||
XCTAssertEqual((10 / 9 as Ratio).mixed.whole, 1)
|
||||
XCTAssertEqual((10 / 9 as Ratio).mixed.fractional, 1 / 9)
|
||||
|
||||
// Test special values.
|
||||
let pn = Ratio.nan
|
||||
let pi = Ratio.infinity
|
||||
let ni = -Ratio.infinity
|
||||
|
||||
XCTAssertTrue((pn + pn).isNaN)
|
||||
XCTAssertTrue((pn - pn).isNaN)
|
||||
XCTAssertTrue((pn * pn).isNaN)
|
||||
XCTAssertTrue((pn / pn).isNaN)
|
||||
|
||||
XCTAssertEqual(pi + pi, .infinity)
|
||||
XCTAssertEqual(ni + ni, -.infinity)
|
||||
XCTAssertEqual(pi + 0, .infinity)
|
||||
XCTAssertEqual(ni + 0, -.infinity)
|
||||
XCTAssertEqual(pi + 42, .infinity)
|
||||
XCTAssertEqual(pi - 42, .infinity)
|
||||
XCTAssertEqual(ni + 42, -.infinity)
|
||||
XCTAssertEqual(ni - 42, -.infinity)
|
||||
|
||||
XCTAssertTrue((pi + ni).isNaN)
|
||||
XCTAssertTrue((ni + pi).isNaN)
|
||||
XCTAssertTrue((pi - pi).isNaN)
|
||||
XCTAssertTrue((-pi + pi).isNaN)
|
||||
|
||||
XCTAssertTrue((0 / 0 as Ratio).isNaN)
|
||||
XCTAssert((0 / 0 as Ratio) != .nan) // NaN compares unequal to everything.
|
||||
XCTAssertTrue((42 / 0 as Ratio).isInfinite)
|
||||
XCTAssertTrue((-42 / 0 as Ratio).isInfinite)
|
||||
XCTAssert(42 / 0 as Ratio == .infinity)
|
||||
XCTAssert(-42 / 0 as Ratio == -.infinity)
|
||||
XCTAssertEqual((42 / 0 as Ratio).description, "inf")
|
||||
XCTAssertEqual((-42 / 0 as Ratio).description, "-inf")
|
||||
|
||||
XCTAssertEqual(pi * pi, .infinity)
|
||||
XCTAssertEqual(pi * ni, -.infinity)
|
||||
XCTAssertEqual(ni * pi, -.infinity)
|
||||
XCTAssertEqual(ni * ni, .infinity)
|
||||
|
||||
XCTAssertTrue((pi * 0).isNaN)
|
||||
XCTAssertTrue((ni * 0).isNaN)
|
||||
XCTAssertTrue((0 * pi).isNaN)
|
||||
XCTAssertTrue((0 * ni).isNaN)
|
||||
XCTAssertTrue((pn * pi).isNaN)
|
||||
XCTAssertTrue((pi * pn).isNaN)
|
||||
XCTAssertTrue((pn * ni).isNaN)
|
||||
XCTAssertTrue((ni * pn).isNaN)
|
||||
}
|
||||
|
||||
func testRationalConversion() {
|
||||
var d: Double, r: Ratio
|
||||
|
||||
r = Ratio(42)
|
||||
XCTAssertEqual(r, 42)
|
||||
XCTAssertEqual(Int(r), 42)
|
||||
|
||||
r = Ratio(UInt8.max)
|
||||
XCTAssertEqual(UInt8(r), .max)
|
||||
|
||||
r = Ratio(Int16.min)
|
||||
XCTAssertEqual(Int16(r), .min)
|
||||
XCTAssertNil(UInt16(exactly: r))
|
||||
|
||||
XCTAssertNil(Ratio(exactly: Int.min))
|
||||
|
||||
r = Ratio(Double.pi)
|
||||
XCTAssertEqual(Double(r), .pi)
|
||||
XCTAssertTrue(r.isCanonical)
|
||||
|
||||
r = Ratio(Double.e)
|
||||
XCTAssertEqual(Double(r), .e)
|
||||
XCTAssertTrue(r.isCanonical)
|
||||
|
||||
r = Ratio(Double.phi)
|
||||
XCTAssertEqual(Double(r), .phi)
|
||||
XCTAssertTrue(r.isCanonical)
|
||||
|
||||
r = Ratio(Float.pi)
|
||||
XCTAssertEqual(Float(r), .pi)
|
||||
XCTAssertTrue(r.isCanonical)
|
||||
|
||||
r = Ratio(Float.e)
|
||||
XCTAssertEqual(Float(r), .e)
|
||||
XCTAssertTrue(r.isCanonical)
|
||||
|
||||
r = Ratio(Float.phi)
|
||||
XCTAssertEqual(Float(r), .phi)
|
||||
XCTAssertTrue(r.isCanonical)
|
||||
|
||||
d = 0
|
||||
XCTAssertEqual(Ratio(d), 0)
|
||||
XCTAssertEqual(Double(Ratio(d)), 0)
|
||||
|
||||
d = 0.ulp
|
||||
XCTAssertTrue(d.isSubnormal)
|
||||
XCTAssertEqual(d.significand, 1)
|
||||
XCTAssertEqual(d.exponent, -1074)
|
||||
XCTAssertNil(Ratio(exactly: d))
|
||||
|
||||
d = .infinity
|
||||
XCTAssertEqual(Ratio(d), .infinity)
|
||||
XCTAssertEqual(Double(Ratio(d)), .infinity)
|
||||
|
||||
d = -.infinity
|
||||
XCTAssertEqual(Ratio(d), -.infinity)
|
||||
XCTAssertEqual(Double(Ratio(d)), -.infinity)
|
||||
|
||||
d = .nan
|
||||
XCTAssertTrue(Ratio(d).isNaN)
|
||||
XCTAssertTrue(Double(Ratio(d)).isNaN)
|
||||
}
|
||||
|
||||
func testRationalComparison() {
|
||||
let a = 1 / 2 as Ratio
|
||||
let b = 1 / 4 as Ratio
|
||||
XCTAssert(a != b)
|
||||
XCTAssert(a == a)
|
||||
XCTAssert(b == b)
|
||||
XCTAssert(a > b)
|
||||
XCTAssert(b < a)
|
||||
XCTAssert(!(a < a))
|
||||
|
||||
let c = -1 / 2 as Ratio
|
||||
let d = -1 / 4 as Ratio
|
||||
XCTAssert(c != d)
|
||||
XCTAssert(c == c)
|
||||
XCTAssert(d == d)
|
||||
XCTAssert(c < d)
|
||||
XCTAssert(d > c)
|
||||
XCTAssert(!(c < c))
|
||||
|
||||
let e = Ratio(numerator: 0, denominator: 1)
|
||||
let f = Ratio(numerator: 0, denominator: 2)
|
||||
let g = Ratio(numerator: 0, denominator: -1)
|
||||
let h = Ratio(numerator: 0, denominator: -2)
|
||||
let i = Ratio(numerator: 0, denominator: 0)
|
||||
XCTAssert(e.sign == .plus)
|
||||
XCTAssert(e == f)
|
||||
XCTAssert(f.sign == .plus)
|
||||
XCTAssert(e == g)
|
||||
XCTAssert(g.sign == .plus)
|
||||
XCTAssert(e == h)
|
||||
XCTAssert(h.sign == .plus)
|
||||
XCTAssert(e != i)
|
||||
XCTAssert(i != i)
|
||||
|
||||
let j = Ratio.infinity
|
||||
let k = Ratio(numerator: 2, denominator: 0)
|
||||
let l = -Ratio.infinity
|
||||
let m = Ratio(numerator: -2, denominator: 0)
|
||||
let n = Ratio.nan
|
||||
XCTAssert(j == k)
|
||||
XCTAssert(j >= k)
|
||||
XCTAssert(!(j < k))
|
||||
XCTAssert(j != l)
|
||||
XCTAssert(j > l)
|
||||
XCTAssert(!(j < l))
|
||||
XCTAssert(j != m)
|
||||
XCTAssert(j > m)
|
||||
XCTAssert(!(j < m))
|
||||
XCTAssert(l != j)
|
||||
XCTAssert(l < j)
|
||||
XCTAssert(!(l > j))
|
||||
XCTAssert(l != k)
|
||||
XCTAssert(l < k)
|
||||
XCTAssert(!(l > k))
|
||||
XCTAssert(l == m)
|
||||
XCTAssert(l >= m)
|
||||
XCTAssert(!(l < m))
|
||||
XCTAssert(j != n)
|
||||
XCTAssert(!(j < n))
|
||||
XCTAssert(!(j <= n))
|
||||
XCTAssert(!(j > n))
|
||||
XCTAssert(!(j >= n))
|
||||
XCTAssert(l != n)
|
||||
XCTAssert(!(l < n))
|
||||
XCTAssert(!(l <= n))
|
||||
XCTAssert(!(l > n))
|
||||
XCTAssert(!(l >= n))
|
||||
XCTAssert(n != n)
|
||||
XCTAssert(!(n < n))
|
||||
XCTAssert(!(n <= n))
|
||||
XCTAssert(!(n > n))
|
||||
XCTAssert(!(n >= n))
|
||||
}
|
||||
|
||||
func testRationalRounding() {
|
||||
let a = 10 / 3 as Ratio
|
||||
XCTAssertEqual(a.rounded(), 3)
|
||||
XCTAssertEqual(a.rounded(.up), 4)
|
||||
XCTAssertEqual(a.rounded(.down), 3)
|
||||
XCTAssertEqual(a.rounded(.towardZero), 3)
|
||||
XCTAssertEqual(a.rounded(.awayFromZero), 4)
|
||||
XCTAssertEqual(a.rounded(.toNearestOrEven), 3)
|
||||
XCTAssertEqual(a.rounded(.toNearestOrAwayFromZero), 3)
|
||||
|
||||
let b = -a
|
||||
XCTAssertEqual(b, -10 / 3)
|
||||
XCTAssertEqual(b.rounded(), -3)
|
||||
XCTAssertEqual(b.rounded(.up), -3)
|
||||
XCTAssertEqual(b.rounded(.down), -4)
|
||||
XCTAssertEqual(b.rounded(.towardZero), -3)
|
||||
XCTAssertEqual(b.rounded(.awayFromZero), -4)
|
||||
XCTAssertEqual(b.rounded(.toNearestOrEven), -3)
|
||||
XCTAssertEqual(b.rounded(.toNearestOrAwayFromZero), -3)
|
||||
|
||||
let c = 5 / 2 as Ratio
|
||||
XCTAssertEqual(c.rounded(), 3)
|
||||
XCTAssertEqual(c.rounded(.up), 3)
|
||||
XCTAssertEqual(c.rounded(.down), 2)
|
||||
XCTAssertEqual(c.rounded(.towardZero), 2)
|
||||
XCTAssertEqual(c.rounded(.awayFromZero), 3)
|
||||
XCTAssertEqual(c.rounded(.toNearestOrEven), 2)
|
||||
XCTAssertEqual(c.rounded(.toNearestOrAwayFromZero), 3)
|
||||
|
||||
let d = -c
|
||||
XCTAssertEqual(d, -5 / 2)
|
||||
XCTAssertEqual(d.rounded(), -3)
|
||||
XCTAssertEqual(d.rounded(.up), -2)
|
||||
XCTAssertEqual(d.rounded(.down), -3)
|
||||
XCTAssertEqual(d.rounded(.towardZero), -2)
|
||||
XCTAssertEqual(d.rounded(.awayFromZero), -3)
|
||||
XCTAssertEqual(d.rounded(.toNearestOrEven), -2)
|
||||
XCTAssertEqual(d.rounded(.toNearestOrAwayFromZero), -3)
|
||||
|
||||
let e = 1 / 9 as Ratio
|
||||
XCTAssertEqual(e.rounded(), 0)
|
||||
XCTAssertEqual(e.rounded(.up), 1)
|
||||
XCTAssertEqual(e.rounded(.down), 0)
|
||||
XCTAssertEqual(e.rounded(.towardZero), 0)
|
||||
XCTAssertEqual(e.rounded(.awayFromZero), 1)
|
||||
XCTAssertEqual(e.rounded(.toNearestOrEven), 0)
|
||||
XCTAssertEqual(e.rounded(.toNearestOrAwayFromZero), 0)
|
||||
}
|
||||
|
||||
static var allTests = [
|
||||
("testRational", testRational),
|
||||
("testRationalConversion", testRationalConversion),
|
||||
("testRationalComparison", testRationalComparison),
|
||||
("testRationalRounding", testRationalRounding),
|
||||
]
|
||||
}
|
|
@ -0,0 +1,243 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Type Aliases 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 title="Type Aliases 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Type Aliases</h1>
|
||||
<p>The following type aliases are available globally.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4Signa">Sign</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex12RoundingRulea">RoundingRule</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4Signa"></a>
|
||||
<a name="//apple_ref/swift/Alias/Sign" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Sign</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>The mathematical sign of a number.</p>
|
||||
|
||||
</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">typealias</span> <span class="kt">Sign</span> <span class="o">=</span> <span class="kt">FloatingPointSign</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex12RoundingRulea"></a>
|
||||
<a name="//apple_ref/swift/Alias/RoundingRule" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>RoundingRule</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>A rule for rounding a number.</p>
|
||||
|
||||
</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">typealias</span> <span class="kt">RoundingRule</span> <span class="o">=</span> <span class="kt">FloatingPointRoundingRule</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,186 @@
|
|||
/* Credit to https://gist.github.com/wataru420/2048287 */
|
||||
.highlight {
|
||||
/* Comment */
|
||||
/* Error */
|
||||
/* Keyword */
|
||||
/* Operator */
|
||||
/* Comment.Multiline */
|
||||
/* Comment.Preproc */
|
||||
/* Comment.Single */
|
||||
/* Comment.Special */
|
||||
/* Generic.Deleted */
|
||||
/* Generic.Deleted.Specific */
|
||||
/* Generic.Emph */
|
||||
/* Generic.Error */
|
||||
/* Generic.Heading */
|
||||
/* Generic.Inserted */
|
||||
/* Generic.Inserted.Specific */
|
||||
/* Generic.Output */
|
||||
/* Generic.Prompt */
|
||||
/* Generic.Strong */
|
||||
/* Generic.Subheading */
|
||||
/* Generic.Traceback */
|
||||
/* Keyword.Constant */
|
||||
/* Keyword.Declaration */
|
||||
/* Keyword.Pseudo */
|
||||
/* Keyword.Reserved */
|
||||
/* Keyword.Type */
|
||||
/* Literal.Number */
|
||||
/* Literal.String */
|
||||
/* Name.Attribute */
|
||||
/* Name.Builtin */
|
||||
/* Name.Class */
|
||||
/* Name.Constant */
|
||||
/* Name.Entity */
|
||||
/* Name.Exception */
|
||||
/* Name.Function */
|
||||
/* Name.Namespace */
|
||||
/* Name.Tag */
|
||||
/* Name.Variable */
|
||||
/* Operator.Word */
|
||||
/* Text.Whitespace */
|
||||
/* Literal.Number.Float */
|
||||
/* Literal.Number.Hex */
|
||||
/* Literal.Number.Integer */
|
||||
/* Literal.Number.Oct */
|
||||
/* Literal.String.Backtick */
|
||||
/* Literal.String.Char */
|
||||
/* Literal.String.Doc */
|
||||
/* Literal.String.Double */
|
||||
/* Literal.String.Escape */
|
||||
/* Literal.String.Heredoc */
|
||||
/* Literal.String.Interpol */
|
||||
/* Literal.String.Other */
|
||||
/* Literal.String.Regex */
|
||||
/* Literal.String.Single */
|
||||
/* Literal.String.Symbol */
|
||||
/* Name.Builtin.Pseudo */
|
||||
/* Name.Variable.Class */
|
||||
/* Name.Variable.Global */
|
||||
/* Name.Variable.Instance */
|
||||
/* Literal.Number.Integer.Long */ }
|
||||
.highlight a {
|
||||
color: inherit; }
|
||||
.highlight .c {
|
||||
color: #007400; }
|
||||
.highlight .err {
|
||||
color: #a61717;
|
||||
background-color: #e3d2d2; }
|
||||
.highlight .k {
|
||||
color: #aa0d91; }
|
||||
.highlight .o {
|
||||
color: #000; }
|
||||
.highlight .cm {
|
||||
color: #007400; }
|
||||
.highlight .cp {
|
||||
color: #007400; }
|
||||
.highlight .c1 {
|
||||
color: #007400; }
|
||||
.highlight .cs {
|
||||
color: #007400; }
|
||||
.highlight .gd {
|
||||
color: #000;
|
||||
background-color: #fdd; }
|
||||
.highlight .gd .x {
|
||||
color: #000;
|
||||
background-color: #faa; }
|
||||
.highlight .ge {
|
||||
font-style: italic; }
|
||||
.highlight .gr {
|
||||
color: #a00; }
|
||||
.highlight .gh {
|
||||
color: #999; }
|
||||
.highlight .gi {
|
||||
color: #000;
|
||||
background-color: #dfd; }
|
||||
.highlight .gi .x {
|
||||
color: #000;
|
||||
background-color: #afa; }
|
||||
.highlight .go {
|
||||
color: #888; }
|
||||
.highlight .gp {
|
||||
color: #555; }
|
||||
.highlight .gs {
|
||||
font-weight: bold; }
|
||||
.highlight .gu {
|
||||
color: #aaa; }
|
||||
.highlight .gt {
|
||||
color: #a00; }
|
||||
.highlight .kc {
|
||||
color: #aa0d91; }
|
||||
.highlight .kd {
|
||||
color: #aa0d91; }
|
||||
.highlight .kp {
|
||||
color: #aa0d91; }
|
||||
.highlight .kr {
|
||||
color: #aa0d91; }
|
||||
.highlight .kt {
|
||||
color: #2b839f; }
|
||||
.highlight .m {
|
||||
color: #000; }
|
||||
.highlight .s {
|
||||
color: #a31515; }
|
||||
.highlight .na {
|
||||
color: #2b839f; }
|
||||
.highlight .nb {
|
||||
color: #2b839f; }
|
||||
.highlight .nc {
|
||||
color: #2b839f; }
|
||||
.highlight .no {
|
||||
color: #2b839f; }
|
||||
.highlight .ni {
|
||||
color: #2b839f; }
|
||||
.highlight .ne {
|
||||
color: #2b839f; }
|
||||
.highlight .nf {
|
||||
color: #2b839f; }
|
||||
.highlight .nn {
|
||||
color: #2b839f; }
|
||||
.highlight .nt {
|
||||
color: #2b839f; }
|
||||
.highlight .nv {
|
||||
color: #000; }
|
||||
.highlight .ow {
|
||||
color: #000; }
|
||||
.highlight .w {
|
||||
color: #bbb; }
|
||||
.highlight .mf {
|
||||
color: #1c00cf; }
|
||||
.highlight .mh {
|
||||
color: #1c00cf; }
|
||||
.highlight .mi {
|
||||
color: #1c00cf; }
|
||||
.highlight .mo {
|
||||
color: #1c00cf; }
|
||||
.highlight .sb {
|
||||
color: #c41a16; }
|
||||
.highlight .sc {
|
||||
color: #1c00cf; }
|
||||
.highlight .sd {
|
||||
color: #c41a16; }
|
||||
.highlight .s2 {
|
||||
color: #c41a16; }
|
||||
.highlight .se {
|
||||
color: #c41a16; }
|
||||
.highlight .sh {
|
||||
color: #c41a16; }
|
||||
.highlight .si {
|
||||
color: #c41a16; }
|
||||
.highlight .sx {
|
||||
color: #c41a16; }
|
||||
.highlight .sr {
|
||||
color: #c41a16; }
|
||||
.highlight .s1 {
|
||||
color: #c41a16; }
|
||||
.highlight .ss {
|
||||
color: #c41a16; }
|
||||
.highlight .bp {
|
||||
color: #999; }
|
||||
.highlight .vc {
|
||||
color: #2b839f; }
|
||||
.highlight .vg {
|
||||
color: #2b839f; }
|
||||
.highlight .vi {
|
||||
color: #2b839f; }
|
||||
.highlight .il {
|
||||
color: #1c00cf; }
|
|
@ -0,0 +1,350 @@
|
|||
@import url("https://fonts.googleapis.com/css?family=Roboto+Mono:400,500,700&subset=greek");
|
||||
*, *::before, *::after {
|
||||
box-sizing: inherit; }
|
||||
|
||||
body {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
background: #fff;
|
||||
color: #333;
|
||||
font: 16px/24px -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; }
|
||||
|
||||
h1 {
|
||||
margin: 32px 0 16px;
|
||||
font-weight: 500;
|
||||
font-size: 28px;
|
||||
line-height: 32px; }
|
||||
|
||||
h2 {
|
||||
margin: 32px 0 16px;
|
||||
font-weight: 500;
|
||||
font-size: 24px;
|
||||
line-height: 32px; }
|
||||
|
||||
h3 {
|
||||
margin: 24px 0 16px;
|
||||
font-weight: 500;
|
||||
font-size: 20px;
|
||||
line-height: 24px; }
|
||||
|
||||
h4 {
|
||||
margin: 24px 0 16px;
|
||||
font-weight: 500;
|
||||
font-size: 16px;
|
||||
line-height: 24px; }
|
||||
|
||||
h5 {
|
||||
margin: 24px 0 16px;
|
||||
font-weight: 500;
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
color: #777; }
|
||||
|
||||
h6 {
|
||||
margin: 24px 0 16px;
|
||||
font-weight: 500;
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
color: #aaaaaa; }
|
||||
|
||||
p {
|
||||
margin: 0 0 16px; }
|
||||
|
||||
ul, ol {
|
||||
margin: 0 0 16px;
|
||||
padding: 0 0 0 32px; }
|
||||
|
||||
blockquote {
|
||||
margin: 0 0 16px;
|
||||
border-left: 6px solid #e6e6e6;
|
||||
border-radius: 4px;
|
||||
padding: 16px;
|
||||
background-color: #fafafa;
|
||||
color: #858585; }
|
||||
blockquote > p:last-child {
|
||||
margin-bottom: 0; }
|
||||
|
||||
dl {
|
||||
margin: 0;
|
||||
padding: 0; }
|
||||
|
||||
dt {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-weight: 500; }
|
||||
dt:last-child {
|
||||
margin-bottom: 16px; }
|
||||
|
||||
dd {
|
||||
margin: 0 0 16px;
|
||||
padding: 0 0 0 8px; }
|
||||
|
||||
img {
|
||||
max-width: 100%; }
|
||||
|
||||
a {
|
||||
color: #4183c4;
|
||||
text-decoration: none; }
|
||||
a:hover, a:focus {
|
||||
outline: 0;
|
||||
text-decoration: underline; }
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
margin: 0 0 12px;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
background: #fff; }
|
||||
|
||||
tr:nth-child(2n) {
|
||||
background-color: #fbfbfb; }
|
||||
|
||||
th, td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 7px 11px; }
|
||||
|
||||
pre {
|
||||
overflow: auto;
|
||||
margin: 0 0 16px;
|
||||
border: 1px solid #e6e6e6;
|
||||
border-radius: 4px;
|
||||
padding: calc(12px - 1px) calc(16px - 1px);
|
||||
background: #f9f9f9;
|
||||
font-size: inherit;
|
||||
line-height: inherit;
|
||||
font-family: "Roboto Mono", Menlo, Consolas, "Liberation Mono", Courier, monospace; }
|
||||
|
||||
code {
|
||||
font-size: 16px;
|
||||
line-height: 16px;
|
||||
font-family: "Roboto Mono", Menlo, Consolas, "Liberation Mono", Courier, monospace; }
|
||||
|
||||
pre code {
|
||||
padding: 0;
|
||||
white-space: pre; }
|
||||
|
||||
body > .wrapper {
|
||||
display: flex;
|
||||
flex-direction: column; }
|
||||
@media only screen and (min-width: 1024px) {
|
||||
body > .wrapper {
|
||||
flex-direction: row; } }
|
||||
|
||||
header {
|
||||
display: flex;
|
||||
padding: 8px;
|
||||
background: #333;
|
||||
color: #999;
|
||||
font-size: 14px;
|
||||
line-height: inherit; }
|
||||
|
||||
header p {
|
||||
margin: 0;
|
||||
padding: 0 8px; }
|
||||
|
||||
header p.primary {
|
||||
flex: 1; }
|
||||
|
||||
header a[href] {
|
||||
color: #fff; }
|
||||
|
||||
nav {
|
||||
order: 2; }
|
||||
@media only screen and (min-width: 1024px) {
|
||||
nav {
|
||||
order: 1;
|
||||
flex: 0 0 25%;
|
||||
max-width: 239px;
|
||||
overflow: hidden;
|
||||
border-right: 1px solid #ddd;
|
||||
padding-bottom: 32px;
|
||||
background: #fbfbfb;
|
||||
word-wrap: normal; } }
|
||||
nav > ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 14px;
|
||||
line-height: inherit;
|
||||
list-style: none; }
|
||||
nav > ul > li {
|
||||
margin: 8px 0;
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding: 8px 0 7px 16px; }
|
||||
nav > ul > li:last-child {
|
||||
margin-bottom: 0; }
|
||||
nav > ul > li > p {
|
||||
margin: 0; }
|
||||
nav > ul > li > p > a[href] {
|
||||
color: #333; }
|
||||
nav > ul > li > ul {
|
||||
margin: 8px 0;
|
||||
padding-left: 16px;
|
||||
list-style: inherit; }
|
||||
nav > ul > li > ul > li {
|
||||
white-space: nowrap; }
|
||||
nav > ul > li > ul > li > a[href] {
|
||||
color: #808080; }
|
||||
|
||||
/*
|
||||
@keyframes appear {
|
||||
0% { opacity: 0 }
|
||||
100% { opacity: 1 }
|
||||
}
|
||||
*/
|
||||
article {
|
||||
order: 1;
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding-bottom: 31px; }
|
||||
@media only screen and (min-width: 1024px) {
|
||||
article {
|
||||
order: 2;
|
||||
flex: 1 1 auto;
|
||||
border-bottom: none;
|
||||
padding-bottom: 32px; } }
|
||||
article > section {
|
||||
padding: 0 32px; }
|
||||
article > section:last-child {
|
||||
border-bottom: none; }
|
||||
article > section > .wrapper {
|
||||
max-width: 720px;
|
||||
margin: 0 auto; }
|
||||
|
||||
.declaration .highlight {
|
||||
overflow-x: initial;
|
||||
margin: 0;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
padding: 0;
|
||||
background-color: transparent; }
|
||||
|
||||
.toc {
|
||||
border-top: 1px solid #ddd;
|
||||
border-bottom: 1px solid #ddd;
|
||||
background-color: #fbfbfb; }
|
||||
.toc details {
|
||||
max-width: 720px;
|
||||
margin: 0 auto;
|
||||
padding: 15px 0; }
|
||||
.toc details[open] > summary {
|
||||
margin-bottom: 8px;
|
||||
/*
|
||||
& ~ * {
|
||||
animation: appear .2s ease-in-out;
|
||||
}
|
||||
*/ }
|
||||
.toc details[open] > summary::after {
|
||||
content: ' \2212'; }
|
||||
.toc details > summary {
|
||||
display: block;
|
||||
margin: 0;
|
||||
padding-bottom: 0;
|
||||
color: #666666;
|
||||
font-weight: 500;
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.1em;
|
||||
text-transform: uppercase;
|
||||
user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
outline: none; }
|
||||
.toc details > summary::-webkit-details-marker {
|
||||
display: none; }
|
||||
.toc details > summary::after {
|
||||
content: ' +'; }
|
||||
.toc details > .wrapper {
|
||||
columns: 1; }
|
||||
@media only screen and (min-width: 1024px) {
|
||||
.toc details > .wrapper {
|
||||
columns: 2;
|
||||
column-gap: 16px; } }
|
||||
.toc details > .wrapper p {
|
||||
margin: 0;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
break-after: avoid-column;
|
||||
-webkit-column-break-after: avoid; }
|
||||
.toc details > .wrapper p a[href] {
|
||||
color: inherit; }
|
||||
.toc details > .wrapper ul {
|
||||
margin: 0;
|
||||
padding-left: 0;
|
||||
color: #b3b3b3;
|
||||
list-style: square inside; }
|
||||
.toc details > .wrapper ul a[href] {
|
||||
color: #808080; }
|
||||
|
||||
.group {
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding-top: 0; }
|
||||
.group:last-child {
|
||||
border-bottom: none; }
|
||||
.group:last-child > ul > li:last-child {
|
||||
padding-bottom: 16px; }
|
||||
.group a[name]::before {
|
||||
content: "";
|
||||
display: block; }
|
||||
.group > ul {
|
||||
margin: 0;
|
||||
padding: 0; }
|
||||
.group > ul > li {
|
||||
width: 100%;
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding: 0 0 15px;
|
||||
list-style: none; }
|
||||
.group > ul > li:last-child {
|
||||
border-bottom: none; }
|
||||
.group > ul > li .declaration-note {
|
||||
color: #808080;
|
||||
font-weight: normal;
|
||||
font-size: 16px; }
|
||||
|
||||
.aside, .language {
|
||||
overflow-y: hidden;
|
||||
margin: 16px 0;
|
||||
border-left: 6px solid #d0d0d0;
|
||||
border-radius: 4px;
|
||||
padding: 8px 12px;
|
||||
background-color: #f7f7f7; }
|
||||
.aside .aside-title, .language .aside-title {
|
||||
margin: 0;
|
||||
padding-bottom: 0;
|
||||
color: #aaa;
|
||||
font-weight: 500;
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.1em;
|
||||
text-transform: uppercase;
|
||||
user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
-webkit-user-select: none; }
|
||||
.aside p:last-child, .language p:last-child {
|
||||
margin-bottom: 0; }
|
||||
|
||||
.language {
|
||||
border-left: 6px solid #99bcdf;
|
||||
background-color: #f0f5fa; }
|
||||
.language .aside-title {
|
||||
color: #4183c4; }
|
||||
|
||||
.aside-warning {
|
||||
border-left: 6px solid #ffda73;
|
||||
background-color: #fff8e6; }
|
||||
.aside-warning .aside-title {
|
||||
color: #fb0; }
|
||||
|
||||
footer {
|
||||
padding: 16px;
|
||||
background: #444;
|
||||
color: #ddd;
|
||||
font-size: 14px;
|
||||
line-height: inherit; }
|
||||
footer p {
|
||||
margin: 0; }
|
||||
footer a[href] {
|
||||
color: #fff; }
|
||||
|
||||
html.dash header, html.dash nav {
|
||||
display: none; }
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.jazzy.numericannex</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>NumericAnnex</string>
|
||||
<key>DocSetPlatformFamily</key>
|
||||
<string>numericannex</string>
|
||||
<key>isDashDocset</key>
|
||||
<true/>
|
||||
<key>dashIndexFilePath</key>
|
||||
<string>index.html</string>
|
||||
<key>isJavaScriptEnabled</key>
|
||||
<true/>
|
||||
<key>DashDocSetFamily</key>
|
||||
<string>dashtoc</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,246 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Classes 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 title="Classes 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Classes</h1>
|
||||
<p>The following classes are available globally.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex6RandomC">Random</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex6RandomC"></a>
|
||||
<a name="//apple_ref/swift/Class/Random" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Random</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>A pseudo-random number generator (PRNG) that implements
|
||||
<a href="http://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf"><code>xorshift128+</code></a>, an efficient linear-feedback shift register.</p>
|
||||
<div class="aside aside-warning">
|
||||
<p class="aside-title">Warning</p>
|
||||
Once seeded from cryptographically secure random bytes, an
|
||||
instance of <code>Random</code> generates high-quality random numbers but is <em>not</em> a
|
||||
cryptographically secure PRNG.
|
||||
|
||||
</div>
|
||||
|
||||
<p>To generate random numbers, create your own instance of <code>Random</code> with an
|
||||
internal state seeded from cryptographically secure random bytes:</p>
|
||||
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">random</span> <span class="o">=</span> <span class="kt">Random</span><span class="p">()</span><span class="o">!</span>
|
||||
<span class="k">let</span> <span class="nv">x</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">()</span> <span class="k">as</span> <span class="kt">Int</span>
|
||||
|
||||
<span class="c1">// You can also pass the desired result type as an argument.</span>
|
||||
<span class="k">let</span> <span class="nv">y</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="kt">Int</span><span class="o">.</span><span class="k">self</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">x</span> <span class="o">></span> <span class="n">y</span> <span class="p">{</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="s">"Here's a random value between 0 and 42 (inclusive):"</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="mi">42</span><span class="p">))</span>
|
||||
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="s">"Here's a random value between -42 and 0 (inclusive):"</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="o">-</span><span class="mi">42</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="mi">0</span><span class="p">))</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
<div class="aside aside-see-also">
|
||||
<p class="aside-title">See also</p>
|
||||
<code><a href="Classes/Random/Xoroshiro.html">Random.Xoroshiro</a></code>, <code><a href="Protocols/PRNG.html">PRNG</a></code>
|
||||
|
||||
</div>
|
||||
|
||||
<a href="Classes/Random.html">See more…</a>
|
||||
</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">final</span> <span class="kd">class</span> <span class="kt">Random</span> <span class="p">:</span> <span class="kt"><a href="Protocols/PRNG.html">PRNG</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,389 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Random Class 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/Class/Random" class="dashAnchor"></a>
|
||||
<a title="Random Class 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Random</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">final</span> <span class="kd">class</span> <span class="kt">Random</span> <span class="p">:</span> <span class="kt"><a href="../Protocols/PRNG.html">PRNG</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>A pseudo-random number generator (PRNG) that implements
|
||||
<a href="http://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf"><code>xorshift128+</code></a>, an efficient linear-feedback shift register.</p>
|
||||
<div class="aside aside-warning">
|
||||
<p class="aside-title">Warning</p>
|
||||
Once seeded from cryptographically secure random bytes, an
|
||||
instance of <code>Random</code> generates high-quality random numbers but is <em>not</em> a
|
||||
cryptographically secure PRNG.
|
||||
|
||||
</div>
|
||||
|
||||
<p>To generate random numbers, create your own instance of <code>Random</code> with an
|
||||
internal state seeded from cryptographically secure random bytes:</p>
|
||||
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">random</span> <span class="o">=</span> <span class="kt">Random</span><span class="p">()</span><span class="o">!</span>
|
||||
<span class="k">let</span> <span class="nv">x</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">()</span> <span class="k">as</span> <span class="kt">Int</span>
|
||||
|
||||
<span class="c1">// You can also pass the desired result type as an argument.</span>
|
||||
<span class="k">let</span> <span class="nv">y</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="kt">Int</span><span class="o">.</span><span class="k">self</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">x</span> <span class="o">></span> <span class="n">y</span> <span class="p">{</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="s">"Here's a random value between 0 and 42 (inclusive):"</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="mi">42</span><span class="p">))</span>
|
||||
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="s">"Here's a random value between -42 and 0 (inclusive):"</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="o">-</span><span class="mi">42</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="mi">0</span><span class="p">))</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
<div class="aside aside-see-also">
|
||||
<p class="aside-title">See also</p>
|
||||
<code><a href="../Classes/Random/Xoroshiro.html">Random.Xoroshiro</a></code>, <code><a href="../Protocols/PRNG.html">PRNG</a></code>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex6RandomC5states6UInt64V_AFtv">state</a></li>
|
||||
<li><a href="#/s:12NumericAnnex6RandomCACs6UInt64V_AEt5state_tcfc">init(state:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex6RandomCACSgycfc">init()</a></li>
|
||||
<li><a href="#/s:s16IteratorProtocolP4next7ElementQzSgyF">next()</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex6RandomC9XoroshiroC">Xoroshiro</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex6RandomC5states6UInt64V_AFtv"></a>
|
||||
<a name="//apple_ref/swift/Property/state" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>state</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>The internal state of the pseudo-random number generator.</p>
|
||||
|
||||
</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="k">var</span> <span class="nv">state</span><span class="p">:</span> <span class="p">(</span><span class="kt">UInt64</span><span class="p">,</span> <span class="kt">UInt64</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex6RandomCACs6UInt64V_AEt5state_tcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(state:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(state:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a pseudo-random number generator with the given internal state.</p>
|
||||
|
||||
</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="nf">init</span><span class="p">(</span><span class="nv">state</span><span class="p">:</span> <span class="p">(</span><span class="kt">UInt64</span><span class="p">,</span> <span class="kt">UInt64</span><span class="p">))</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>state</code></dt>
|
||||
<dd>
|
||||
<p>The value to be used as the generator’s internal state.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex6RandomCACSgycfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a pseudo-random number generator with an internal state seeded
|
||||
using cryptographically secure random bytes.</p>
|
||||
|
||||
<p>If cryptographically secure random bytes are unavailable, the result is
|
||||
<code>nil</code>.</p>
|
||||
|
||||
</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="n">convenience</span> <span class="nf">init</span><span class="p">?()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s16IteratorProtocolP4next7ElementQzSgyF"></a>
|
||||
<a name="//apple_ref/swift/Method/next()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>next()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">next</span><span class="p">()</span> <span class="o">-></span> <span class="kt">UInt64</span><span class="p">?</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex6RandomC9XoroshiroC"></a>
|
||||
<a name="//apple_ref/swift/Class/Xoroshiro" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Xoroshiro</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>A pseudo-random number generator (PRNG) that implements <code>xoroshiro128+</code>, a
|
||||
successor to <code>xorshift128+</code> devised by S. Vigna and D. Blackman.</p>
|
||||
<div class="aside aside-warning">
|
||||
<p class="aside-title">Warning</p>
|
||||
Once seeded from cryptographically secure random bytes, an
|
||||
instance of <code>Random.Xoroshiro</code> generates high-quality random numbers but
|
||||
is <em>not</em> a cryptographically secure PRNG.
|
||||
|
||||
</div>
|
||||
|
||||
<p>To generate random numbers, create your own instance of <code>Random.Xoroshiro</code>
|
||||
with an internal state seeded from cryptographically secure random bytes:</p>
|
||||
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">random</span> <span class="o">=</span> <span class="kt">Random</span><span class="o">.</span><span class="kt">Xoroshiro</span><span class="p">()</span><span class="o">!</span>
|
||||
<span class="k">let</span> <span class="nv">x</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">()</span> <span class="k">as</span> <span class="kt">Int</span>
|
||||
|
||||
<span class="c1">// You can also pass the desired result type as an argument.</span>
|
||||
<span class="k">let</span> <span class="nv">y</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="kt">Int</span><span class="o">.</span><span class="k">self</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">x</span> <span class="o">></span> <span class="n">y</span> <span class="p">{</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="s">"Here's a random value between 0 and 42 (inclusive):"</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="mi">42</span><span class="p">))</span>
|
||||
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="s">"Here's a random value between -42 and 0 (inclusive):"</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="o">-</span><span class="mi">42</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="mi">0</span><span class="p">))</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
<div class="aside aside-see-also">
|
||||
<p class="aside-title">See also</p>
|
||||
<code><a href="../Classes/Random.html">Random</a></code>, <code><a href="../Protocols/PRNG.html">PRNG</a></code>
|
||||
|
||||
</div>
|
||||
|
||||
<a href="../Classes/Random/Xoroshiro.html">See more…</a>
|
||||
</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">final</span> <span class="kd">class</span> <span class="kt">Xoroshiro</span> <span class="p">:</span> <span class="kt"><a href="../Protocols/PRNG.html">PRNG</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,330 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Xoroshiro Class 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/Class/Xoroshiro" class="dashAnchor"></a>
|
||||
<a title="Xoroshiro Class 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Xoroshiro</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">final</span> <span class="kd">class</span> <span class="kt">Xoroshiro</span> <span class="p">:</span> <span class="kt"><a href="../../Protocols/PRNG.html">PRNG</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>A pseudo-random number generator (PRNG) that implements <code>xoroshiro128+</code>, a
|
||||
successor to <code>xorshift128+</code> devised by S. Vigna and D. Blackman.</p>
|
||||
<div class="aside aside-warning">
|
||||
<p class="aside-title">Warning</p>
|
||||
Once seeded from cryptographically secure random bytes, an
|
||||
instance of <code>Random.Xoroshiro</code> generates high-quality random numbers but
|
||||
is <em>not</em> a cryptographically secure PRNG.
|
||||
|
||||
</div>
|
||||
|
||||
<p>To generate random numbers, create your own instance of <code>Random.Xoroshiro</code>
|
||||
with an internal state seeded from cryptographically secure random bytes:</p>
|
||||
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">random</span> <span class="o">=</span> <span class="kt">Random</span><span class="o">.</span><span class="kt">Xoroshiro</span><span class="p">()</span><span class="o">!</span>
|
||||
<span class="k">let</span> <span class="nv">x</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">()</span> <span class="k">as</span> <span class="kt">Int</span>
|
||||
|
||||
<span class="c1">// You can also pass the desired result type as an argument.</span>
|
||||
<span class="k">let</span> <span class="nv">y</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="kt">Int</span><span class="o">.</span><span class="k">self</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">x</span> <span class="o">></span> <span class="n">y</span> <span class="p">{</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="s">"Here's a random value between 0 and 42 (inclusive):"</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="mi">42</span><span class="p">))</span>
|
||||
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="s">"Here's a random value between -42 and 0 (inclusive):"</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="nf">uniform</span><span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="o">-</span><span class="mi">42</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="mi">0</span><span class="p">))</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
<div class="aside aside-see-also">
|
||||
<p class="aside-title">See also</p>
|
||||
<code><a href="../../Classes/Random.html">Random</a></code>, <code><a href="../../Protocols/PRNG.html">PRNG</a></code>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex6RandomC9XoroshiroC5states6UInt64V_AHtv">state</a></li>
|
||||
<li><a href="#/s:12NumericAnnex6RandomC9XoroshiroCAEs6UInt64V_AGt5state_tcfc">init(state:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex6RandomC9XoroshiroCAESgycfc">init()</a></li>
|
||||
<li><a href="#/s:s16IteratorProtocolP4next7ElementQzSgyF">next()</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex6RandomC9XoroshiroC5states6UInt64V_AHtv"></a>
|
||||
<a name="//apple_ref/swift/Property/state" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>state</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>The internal state of the pseudo-random number generator.</p>
|
||||
|
||||
</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="k">var</span> <span class="nv">state</span><span class="p">:</span> <span class="p">(</span><span class="kt">UInt64</span><span class="p">,</span> <span class="kt">UInt64</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex6RandomC9XoroshiroCAEs6UInt64V_AGt5state_tcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(state:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(state:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a pseudo-random number generator with the given internal state.</p>
|
||||
|
||||
</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="nf">init</span><span class="p">(</span><span class="nv">state</span><span class="p">:</span> <span class="p">(</span><span class="kt">UInt64</span><span class="p">,</span> <span class="kt">UInt64</span><span class="p">))</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>state</code></dt>
|
||||
<dd>
|
||||
<p>The value to be used as the generator’s internal state.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex6RandomC9XoroshiroCAESgycfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a pseudo-random number generator with an internal state seeded
|
||||
using cryptographically secure random bytes.</p>
|
||||
|
||||
<p>If cryptographically secure random bytes are unavailable, the result is
|
||||
<code>nil</code>.</p>
|
||||
|
||||
</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="n">convenience</span> <span class="nf">init</span><span class="p">?()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s16IteratorProtocolP4next7ElementQzSgyF"></a>
|
||||
<a name="//apple_ref/swift/Method/next()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>next()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">next</span><span class="p">()</span> <span class="o">-></span> <span class="kt">UInt64</span><span class="p">?</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,549 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Extensions 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 title="Extensions 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Extensions</h1>
|
||||
<p>The following extensions are available globally.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s13BinaryIntegerP">BinaryInteger</a></li>
|
||||
<li><a href="#/s:s15UnsignedIntegerP">UnsignedInteger</a></li>
|
||||
<li><a href="#/s:Si">Int</a></li>
|
||||
<li><a href="#/s:s4Int8V">Int8</a></li>
|
||||
<li><a href="#/s:s5Int16V">Int16</a></li>
|
||||
<li><a href="#/s:s5Int32V">Int32</a></li>
|
||||
<li><a href="#/s:s5Int64V">Int64</a></li>
|
||||
<li><a href="#/s:Su">UInt</a></li>
|
||||
<li><a href="#/s:s5UInt8V">UInt8</a></li>
|
||||
<li><a href="#/s:s6UInt16V">UInt16</a></li>
|
||||
<li><a href="#/s:s6UInt32V">UInt32</a></li>
|
||||
<li><a href="#/s:s6UInt64V">UInt64</a></li>
|
||||
<li><a href="#/">DoubleWidth</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:Sf">Float</a></li>
|
||||
<li><a href="#/s:Sd">Double</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:s13FloatingPointP">FloatingPoint</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP"></a>
|
||||
<a name="//apple_ref/swift/Extension/BinaryInteger" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>BinaryInteger</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/BinaryInteger.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">protocol</span> <span class="kt">BinaryInteger</span> <span class="p">:</span> <span class="kt">Hashable</span><span class="p">,</span> <span class="kt">Numeric</span><span class="p">,</span> <span class="kt">CustomStringConvertible</span><span class="p">,</span> <span class="kt">Strideable</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s15UnsignedIntegerP"></a>
|
||||
<a name="//apple_ref/swift/Extension/UnsignedInteger" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>UnsignedInteger</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/UnsignedInteger.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">protocol</span> <span class="kt">UnsignedInteger</span> <span class="p">:</span> <span class="kt">BinaryInteger</span> <span class="k">where</span> <span class="k">Self</span><span class="o">.</span><span class="kt">Magnitude</span> <span class="p">:</span> <span class="kt">BinaryInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:Si"></a>
|
||||
<a name="//apple_ref/swift/Extension/Int" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Int</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/Int.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s4Int8V"></a>
|
||||
<a name="//apple_ref/swift/Extension/Int8" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Int8</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/Int8.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int8</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int16V"></a>
|
||||
<a name="//apple_ref/swift/Extension/Int16" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Int16</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/Int16.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int16</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int32V"></a>
|
||||
<a name="//apple_ref/swift/Extension/Int32" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Int32</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/Int32.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int32</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int64V"></a>
|
||||
<a name="//apple_ref/swift/Extension/Int64" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Int64</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/Int64.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int64</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:Su"></a>
|
||||
<a name="//apple_ref/swift/Extension/UInt" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>UInt</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/UInt.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5UInt8V"></a>
|
||||
<a name="//apple_ref/swift/Extension/UInt8" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>UInt8</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/UInt8.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt8</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt16V"></a>
|
||||
<a name="//apple_ref/swift/Extension/UInt16" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>UInt16</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/UInt16.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt16</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt32V"></a>
|
||||
<a name="//apple_ref/swift/Extension/UInt32" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>UInt32</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/UInt32.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt32</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt64V"></a>
|
||||
<a name="//apple_ref/swift/Extension/UInt64" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>UInt64</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/UInt64.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt64</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/"></a>
|
||||
<a name="//apple_ref/swift/Extension/DoubleWidth" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>DoubleWidth</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/DoubleWidth.html">See more…</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:Sf"></a>
|
||||
<a name="//apple_ref/swift/Extension/Float" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Float</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/Float.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:Sd"></a>
|
||||
<a name="//apple_ref/swift/Extension/Double" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Double</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/Double.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13FloatingPointP"></a>
|
||||
<a name="//apple_ref/swift/Extension/FloatingPoint" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>FloatingPoint</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/FloatingPoint.html">See more…</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">protocol</span> <span class="kt">FloatingPoint</span> <span class="p">:</span> <span class="kt">SignedNumeric</span><span class="p">,</span> <span class="kt">Strideable</span><span class="p">,</span> <span class="kt">Hashable</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,564 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>BinaryInteger Extension 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/Extension/BinaryInteger" class="dashAnchor"></a>
|
||||
<a title="BinaryInteger Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>BinaryInteger</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">protocol</span> <span class="kt">BinaryInteger</span> <span class="p">:</span> <span class="kt">Hashable</span><span class="p">,</span> <span class="kt">Numeric</span><span class="p">,</span> <span class="kt">CustomStringConvertible</span><span class="p">,</span> <span class="kt">Strideable</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<p><a href="#/Exponentiation">Exponentiation</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexE2mmoixx_xtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexE3mmeoiyxz_xtFZ">**=(_:_:)</a></li>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexE3powxx_xtFZ">pow(_:_:)</a></li>
|
||||
</ul>
|
||||
<p><a href="#/Square%20Root">Square Root</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexE4sqrtxxFZ">sqrt(_:)</a></li>
|
||||
</ul>
|
||||
<p><a href="#/Cube%20Root">Cube Root</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexsAARzs08UnsignedB09MagnitudeRpzlE4cbrtxxFZ">cbrt(_:)</a></li>
|
||||
</ul>
|
||||
<p><a href="#/Factoring">Factoring</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexsAARzs08UnsignedB09MagnitudeRpzlE3gcdxx_xtFZ">gcd(_:_:)</a></li>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexsAARzs08UnsignedB09MagnitudeRpzlE3lcmxx_xtFZ">lcm(_:_:)</a></li>
|
||||
</ul>
|
||||
<p><a href="#/Factoring%20(Fixed-Width)">Factoring (Fixed-Width)</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexs010FixedWidthB0RzsAD9MagnitudeRpzs08UnsignedB0AFRQAE_AEs0C0PQZAFRSlE20gcdReportingOverflowx12partialValue_Sb8overflowtx_xtFZ">gcdReportingOverflow(_:_:)</a></li>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexs010FixedWidthB0RzsAD9MagnitudeRpzs08UnsignedB0AFRQAE_AEs0C0PQZAFRSlE20lcmReportingOverflowx12partialValue_Sb8overflowtx_xtFZ">lcmReportingOverflow(_:_:)</a></li>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexs010FixedWidthB0RzsAD9MagnitudeRpzs08UnsignedB0AFRQAE_AEs0C0PQZAFRSlE07lcmFullF0x4high_AF3lowtx_xtFZ">lcmFullWidth(_:_:)</a></li>
|
||||
</ul>
|
||||
<p><a href="#/Initializers">Initializers</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexExSgAC8RationalVyqd__G7exactly_tcs9DecodableRd__s9EncodableRd__s06SignedB0Rd__s021_ExpressibleByBuiltinB7LiteralRd__s08UnsignedB09Magnitudes0C0PRpd__AnP_ANQYd__AQRSlufc">init(exactly:)</a></li>
|
||||
<li><a href="#/s:s13BinaryIntegerP12NumericAnnexExAC8RationalVyqd__Gcs9DecodableRd__s9EncodableRd__s06SignedB0Rd__s021_ExpressibleByBuiltinB7LiteralRd__s08UnsignedB09Magnitudes0C0PRpd__AlN_ALQYd__AORSlufc">init(_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Exponentiation"></a>
|
||||
<a name="//apple_ref/swift/Section/Exponentiation" class="dashAnchor"></a>
|
||||
<h3>Exponentiation</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexE2mmoixx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexE3mmeoiyxz_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="k">Self</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexE3powxx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/pow(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>pow(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>base</code> to the power of <code>exponent</code>, rounded
|
||||
to a representable value (deprecated).</p>
|
||||
|
||||
</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">pow</span><span class="p">(</span><span class="n">_</span> <span class="nv">base</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">exponent</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Square%20Root"></a>
|
||||
<a name="//apple_ref/swift/Section/Square Root" class="dashAnchor"></a>
|
||||
<h3>Square Root</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexE4sqrtxxFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/sqrt(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>sqrt(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the square root of <code>x</code>, rounding toward zero. If <code>x</code> is negative,
|
||||
a runtime error may occur.</p>
|
||||
|
||||
</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">sqrt</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">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Cube%20Root"></a>
|
||||
<a name="//apple_ref/swift/Section/Cube Root" class="dashAnchor"></a>
|
||||
<h3>Cube Root</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexsAARzs08UnsignedB09MagnitudeRpzlE4cbrtxxFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/cbrt(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>cbrt(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the cube root of <code>x</code>, rounding toward zero.</p>
|
||||
|
||||
</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">cbrt</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">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Factoring"></a>
|
||||
<a name="//apple_ref/swift/Section/Factoring" class="dashAnchor"></a>
|
||||
<h3>Factoring</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexsAARzs08UnsignedB09MagnitudeRpzlE3gcdxx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/gcd(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>gcd(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the greatest common divisor of <code>a</code> and <code>b</code>.</p>
|
||||
|
||||
</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">gcd</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexsAARzs08UnsignedB09MagnitudeRpzlE3lcmxx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/lcm(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>lcm(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the least common multiple of <code>a</code> and <code>b</code>.</p>
|
||||
|
||||
</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">lcm</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Factoring%20(Fixed-Width)"></a>
|
||||
<a name="//apple_ref/swift/Section/Factoring (Fixed-Width)" class="dashAnchor"></a>
|
||||
<h3>Factoring (Fixed-Width)</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexs010FixedWidthB0RzsAD9MagnitudeRpzs08UnsignedB0AFRQAE_AEs0C0PQZAFRSlE20gcdReportingOverflowx12partialValue_Sb8overflowtx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/gcdReportingOverflow(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>gcdReportingOverflow(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the greatest common divisor of <code>a</code> and <code>b</code> and a flag to indicate
|
||||
whether overflow occurred during the operation.</p>
|
||||
|
||||
</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">gcdReportingOverflow</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span>
|
||||
<span class="o">-></span> <span class="p">(</span><span class="nv">partialValue</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="nv">overflow</span><span class="p">:</span> <span class="kt">Bool</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexs010FixedWidthB0RzsAD9MagnitudeRpzs08UnsignedB0AFRQAE_AEs0C0PQZAFRSlE20lcmReportingOverflowx12partialValue_Sb8overflowtx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/lcmReportingOverflow(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>lcmReportingOverflow(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the least common multiple of <code>a</code> and <code>b</code> and a flag to indicate
|
||||
whether overflow occurred during the operation.</p>
|
||||
|
||||
</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">lcmReportingOverflow</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span>
|
||||
<span class="o">-></span> <span class="p">(</span><span class="nv">partialValue</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="nv">overflow</span><span class="p">:</span> <span class="kt">Bool</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexs010FixedWidthB0RzsAD9MagnitudeRpzs08UnsignedB0AFRQAE_AEs0C0PQZAFRSlE07lcmFullF0x4high_AF3lowtx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/lcmFullWidth(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>lcmFullWidth(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the high and low parts of the least common multiple of <code>a</code> and <code>b</code>
|
||||
computed using full-width arithmetic.</p>
|
||||
|
||||
</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">lcmFullWidth</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span>
|
||||
<span class="o">-></span> <span class="p">(</span><span class="nv">high</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="nv">low</span><span class="p">:</span> <span class="k">Self</span><span class="o">.</span><span class="kt">Magnitude</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Initializers"></a>
|
||||
<a name="//apple_ref/swift/Section/Initializers" class="dashAnchor"></a>
|
||||
<h3>Initializers</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexExSgAC8RationalVyqd__G7exactly_tcs9DecodableRd__s9EncodableRd__s06SignedB0Rd__s021_ExpressibleByBuiltinB7LiteralRd__s08UnsignedB09Magnitudes0C0PRpd__AnP_ANQYd__AQRSlufc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(exactly:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(exactly:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a new binary integer from the given rational value, if it can be
|
||||
represented exactly.</p>
|
||||
|
||||
<p>If <code>source</code> is not representable exactly, the result is <code>nil</code>.</p>
|
||||
|
||||
</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">init</span><span class="p">?</span><span class="o"><</span><span class="kt">U</span><span class="o">></span><span class="p">(</span><span class="n">exactly</span> <span class="nv">source</span><span class="p">:</span> <span class="kt"><a href="../Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">U</span><span class="o">></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>source</code></dt>
|
||||
<dd>
|
||||
<p>A rational value to convert to a binary integer.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13BinaryIntegerP12NumericAnnexExAC8RationalVyqd__Gcs9DecodableRd__s9EncodableRd__s06SignedB0Rd__s021_ExpressibleByBuiltinB7LiteralRd__s08UnsignedB09Magnitudes0C0PRpd__AlN_ALQYd__AORSlufc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a new binary integer from the given rational value, rounding
|
||||
toward zero.</p>
|
||||
|
||||
<p>If <code>source</code> is outside the bounds of this type after rounding toward zero,
|
||||
a runtime error may occur.</p>
|
||||
|
||||
</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">init</span><span class="o"><</span><span class="kt">U</span><span class="o">></span><span class="p">(</span><span class="n">_</span> <span class="nv">source</span><span class="p">:</span> <span class="kt"><a href="../Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">U</span><span class="o">></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>source</code></dt>
|
||||
<dd>
|
||||
<p>A rational value to convert to a binary integer.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,856 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Double Extension 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/Extension/Double" class="dashAnchor"></a>
|
||||
<a title="Double Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Double</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<p><a href="#/Real">Real</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4MathP1exvZ">e</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP3phixvZ">phi</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP2mmoixx_xtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP3mmeoiyxz_xtFZ">**=(_:_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP18naturalExponentialxyF">naturalExponential()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP17binaryExponentialxyF">binaryExponential()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP17commonExponentialxyF">commonExponential()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP26naturalExponentialMinusOnexyF">naturalExponentialMinusOne()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP16naturalLogarithmxyF">naturalLogarithm()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP15binaryLogarithmxyF">binaryLogarithm()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP15commonLogarithmxyF">commonLogarithm()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP23naturalLogarithmOnePlusxyF">naturalLogarithmOnePlus()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP8cubeRootxyF">cubeRoot()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP4sinexyF">sine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP6cosinexyF">cosine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP7tangentxyF">tangent()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP11inverseSinexyF">inverseSine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP13inverseCosinexyF">inverseCosine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP14inverseTangentxyF">inverseTangent()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP14hyperbolicSinexyF">hyperbolicSine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP16hyperbolicCosinexyF">hyperbolicCosine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP17hyperbolicTangentxyF">hyperbolicTangent()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP21inverseHyperbolicSinexyF">inverseHyperbolicSine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP23inverseHyperbolicCosinexyF">inverseHyperbolicCosine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP24inverseHyperbolicTangentxyF">inverseHyperbolicTangent()</a></li>
|
||||
<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>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Real"></a>
|
||||
<a name="//apple_ref/swift/Section/Real" class="dashAnchor"></a>
|
||||
<h3>Real</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP1exvZ"></a>
|
||||
<a name="//apple_ref/swift/Variable/e" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>e</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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="k">var</span> <span class="nv">e</span><span class="p">:</span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP3phixvZ"></a>
|
||||
<a name="//apple_ref/swift/Variable/phi" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>phi</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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="k">var</span> <span class="nv">phi</span><span class="p">:</span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP2mmoixx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">Double</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Double</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP3mmeoiyxz_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Double</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Double</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP18naturalExponentialxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/naturalExponential()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>naturalExponential()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">naturalExponential</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP17binaryExponentialxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/binaryExponential()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>binaryExponential()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">binaryExponential</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP17commonExponentialxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/commonExponential()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>commonExponential()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">commonExponential</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP26naturalExponentialMinusOnexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/naturalExponentialMinusOne()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>naturalExponentialMinusOne()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">naturalExponentialMinusOne</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP16naturalLogarithmxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/naturalLogarithm()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>naturalLogarithm()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">naturalLogarithm</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP15binaryLogarithmxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/binaryLogarithm()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>binaryLogarithm()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">binaryLogarithm</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP15commonLogarithmxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/commonLogarithm()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>commonLogarithm()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">commonLogarithm</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP23naturalLogarithmOnePlusxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/naturalLogarithmOnePlus()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>naturalLogarithmOnePlus()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">naturalLogarithmOnePlus</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP8cubeRootxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/cubeRoot()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>cubeRoot()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP4sinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/sine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>sine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">sine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP6cosinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/cosine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>cosine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">cosine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP7tangentxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/tangent()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>tangent()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">tangent</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP11inverseSinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseSine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseSine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseSine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP13inverseCosinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseCosine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseCosine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseCosine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP14inverseTangentxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseTangent()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseTangent()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseTangent</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP14hyperbolicSinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/hyperbolicSine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>hyperbolicSine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">hyperbolicSine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP16hyperbolicCosinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/hyperbolicCosine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>hyperbolicCosine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">hyperbolicCosine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP17hyperbolicTangentxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/hyperbolicTangent()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>hyperbolicTangent()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">hyperbolicTangent</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP21inverseHyperbolicSinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseHyperbolicSine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseHyperbolicSine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseHyperbolicSine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP23inverseHyperbolicCosinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseHyperbolicCosine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseHyperbolicCosine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseHyperbolicCosine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP24inverseHyperbolicTangentxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseHyperbolicTangent()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseHyperbolicTangent()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseHyperbolicTangent</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4RealP5hypotxx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/hypot(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>hypot(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">hypot</span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="kt">Double</span><span class="p">,</span> <span class="n">_</span> <span class="nv">y</span><span class="p">:</span> <span class="kt">Double</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</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>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseTangent</span><span class="p">(</span><span class="n">dividingBy</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">Double</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</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">
|
||||
|
||||
</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">error</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</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">
|
||||
|
||||
</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">complementaryError</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</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">
|
||||
|
||||
</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">gamma</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</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">
|
||||
|
||||
</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">logarithmicGamma</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Double</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,223 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>DoubleWidth Extension 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/Extension/DoubleWidth" class="dashAnchor"></a>
|
||||
<a title="DoubleWidth Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>DoubleWidth</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/">**(_:_:)</a></li>
|
||||
<li><a href="#/">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,856 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Float Extension 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/Extension/Float" class="dashAnchor"></a>
|
||||
<a title="Float Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Float</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<p><a href="#/Real">Real</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4MathP1exvZ">e</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP3phixvZ">phi</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP2mmoixx_xtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP3mmeoiyxz_xtFZ">**=(_:_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP18naturalExponentialxyF">naturalExponential()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP17binaryExponentialxyF">binaryExponential()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP17commonExponentialxyF">commonExponential()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP26naturalExponentialMinusOnexyF">naturalExponentialMinusOne()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP16naturalLogarithmxyF">naturalLogarithm()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP15binaryLogarithmxyF">binaryLogarithm()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP15commonLogarithmxyF">commonLogarithm()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP23naturalLogarithmOnePlusxyF">naturalLogarithmOnePlus()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP8cubeRootxyF">cubeRoot()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP4sinexyF">sine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP6cosinexyF">cosine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP7tangentxyF">tangent()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP11inverseSinexyF">inverseSine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP13inverseCosinexyF">inverseCosine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP14inverseTangentxyF">inverseTangent()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP14hyperbolicSinexyF">hyperbolicSine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP16hyperbolicCosinexyF">hyperbolicCosine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP17hyperbolicTangentxyF">hyperbolicTangent()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP21inverseHyperbolicSinexyF">inverseHyperbolicSine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP23inverseHyperbolicCosinexyF">inverseHyperbolicCosine()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4MathP24inverseHyperbolicTangentxyF">inverseHyperbolicTangent()</a></li>
|
||||
<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>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Real"></a>
|
||||
<a name="//apple_ref/swift/Section/Real" class="dashAnchor"></a>
|
||||
<h3>Real</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP1exvZ"></a>
|
||||
<a name="//apple_ref/swift/Variable/e" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>e</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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="k">var</span> <span class="nv">e</span><span class="p">:</span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP3phixvZ"></a>
|
||||
<a name="//apple_ref/swift/Variable/phi" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>phi</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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="k">var</span> <span class="nv">phi</span><span class="p">:</span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP2mmoixx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">Float</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Float</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP3mmeoiyxz_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Float</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Float</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP18naturalExponentialxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/naturalExponential()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>naturalExponential()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">naturalExponential</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP17binaryExponentialxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/binaryExponential()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>binaryExponential()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">binaryExponential</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP17commonExponentialxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/commonExponential()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>commonExponential()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">commonExponential</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP26naturalExponentialMinusOnexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/naturalExponentialMinusOne()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>naturalExponentialMinusOne()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">naturalExponentialMinusOne</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP16naturalLogarithmxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/naturalLogarithm()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>naturalLogarithm()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">naturalLogarithm</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP15binaryLogarithmxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/binaryLogarithm()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>binaryLogarithm()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">binaryLogarithm</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP15commonLogarithmxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/commonLogarithm()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>commonLogarithm()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">commonLogarithm</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP23naturalLogarithmOnePlusxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/naturalLogarithmOnePlus()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>naturalLogarithmOnePlus()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">naturalLogarithmOnePlus</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP8cubeRootxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/cubeRoot()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>cubeRoot()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP4sinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/sine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>sine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">sine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP6cosinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/cosine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>cosine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">cosine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP7tangentxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/tangent()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>tangent()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">tangent</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP11inverseSinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseSine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseSine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseSine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP13inverseCosinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseCosine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseCosine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseCosine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP14inverseTangentxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseTangent()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseTangent()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseTangent</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP14hyperbolicSinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/hyperbolicSine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>hyperbolicSine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">hyperbolicSine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP16hyperbolicCosinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/hyperbolicCosine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>hyperbolicCosine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">hyperbolicCosine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP17hyperbolicTangentxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/hyperbolicTangent()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>hyperbolicTangent()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">hyperbolicTangent</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP21inverseHyperbolicSinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseHyperbolicSine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseHyperbolicSine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseHyperbolicSine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP23inverseHyperbolicCosinexyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseHyperbolicCosine()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseHyperbolicCosine()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseHyperbolicCosine</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP24inverseHyperbolicTangentxyF"></a>
|
||||
<a name="//apple_ref/swift/Method/inverseHyperbolicTangent()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>inverseHyperbolicTangent()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseHyperbolicTangent</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4RealP5hypotxx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/hypot(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>hypot(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">hypot</span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="kt">Float</span><span class="p">,</span> <span class="n">_</span> <span class="nv">y</span><span class="p">:</span> <span class="kt">Float</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</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>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
|
||||
</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">inverseTangent</span><span class="p">(</span><span class="n">dividingBy</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">Float</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</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">
|
||||
|
||||
</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">error</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</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">
|
||||
|
||||
</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">complementaryError</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</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">
|
||||
|
||||
</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">gamma</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</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">
|
||||
|
||||
</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">logarithmicGamma</span><span class="p">()</span> <span class="o">-></span> <span class="kt">Float</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,390 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>FloatingPoint Extension 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/Extension/FloatingPoint" class="dashAnchor"></a>
|
||||
<a title="FloatingPoint Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>FloatingPoint</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">protocol</span> <span class="kt">FloatingPoint</span> <span class="p">:</span> <span class="kt">SignedNumeric</span><span class="p">,</span> <span class="kt">Strideable</span><span class="p">,</span> <span class="kt">Hashable</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<p><a href="#/Initializers">Initializers</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s13FloatingPointP12NumericAnnexExAC8RationalVySiGcfc">init(_:)</a></li>
|
||||
<li><a href="#/s:s13FloatingPointP12NumericAnnexExAC8RationalVys4Int8VGcfc">init(_:)</a></li>
|
||||
<li><a href="#/s:s13FloatingPointP12NumericAnnexExAC8RationalVys5Int16VGcfc">init(_:)</a></li>
|
||||
<li><a href="#/s:s13FloatingPointP12NumericAnnexExAC8RationalVys5Int32VGcfc">init(_:)</a></li>
|
||||
<li><a href="#/s:s13FloatingPointP12NumericAnnexExAC8RationalVys5Int64VGcfc">init(_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Initializers"></a>
|
||||
<a name="//apple_ref/swift/Section/Initializers" class="dashAnchor"></a>
|
||||
<h3>Initializers</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13FloatingPointP12NumericAnnexExAC8RationalVySiGcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a new floating-point value from the given rational value, after
|
||||
rounding the whole part, the numerator of the fractional part, and the
|
||||
denominator of the fractional part each to the closest possible
|
||||
representation.</p>
|
||||
|
||||
<p>If two representable values are equally close, the result of rounding is
|
||||
the value with more trailing zeros in its significand bit pattern.</p>
|
||||
|
||||
</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="nf">init</span><span class="p">(</span><span class="n">_</span> <span class="nv">source</span><span class="p">:</span> <span class="kt"><a href="../Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">Int</span><span class="o">></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>source</code></dt>
|
||||
<dd>
|
||||
<p>The rational value to convert to a floating-point value.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13FloatingPointP12NumericAnnexExAC8RationalVys4Int8VGcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a new floating-point value from the given rational value, after
|
||||
rounding the whole part, the numerator of the fractional part, and the
|
||||
denominator of the fractional part each to the closest possible
|
||||
representation.</p>
|
||||
|
||||
<p>If two representable values are equally close, the result of rounding is
|
||||
the value with more trailing zeros in its significand bit pattern.</p>
|
||||
|
||||
</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="nf">init</span><span class="p">(</span><span class="n">_</span> <span class="nv">source</span><span class="p">:</span> <span class="kt"><a href="../Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">Int8</span><span class="o">></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>source</code></dt>
|
||||
<dd>
|
||||
<p>The rational value to convert to a floating-point value.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13FloatingPointP12NumericAnnexExAC8RationalVys5Int16VGcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a new floating-point value from the given rational value, after
|
||||
rounding the whole part, the numerator of the fractional part, and the
|
||||
denominator of the fractional part each to the closest possible
|
||||
representation.</p>
|
||||
|
||||
<p>If two representable values are equally close, the result of rounding is
|
||||
the value with more trailing zeros in its significand bit pattern.</p>
|
||||
|
||||
</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="nf">init</span><span class="p">(</span><span class="n">_</span> <span class="nv">source</span><span class="p">:</span> <span class="kt"><a href="../Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">Int16</span><span class="o">></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>source</code></dt>
|
||||
<dd>
|
||||
<p>The rational value to convert to a floating-point value.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13FloatingPointP12NumericAnnexExAC8RationalVys5Int32VGcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a new floating-point value from the given rational value, after
|
||||
rounding the whole part, the numerator of the fractional part, and the
|
||||
denominator of the fractional part each to the closest possible
|
||||
representation.</p>
|
||||
|
||||
<p>If two representable values are equally close, the result of rounding is
|
||||
the value with more trailing zeros in its significand bit pattern.</p>
|
||||
|
||||
</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="nf">init</span><span class="p">(</span><span class="n">_</span> <span class="nv">source</span><span class="p">:</span> <span class="kt"><a href="../Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">Int32</span><span class="o">></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>source</code></dt>
|
||||
<dd>
|
||||
<p>The rational value to convert to a floating-point value.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s13FloatingPointP12NumericAnnexExAC8RationalVys5Int64VGcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a new floating-point value from the given rational value, after
|
||||
rounding the whole part, the numerator of the fractional part, and the
|
||||
denominator of the fractional part each to the closest possible
|
||||
representation.</p>
|
||||
|
||||
<p>If two representable values are equally close, the result of rounding is
|
||||
the value with more trailing zeros in its significand bit pattern.</p>
|
||||
|
||||
</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="nf">init</span><span class="p">(</span><span class="n">_</span> <span class="nv">source</span><span class="p">:</span> <span class="kt"><a href="../Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">Int64</span><span class="o">></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>source</code></dt>
|
||||
<dd>
|
||||
<p>The rational value to convert to a floating-point value.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Int Extension 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/Extension/Int" class="dashAnchor"></a>
|
||||
<a title="Int Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Int</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:Si12NumericAnnexE2mmoiS2i_SitFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:Si12NumericAnnexE3mmeoiySiz_SitFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:Si12NumericAnnexE2mmoiS2i_SitFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">Int</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:Si12NumericAnnexE3mmeoiySiz_SitFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Int</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Int16 Extension 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/Extension/Int16" class="dashAnchor"></a>
|
||||
<a title="Int16 Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Int16</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int16</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s5Int16V12NumericAnnexE2mmoiA2B_ABtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s5Int16V12NumericAnnexE3mmeoiyABz_ABtFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int16V12NumericAnnexE2mmoiA2B_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">Int16</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int16</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Int16</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int16V12NumericAnnexE3mmeoiyABz_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Int16</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int16</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Int32 Extension 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/Extension/Int32" class="dashAnchor"></a>
|
||||
<a title="Int32 Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Int32</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int32</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s5Int32V12NumericAnnexE2mmoiA2B_ABtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s5Int32V12NumericAnnexE3mmeoiyABz_ABtFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int32V12NumericAnnexE2mmoiA2B_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">Int32</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int32</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Int32</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int32V12NumericAnnexE3mmeoiyABz_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Int32</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int32</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Int64 Extension 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/Extension/Int64" class="dashAnchor"></a>
|
||||
<a title="Int64 Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Int64</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int64</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s5Int64V12NumericAnnexE2mmoiA2B_ABtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s5Int64V12NumericAnnexE3mmeoiyABz_ABtFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int64V12NumericAnnexE2mmoiA2B_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">Int64</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int64</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Int64</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5Int64V12NumericAnnexE3mmeoiyABz_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Int64</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int64</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Int8 Extension 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/Extension/Int8" class="dashAnchor"></a>
|
||||
<a title="Int8 Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Int8</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">Int8</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">SignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s4Int8V12NumericAnnexE2mmoiA2B_ABtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s4Int8V12NumericAnnexE3mmeoiyABz_ABtFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s4Int8V12NumericAnnexE2mmoiA2B_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">Int8</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int8</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Int8</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s4Int8V12NumericAnnexE3mmeoiyABz_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Int8</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">Int8</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>UInt Extension 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/Extension/UInt" class="dashAnchor"></a>
|
||||
<a title="UInt Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>UInt</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:Su12NumericAnnexE2mmoiS2u_SutFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:Su12NumericAnnexE3mmeoiySuz_SutFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:Su12NumericAnnexE2mmoiS2u_SutFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span> <span class="o">-></span> <span class="kt">UInt</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:Su12NumericAnnexE3mmeoiySuz_SutFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">UInt</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>UInt16 Extension 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/Extension/UInt16" class="dashAnchor"></a>
|
||||
<a title="UInt16 Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>UInt16</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt16</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s6UInt16V12NumericAnnexE2mmoiA2B_ABtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s6UInt16V12NumericAnnexE3mmeoiyABz_ABtFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt16V12NumericAnnexE2mmoiA2B_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">UInt16</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt16</span><span class="p">)</span> <span class="o">-></span> <span class="kt">UInt16</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt16V12NumericAnnexE3mmeoiyABz_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">UInt16</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt16</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>UInt32 Extension 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/Extension/UInt32" class="dashAnchor"></a>
|
||||
<a title="UInt32 Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>UInt32</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt32</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s6UInt32V12NumericAnnexE2mmoiA2B_ABtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s6UInt32V12NumericAnnexE3mmeoiyABz_ABtFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt32V12NumericAnnexE2mmoiA2B_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">UInt32</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt32</span><span class="p">)</span> <span class="o">-></span> <span class="kt">UInt32</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt32V12NumericAnnexE3mmeoiyABz_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">UInt32</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt32</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>UInt64 Extension 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/Extension/UInt64" class="dashAnchor"></a>
|
||||
<a title="UInt64 Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>UInt64</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt64</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s6UInt64V12NumericAnnexE2mmoiA2B_ABtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s6UInt64V12NumericAnnexE3mmeoiyABz_ABtFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt64V12NumericAnnexE2mmoiA2B_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">UInt64</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt64</span><span class="p">)</span> <span class="o">-></span> <span class="kt">UInt64</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s6UInt64V12NumericAnnexE3mmeoiyABz_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">UInt64</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt64</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,245 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>UInt8 Extension 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/Extension/UInt8" class="dashAnchor"></a>
|
||||
<a title="UInt8 Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>UInt8</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UInt8</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span><span class="p">,</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:s5UInt8V12NumericAnnexE2mmoiA2B_ABtFZ">**(_:_:)</a></li>
|
||||
<li><a href="#/s:s5UInt8V12NumericAnnexE3mmeoiyABz_ABtFZ">**=(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5UInt8V12NumericAnnexE2mmoiA2B_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the result of raising <code>lhs</code> to the power of <code>rhs</code>, rounded to a
|
||||
representable value.</p>
|
||||
|
||||
</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="o">**</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="kt">UInt8</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt8</span><span class="p">)</span> <span class="o">-></span> <span class="kt">UInt8</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s5UInt8V12NumericAnnexE3mmeoiyABz_ABtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/**=(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>**=(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Raises <code>lhs</code> to the power of <code>rhs</code> and stores the result in <code>lhs</code>, rounded
|
||||
to a representable value.</p>
|
||||
|
||||
</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="o">**=</span> <span class="p">(</span><span class="nv">lhs</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">UInt8</span><span class="p">,</span> <span class="nv">rhs</span><span class="p">:</span> <span class="kt">UInt8</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,343 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>UnsignedInteger Extension 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/Extension/UnsignedInteger" class="dashAnchor"></a>
|
||||
<a title="UnsignedInteger Extension 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>UnsignedInteger</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">protocol</span> <span class="kt">UnsignedInteger</span> <span class="p">:</span> <span class="kt">BinaryInteger</span> <span class="k">where</span> <span class="k">Self</span><span class="o">.</span><span class="kt">Magnitude</span> <span class="p">:</span> <span class="kt">BinaryInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<p><a href="#/Cube%20Root">Cube Root</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s15UnsignedIntegerP12NumericAnnexE4cbrtxxFZ">cbrt(_:)</a></li>
|
||||
</ul>
|
||||
<p><a href="#/Factoring">Factoring</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s15UnsignedIntegerP12NumericAnnexE3gcdxx_xtFZ">gcd(_:_:)</a></li>
|
||||
<li><a href="#/s:s15UnsignedIntegerP12NumericAnnexE3lcmxx_xtFZ">lcm(_:_:)</a></li>
|
||||
</ul>
|
||||
<p><a href="#/Factoring%20(Fixed-Width)">Factoring (Fixed-Width)</a></p>
|
||||
<ul>
|
||||
<li><a href="#/s:s15UnsignedIntegerP12NumericAnnexs010FixedWidthB0RzsAARzlE20lcmReportingOverflowx12partialValue_Sb8overflowtx_xtFZ">lcmReportingOverflow(_:_:)</a></li>
|
||||
<li><a href="#/s:s15UnsignedIntegerP12NumericAnnexs010FixedWidthB0RzsAARzlE07lcmFullF0x4high_9Magnitudes0C0PQz3lowtx_xtFZ">lcmFullWidth(_:_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Cube%20Root"></a>
|
||||
<a name="//apple_ref/swift/Section/Cube Root" class="dashAnchor"></a>
|
||||
<h3>Cube Root</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s15UnsignedIntegerP12NumericAnnexE4cbrtxxFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/cbrt(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>cbrt(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the cube root of <code>x</code>, rounding toward zero.</p>
|
||||
|
||||
</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">cbrt</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">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Factoring"></a>
|
||||
<a name="//apple_ref/swift/Section/Factoring" class="dashAnchor"></a>
|
||||
<h3>Factoring</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s15UnsignedIntegerP12NumericAnnexE3gcdxx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/gcd(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>gcd(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the greatest common divisor of <code>a</code> and <code>b</code>.</p>
|
||||
|
||||
</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">gcd</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s15UnsignedIntegerP12NumericAnnexE3lcmxx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/lcm(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>lcm(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the least common multiple of <code>a</code> and <code>b</code>.</p>
|
||||
|
||||
</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">lcm</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span> <span class="o">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<div>
|
||||
<a name="/Factoring%20(Fixed-Width)"></a>
|
||||
<a name="//apple_ref/swift/Section/Factoring (Fixed-Width)" class="dashAnchor"></a>
|
||||
<h3>Factoring (Fixed-Width)</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s15UnsignedIntegerP12NumericAnnexs010FixedWidthB0RzsAARzlE20lcmReportingOverflowx12partialValue_Sb8overflowtx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/lcmReportingOverflow(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>lcmReportingOverflow(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the least common multiple of <code>a</code> and <code>b</code> and a flag to indicate
|
||||
whether overflow occurred during the operation.</p>
|
||||
|
||||
</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">lcmReportingOverflow</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span>
|
||||
<span class="o">-></span> <span class="p">(</span><span class="nv">partialValue</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="nv">overflow</span><span class="p">:</span> <span class="kt">Bool</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:s15UnsignedIntegerP12NumericAnnexs010FixedWidthB0RzsAARzlE07lcmFullF0x4high_9Magnitudes0C0PQz3lowtx_xtFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/lcmFullWidth(_:_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>lcmFullWidth(_:_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the high and low parts of the least common multiple of <code>a</code> and <code>b</code>
|
||||
computed using full-width arithmetic.</p>
|
||||
|
||||
</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">lcmFullWidth</span><span class="p">(</span><span class="n">_</span> <span class="nv">a</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="n">_</span> <span class="nv">b</span><span class="p">:</span> <span class="k">Self</span><span class="p">)</span>
|
||||
<span class="o">-></span> <span class="p">(</span><span class="nv">high</span><span class="p">:</span> <span class="k">Self</span><span class="p">,</span> <span class="nv">low</span><span class="p">:</span> <span class="k">Self</span><span class="o">.</span><span class="kt">Magnitude</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,355 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Functions 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 title="Functions 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Functions</h1>
|
||||
<p>The following functions are available globally.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex3absAA7ComplexVyxGAeA4RealRzs9DecodableRzs9EncodableRzs33_ExpressibleByBuiltinFloatLiteralRzlF">abs(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4sqrtAA7ComplexVyxGAeA4RealRzs9DecodableRzs9EncodableRzs33_ExpressibleByBuiltinFloatLiteralRzlF">sqrt(_:)</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex3absAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF">abs(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4ceilAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF">ceil(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex5floorAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF">floor(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex5roundAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF">round(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex5truncAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF">trunc(_:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex3absAA7ComplexVyxGAeA4RealRzs9DecodableRzs9EncodableRzs33_ExpressibleByBuiltinFloatLiteralRzlF"></a>
|
||||
<a name="//apple_ref/swift/Function/abs(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>abs(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the absolute value (magnitude, modulus) of <code>z</code>.</p>
|
||||
|
||||
</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="n">abs</span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">(</span><span class="n">_</span> <span class="nv">z</span><span class="p">:</span> <span class="kt"><a href="Structs/Complex.html">Complex</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="Structs/Complex.html">Complex</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4sqrtAA7ComplexVyxGAeA4RealRzs9DecodableRzs9EncodableRzs33_ExpressibleByBuiltinFloatLiteralRzlF"></a>
|
||||
<a name="//apple_ref/swift/Function/sqrt(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>sqrt(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the square root of <code>z</code>.</p>
|
||||
|
||||
</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="n">sqrt</span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">(</span><span class="n">_</span> <span class="nv">z</span><span class="p">:</span> <span class="kt"><a href="Structs/Complex.html">Complex</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="Structs/Complex.html">Complex</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex3absAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF"></a>
|
||||
<a name="//apple_ref/swift/Function/abs(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>abs(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the absolute value (magnitude) of <code>x</code>.</p>
|
||||
|
||||
</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="n">abs</span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4ceilAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF"></a>
|
||||
<a name="//apple_ref/swift/Function/ceil(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>ceil(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the closest integral value greater than or equal to <code>x</code>.</p>
|
||||
|
||||
</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="n">ceil</span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex5floorAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF"></a>
|
||||
<a name="//apple_ref/swift/Function/floor(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>floor(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the closest integral value less than or equal to <code>x</code>.</p>
|
||||
|
||||
</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="n">floor</span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex5roundAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF"></a>
|
||||
<a name="//apple_ref/swift/Function/round(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>round(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the closest integral value; if two values are equally close, returns
|
||||
the one with greater magnitude.</p>
|
||||
|
||||
</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="n">round</span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex5truncAA8RationalVyxGAEs9DecodableRzs9EncodableRzs13SignedIntegerRzs021_ExpressibleByBuiltinH7LiteralRzs08UnsignedH09Magnitudes0A0PRpzAkM_AKQZANRSlF"></a>
|
||||
<a name="//apple_ref/swift/Function/trunc(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>trunc(_:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns the closest integral value with magnitude less than or equal to that
|
||||
of <code>x</code>.</p>
|
||||
|
||||
</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="n">trunc</span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">(</span><span class="n">_</span> <span class="nv">x</span><span class="p">:</span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="Structs/Rational.html">Rational</a></span><span class="o"><</span><span class="kt">T</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,319 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Protocols 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 title="Protocols 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Protocols</h1>
|
||||
<p>The following protocols are available globally.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGP">PRNG</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4RealP">Real</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4MathP">Math</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGP"></a>
|
||||
<a name="//apple_ref/swift/Protocol/PRNG" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>PRNG</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>A pseudo-random number generator (PRNG).</p>
|
||||
|
||||
<p>Reference types that conform to <code>PRNG</code> are infinite sequences of
|
||||
pseudo-random elements. Protocol extension methods iterate over such a
|
||||
sequence as necessary to generate pseudo-random values from the desired
|
||||
distribution.</p>
|
||||
<h2 id='considerations-for-conforming-types' class='heading'>Considerations for Conforming Types</h2>
|
||||
|
||||
<p>For clarity to end users, custom PRNGs may be implemented in an extension to
|
||||
<code><a href="Classes/Random.html">Random</a></code>. For instance, the <code>xoroshiro128+</code> algorithm is implemented in a
|
||||
final class named <code><a href="Classes/Random/Xoroshiro.html">Random.Xoroshiro</a></code>.</p>
|
||||
|
||||
<p>The static methods <code>_entropy(_:)</code> and <code>_entropy(_:count:)</code> return
|
||||
cryptographically secure random bytes that may be useful for seeding your
|
||||
custom PRNG. However, these methods may return <code>nil</code> if the requested number
|
||||
of random bytes is not available, and they are not recommended as a routine
|
||||
source of random data.</p>
|
||||
<h2 id='adding-other-probability-distributions' class='heading'>Adding Other Probability Distributions</h2>
|
||||
|
||||
<p>Many built-in protocol extension methods make use of the primitive,
|
||||
overloaded method <code>_random(_:bitCount:)</code>. You may wish to use the same
|
||||
method in new protocol extension methods that return pseudo-random
|
||||
values from other probability distributions.</p>
|
||||
|
||||
<p>The method <code>_random(_:bitCount:)</code> generates uniformly distributed binary
|
||||
floating-point values in the half-open range [0, 1) with a precision of
|
||||
either <code>bitCount</code> or the significand bit count of the floating-point type,
|
||||
whichever is less. Additionally, this method generates uniformly distributed
|
||||
unsigned integers in the half-open range [0, 2 ** <em>x</em>), where ** is the
|
||||
exponentiation operator and <em>x</em> is the lesser of <code>bitCount</code> and the bit
|
||||
width of the integer type.</p>
|
||||
|
||||
<p>For end users, however, the recommended spelling for a uniformly distributed
|
||||
numeric value is <code>uniform()</code>; that method is overloaded to permit custom
|
||||
minimum and maximum values for the uniform distribution.</p>
|
||||
|
||||
<a href="Protocols/PRNG.html">See more…</a>
|
||||
</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">protocol</span> <span class="kt">PRNG</span> <span class="p">:</span> <span class="kd">class</span><span class="p">,</span> <span class="kt">IteratorProtocol</span><span class="p">,</span> <span class="kt">Sequence</span>
|
||||
<span class="k">where</span> <span class="kt">Element</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span><span class="p">,</span>
|
||||
<span class="kt">SubSequence</span> <span class="p">:</span> <span class="kt">Sequence</span><span class="p">,</span>
|
||||
<span class="kt">Element</span> <span class="o">==</span> <span class="kt">SubSequence</span><span class="o">.</span><span class="kt">Element</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4RealP"></a>
|
||||
<a name="//apple_ref/swift/Protocol/Real" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Real</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<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>
|
||||
|
||||
<a href="Protocols/Real.html">See more…</a>
|
||||
</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">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>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4MathP"></a>
|
||||
<a name="//apple_ref/swift/Protocol/Math" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Math</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>A signed numeric type that supports elementary functions.</p>
|
||||
|
||||
<p>The <code>Math</code> protocol provides a suitable basis for writing functions that
|
||||
work on any real or complex floating-point type that supports the required
|
||||
functions.</p>
|
||||
|
||||
<a href="Protocols/Math.html">See more…</a>
|
||||
</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">protocol</span> <span class="kt">Math</span> <span class="p">:</span> <span class="kt">SignedNumeric</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,857 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>PRNG 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/PRNG" class="dashAnchor"></a>
|
||||
<a title="PRNG 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>PRNG</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">PRNG</span> <span class="p">:</span> <span class="kd">class</span><span class="p">,</span> <span class="kt">IteratorProtocol</span><span class="p">,</span> <span class="kt">Sequence</span>
|
||||
<span class="k">where</span> <span class="kt">Element</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span><span class="p">,</span>
|
||||
<span class="kt">SubSequence</span> <span class="p">:</span> <span class="kt">Sequence</span><span class="p">,</span>
|
||||
<span class="kt">Element</span> <span class="o">==</span> <span class="kt">SubSequence</span><span class="o">.</span><span class="kt">Element</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>A pseudo-random number generator (PRNG).</p>
|
||||
|
||||
<p>Reference types that conform to <code>PRNG</code> are infinite sequences of
|
||||
pseudo-random elements. Protocol extension methods iterate over such a
|
||||
sequence as necessary to generate pseudo-random values from the desired
|
||||
distribution.</p>
|
||||
<h2 id='considerations-for-conforming-types' class='heading'>Considerations for Conforming Types</h2>
|
||||
|
||||
<p>For clarity to end users, custom PRNGs may be implemented in an extension to
|
||||
<code><a href="../Classes/Random.html">Random</a></code>. For instance, the <code>xoroshiro128+</code> algorithm is implemented in a
|
||||
final class named <code><a href="../Classes/Random/Xoroshiro.html">Random.Xoroshiro</a></code>.</p>
|
||||
|
||||
<p>The static methods <code>_entropy(_:)</code> and <code>_entropy(_:count:)</code> return
|
||||
cryptographically secure random bytes that may be useful for seeding your
|
||||
custom PRNG. However, these methods may return <code>nil</code> if the requested number
|
||||
of random bytes is not available, and they are not recommended as a routine
|
||||
source of random data.</p>
|
||||
<h2 id='adding-other-probability-distributions' class='heading'>Adding Other Probability Distributions</h2>
|
||||
|
||||
<p>Many built-in protocol extension methods make use of the primitive,
|
||||
overloaded method <code>_random(_:bitCount:)</code>. You may wish to use the same
|
||||
method in new protocol extension methods that return pseudo-random
|
||||
values from other probability distributions.</p>
|
||||
|
||||
<p>The method <code>_random(_:bitCount:)</code> generates uniformly distributed binary
|
||||
floating-point values in the half-open range [0, 1) with a precision of
|
||||
either <code>bitCount</code> or the significand bit count of the floating-point type,
|
||||
whichever is less. Additionally, this method generates uniformly distributed
|
||||
unsigned integers in the half-open range [0, 2 ** <em>x</em>), where ** is the
|
||||
exponentiation operator and <em>x</em> is the lesser of <code>bitCount</code> and the bit
|
||||
width of the integer type.</p>
|
||||
|
||||
<p>For end users, however, the recommended spelling for a uniformly distributed
|
||||
numeric value is <code>uniform()</code>; that method is overloaded to permit custom
|
||||
minimum and maximum values for the uniform distribution.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGP5State">State</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGP5state5StateQzv">state</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPx5StateQz5state_tcfc">init(state:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPxSgycfc">init()</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGP3max7ElementQzvZ">max</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGP3min7ElementQzvZ">min</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE15_randomBitWidthSivZ">_randomBitWidth</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE8_entropyqd__Sgqd__ms17FixedWidthIntegerRd__s08UnsignedG0Rd__lFZ">_entropy(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE8_entropySayqd__GSgqd__m_Si5countts17FixedWidthIntegerRd__s08UnsignedH0Rd__lFZ">_entropy(_:count:)</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7_randomqd__qd__m_Si8bitCountts17FixedWidthIntegerRd__s08UnsignedI0Rd__lF">_random(_:bitCount:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7uniformqd__qd__m_qd__1aqd__1bts17FixedWidthIntegerRd__s08UnsignedG0Rd__lF">uniform(_:a:b:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7uniformqd__qd__ms17FixedWidthIntegerRd__s08UnsignedG0Rd__lF">uniform(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7uniforms14UnfoldSequenceVyqd__SiGqd__m_qd__1aqd__1bSi5countts17FixedWidthIntegerRd__s08UnsignedJ0Rd__lF">uniform(_:a:b:count:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7uniforms14UnfoldSequenceVyqd__SiGqd__m_Si5countts17FixedWidthIntegerRd__s08UnsignedJ0Rd__lF">uniform(_:count:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7uniformqd__qd__m_qd__1aqd__1bts17FixedWidthIntegerRd__s06SignedG0Rd__sAG9Magnitudes0A0PRpd__s08UnsignedG0ALRQlF">uniform(_:a:b:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7uniformqd__qd__ms17FixedWidthIntegerRd__s06SignedG0Rd__sAE9Magnitudes0A0PRpd__s08UnsignedG0AJRQlF">uniform(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7uniforms14UnfoldSequenceVyqd__SiGqd__m_qd__1aqd__1bSi5countts17FixedWidthIntegerRd__s06SignedJ0Rd__sAK9Magnitudes0A0PRpd__s08UnsignedJ0APRQlF">uniform(_:a:b:count:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPAAE7uniforms14UnfoldSequenceVyqd__SiGqd__m_Si5countts17FixedWidthIntegerRd__s06SignedJ0Rd__sAI9Magnitudes0A0PRpd__s08UnsignedJ0ANRQlF">uniform(_:count:)</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7_randomqd__qd__m_Si8bitCountts19BinaryFloatingPointRd__lF">_random(_:bitCount:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7uniformqd__qd__m_qd__1aqd__1bts19BinaryFloatingPointRd__lF">uniform(_:a:b:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7uniformqd__qd__ms19BinaryFloatingPointRd__lF">uniform(_:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7uniforms14UnfoldSequenceVyqd__SiGqd__m_qd__1aqd__1bSi5countts19BinaryFloatingPointRd__lF">uniform(_:a:b:count:)</a></li>
|
||||
<li><a href="#/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7uniforms14UnfoldSequenceVyqd__SiGqd__m_Si5countts19BinaryFloatingPointRd__lF">uniform(_:count:)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGP5State"></a>
|
||||
<a name="//apple_ref/swift/Alias/State" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>State</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>A type that can represent the internal state of the pseudo-random number
|
||||
generator.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">associatedtype</span> <span class="kt">State</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGP5state5StateQzv"></a>
|
||||
<a name="//apple_ref/swift/Property/state" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>state</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>The internal state of the pseudo-random number generator.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">var</span> <span class="nv">state</span><span class="p">:</span> <span class="kt"><a href="../Protocols/PRNG.html#/s:12NumericAnnex4PRNGP5State">State</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPx5StateQz5state_tcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(state:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init(state:)</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a pseudo-random number generator with the given internal state.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="nf">init</span><span class="p">(</span><span class="nv">state</span><span class="p">:</span> <span class="kt"><a href="../Protocols/PRNG.html#/s:12NumericAnnex4PRNGP5State">State</a></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters">
|
||||
<h5>Parameters</h5>
|
||||
<dl>
|
||||
<dt><code>state</code></dt>
|
||||
<dd>
|
||||
<p>The value to be used as the generator’s internal state.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPxSgycfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init()" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>init()</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Creates a pseudo-random number generator with an internal state seeded
|
||||
using cryptographically secure random bytes.</p>
|
||||
|
||||
<p>If cryptographically secure random bytes are unavailable, the result is
|
||||
<code>nil</code>.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h5>Declaration</h5>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="nf">init</span><span class="p">?()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGP3max7ElementQzvZ"></a>
|
||||
<a name="//apple_ref/swift/Variable/max" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>max</code>
|
||||
<span class="declaration-note">Default implementation</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>The maximum value that may be generated by the pseudo-random number
|
||||
generator.</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="k">var</span> <span class="nv">max</span><span class="p">:</span> <span class="kt">Element</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGP3min7ElementQzvZ"></a>
|
||||
<a name="//apple_ref/swift/Variable/min" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>min</code>
|
||||
<span class="declaration-note">Default implementation</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>The minimum value that may be generated by the pseudo-random number
|
||||
generator.</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="k">var</span> <span class="nv">min</span><span class="p">:</span> <span class="kt">Element</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE15_randomBitWidthSivZ"></a>
|
||||
<a name="//apple_ref/swift/Variable/_randomBitWidth" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>_randomBitWidth</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>The number of pseudo-random bits available from a value generated by the
|
||||
pseudo-random number generator.</p>
|
||||
|
||||
</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="k">var</span> <span class="nv">_randomBitWidth</span><span class="p">:</span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE8_entropyqd__Sgqd__ms17FixedWidthIntegerRd__s08UnsignedG0Rd__lFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/_entropy(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>_entropy(_:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns a value filled with data from a source of cryptographically secure
|
||||
random bytes, or <code>nil</code> if a sufficient number of cryptographically secure
|
||||
random bytes is unavailable.</p>
|
||||
|
||||
</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="n">_entropy</span><span class="o"><</span>
|
||||
<span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span>
|
||||
<span class="o">></span><span class="p">(</span><span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">)</span> <span class="o">-></span> <span class="kt">T</span><span class="p">?</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE8_entropySayqd__GSgqd__m_Si5countts17FixedWidthIntegerRd__s08UnsignedH0Rd__lFZ"></a>
|
||||
<a name="//apple_ref/swift/Method/_entropy(_:count:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>_entropy(_:count:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Returns an array of <code>count</code> values filled with data from a source of
|
||||
cryptographically secure random bytes, or <code>nil</code> if a sufficient number of
|
||||
cryptographically secure random bytes is unavailable.</p>
|
||||
|
||||
</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="n">_entropy</span><span class="o"><</span>
|
||||
<span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span>
|
||||
<span class="o">></span><span class="p">(</span><span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">count</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-></span> <span class="p">[</span><span class="kt">T</span><span class="p">]?</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7_randomqd__qd__m_Si8bitCountts17FixedWidthIntegerRd__s08UnsignedI0Rd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/_random(_:bitCount:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>_random(_:bitCount:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a pseudo-random unsigned integer of type <code>T</code> in the range from 0
|
||||
to <code>2 ** min(bitCount, T.bitWidth)</code> (exclusive), where <code>**</code> is the
|
||||
exponentiation operator.</p>
|
||||
|
||||
</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="n">_random</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">bitCount</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="n">bitWidth</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">T</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7uniformqd__qd__m_qd__1aqd__1bts17FixedWidthIntegerRd__s08UnsignedG0Rd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:a:b:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:a:b:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a pseudo-random unsigned integer of type <code>T</code> in the range from
|
||||
<code>a</code> through <code>b</code> (inclusive) from the discrete uniform distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">a</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="kt">T</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">T</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7uniformqd__qd__ms17FixedWidthIntegerRd__s08UnsignedG0Rd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a pseudo-random unsigned integer of type <code>T</code> in the range from
|
||||
<code>T.min</code> through <code>T.max</code> (inclusive) from the discrete uniform
|
||||
distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">T</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7uniforms14UnfoldSequenceVyqd__SiGqd__m_qd__1aqd__1bSi5countts17FixedWidthIntegerRd__s08UnsignedJ0Rd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:a:b:count:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:a:b:count:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a sequence of <code>count</code> pseudo-random unsigned integers of type
|
||||
<code>T</code> in the range from <code>a</code> through <code>b</code> (inclusive) from the discrete
|
||||
uniform distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">a</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">count</span><span class="p">:</span> <span class="kt">Int</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">UnfoldSequence</span><span class="o"><</span><span class="kt">T</span><span class="p">,</span> <span class="kt">Int</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7uniforms14UnfoldSequenceVyqd__SiGqd__m_Si5countts17FixedWidthIntegerRd__s08UnsignedJ0Rd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:count:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:count:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a sequence of <code>count</code> pseudo-random unsigned integers of type
|
||||
<code>T</code> in the range from <code>T.min</code> through <code>T.max</code> (inclusive) from the
|
||||
discrete uniform distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">count</span><span class="p">:</span> <span class="kt">Int</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">UnfoldSequence</span><span class="o"><</span><span class="kt">T</span><span class="p">,</span> <span class="kt">Int</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7uniformqd__qd__m_qd__1aqd__1bts17FixedWidthIntegerRd__s06SignedG0Rd__sAG9Magnitudes0A0PRpd__s08UnsignedG0ALRQlF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:a:b:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:a:b:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a pseudo-random signed integer of type <code>T</code> in the range from <code>a</code>
|
||||
through <code>b</code> (inclusive) from the discrete uniform distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">SignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">a</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="kt">T</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">T</span> <span class="k">where</span> <span class="kt">T</span><span class="o">.</span><span class="kt">Magnitude</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7uniformqd__qd__ms17FixedWidthIntegerRd__s06SignedG0Rd__sAE9Magnitudes0A0PRpd__s08UnsignedG0AJRQlF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a pseudo-random signed integer of type <code>T</code> in the range from
|
||||
<code>T.min</code> through <code>T.max</code> (inclusive) from the discrete uniform
|
||||
distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">SignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">T</span> <span class="k">where</span> <span class="kt">T</span><span class="o">.</span><span class="kt">Magnitude</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7uniforms14UnfoldSequenceVyqd__SiGqd__m_qd__1aqd__1bSi5countts17FixedWidthIntegerRd__s06SignedJ0Rd__sAK9Magnitudes0A0PRpd__s08UnsignedJ0APRQlF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:a:b:count:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:a:b:count:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a sequence of <code>count</code> pseudo-random signed integers of type <code>T</code>
|
||||
in the range from <code>a</code> through <code>b</code> (inclusive) from the discrete uniform
|
||||
distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">SignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">a</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">count</span><span class="p">:</span> <span class="kt">Int</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">UnfoldSequence</span><span class="o"><</span><span class="kt">T</span><span class="p">,</span> <span class="kt">Int</span><span class="o">></span>
|
||||
<span class="k">where</span> <span class="kt">T</span><span class="o">.</span><span class="kt">Magnitude</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPAAE7uniforms14UnfoldSequenceVyqd__SiGqd__m_Si5countts17FixedWidthIntegerRd__s06SignedJ0Rd__sAI9Magnitudes0A0PRpd__s08UnsignedJ0ANRQlF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:count:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:count:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a sequence of <code>count</code> pseudo-random signed integers of type <code>T</code>
|
||||
in the range from <code>T.min</code> through <code>T.max</code> (inclusive) from the discrete
|
||||
uniform distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">SignedInteger</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">count</span><span class="p">:</span> <span class="kt">Int</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">UnfoldSequence</span><span class="o"><</span><span class="kt">T</span><span class="p">,</span> <span class="kt">Int</span><span class="o">></span>
|
||||
<span class="k">where</span> <span class="kt">T</span><span class="o">.</span><span class="kt">Magnitude</span> <span class="p">:</span> <span class="kt">FixedWidthInteger</span> <span class="o">&</span> <span class="kt">UnsignedInteger</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7_randomqd__qd__m_Si8bitCountts19BinaryFloatingPointRd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/_random(_:bitCount:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>_random(_:bitCount:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a pseudo-random binary floating-point value of type <code>T</code> in the
|
||||
range from 0 to 1 (exclusive) with <code>min(bitCount, T.significandBitCount)</code>
|
||||
bits of precision.</p>
|
||||
|
||||
</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="n">_random</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">BinaryFloatingPoint</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">bitCount</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="n">significandBitCount</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">T</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7uniformqd__qd__m_qd__1aqd__1bts19BinaryFloatingPointRd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:a:b:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:a:b:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a pseudo-random binary floating-point value of type <code>T</code> in the
|
||||
range from <code>a</code> to <code>b</code> (exclusive) from the uniform distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">BinaryFloatingPoint</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">a</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="kt">T</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">T</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7uniformqd__qd__ms19BinaryFloatingPointRd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a pseudo-random binary floating-point value of type <code>T</code> in the
|
||||
range from 0 to 1 (exclusive) from the uniform distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">BinaryFloatingPoint</span><span class="o">></span><span class="p">(</span><span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">)</span> <span class="o">-></span> <span class="kt">T</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7uniforms14UnfoldSequenceVyqd__SiGqd__m_qd__1aqd__1bSi5countts19BinaryFloatingPointRd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:a:b:count:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:a:b:count:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a sequence of <code>count</code> pseudo-random binary floating-point values
|
||||
of type <code>T</code> in the range from <code>a</code> to <code>b</code> (exclusive) from the uniform
|
||||
distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">BinaryFloatingPoint</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">a</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="kt">T</span><span class="p">,</span> <span class="nv">count</span><span class="p">:</span> <span class="kt">Int</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">UnfoldSequence</span><span class="o"><</span><span class="kt">T</span><span class="p">,</span> <span class="kt">Int</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4PRNGPA2aBRzs6UInt64V7ElementRtzlE7uniforms14UnfoldSequenceVyqd__SiGqd__m_Si5countts19BinaryFloatingPointRd__lF"></a>
|
||||
<a name="//apple_ref/swift/Method/uniform(_:count:)" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>uniform(_:count:)</code>
|
||||
<span class="declaration-note">Extension method</span>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>Generates a sequence of <code>count</code> pseudo-random binary floating-point values
|
||||
of type <code>T</code> in the range from 0 to 1 (exclusive) from the uniform
|
||||
distribution.</p>
|
||||
|
||||
</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="n">uniform</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">BinaryFloatingPoint</span><span class="o">></span><span class="p">(</span>
|
||||
<span class="nv">_</span><span class="p">:</span> <span class="kt">T</span><span class="o">.</span><span class="k">Type</span> <span class="o">=</span> <span class="kt">T</span><span class="o">.</span><span class="k">self</span><span class="p">,</span> <span class="nv">count</span><span class="p">:</span> <span class="kt">Int</span>
|
||||
<span class="p">)</span> <span class="o">-></span> <span class="kt">UnfoldSequence</span><span class="o"><</span><span class="kt">T</span><span class="p">,</span> <span class="kt">Int</span><span class="o">></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,594 @@
|
|||
<!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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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">-></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 && 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">-></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">-></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">-></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">-></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">-></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">-></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 && 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">-></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">-></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">-></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">-></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">-></span> <span class="k">Self</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,337 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Structures 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 title="Structures 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Structures</h1>
|
||||
<p>The following structures are available globally.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex7ComplexV">Complex</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex8RationalV">Rational</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex7ComplexV"></a>
|
||||
<a name="//apple_ref/swift/Struct/Complex" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Complex</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>A type to represent a complex value in Cartesian form.</p>
|
||||
<div class="aside aside-note">
|
||||
<p class="aside-title">Note</p>
|
||||
<code>Complex64</code> is a type alias for <code>Complex<Float></code> and <code>Complex128</code> is
|
||||
a type alias for <code>Complex<Double></code>.
|
||||
|
||||
</div>
|
||||
|
||||
<p>Create new instances of <code>Complex<T></code> using integer or floating-point
|
||||
literals and the imaginary unit <code><a href="Structs/Complex.html#/s:12NumericAnnex7ComplexV1iACyxGvZ">Complex<T>.i</a></code>. For example:</p>
|
||||
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">x</span> <span class="o">=</span> <span class="mi">2</span> <span class="o">+</span> <span class="mi">4</span> <span class="o">*</span> <span class="o">.</span><span class="n">i</span> <span class="c1">// `x` is of type `Complex<Double>`</span>
|
||||
<span class="k">let</span> <span class="nv">y</span> <span class="o">=</span> <span class="mf">3.5</span> <span class="o">+</span> <span class="mi">7</span> <span class="o">*</span> <span class="o">.</span><span class="n">i</span> <span class="c1">// `y` is of type `Complex<Double>`</span>
|
||||
|
||||
<span class="k">let</span> <span class="nv">z</span><span class="p">:</span> <span class="kt">Complex64</span> <span class="o">=</span> <span class="o">.</span><span class="n">e</span> <span class="o">+</span> <span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="o">.</span><span class="n">i</span> <span class="c1">// `z` is of type `Complex<Float>`</span>
|
||||
</code></pre>
|
||||
<h2 id='additional-considerations' class='heading'>Additional Considerations</h2>
|
||||
|
||||
<p>Floating-point types have special values that represent infinity or NaN
|
||||
(<q>not a number</q>). Complex functions in different languages may return
|
||||
different results when working with special values.</p>
|
||||
|
||||
<p>Many complex functions have <a href="http://mathworld.wolfram.com/BranchCut.html">branch cuts</a>, which are curves in the
|
||||
complex plane across which a function is discontinuous. Different languages
|
||||
may adopt different branch cut structures for the same complex function.</p>
|
||||
|
||||
<p>Implementations in <code>Complex<T></code> adhere to the <a href="http://www.open-std.org/JTC1/SC22/WG14/www/standards.html#9899">C standard</a> (Annex G) as
|
||||
closely as possible with respect to special values and branch cuts.</p>
|
||||
|
||||
<p>To users unfamiliar with complex functions, the principal value returned by
|
||||
some complex functions may be unexpected. For example,
|
||||
<code>Double.cbrt(-8) == -2</code>, which is the <strong>real root</strong>, while
|
||||
<code>Complex.cbrt(-8) == 2 * Complex.exp(.i * .pi / 3)</code>, which is the
|
||||
<strong>principal root</strong>.</p>
|
||||
|
||||
<a href="Structs/Complex.html">See more…</a>
|
||||
</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">struct</span> <span class="kt">Complex</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt"><a href="Protocols/Real.html">Real</a></span><span class="o">></span> <span class="p">:</span> <span class="kt">Codable</span>
|
||||
<span class="k">where</span> <span class="kt">T</span> <span class="p">:</span> <span class="kt">Codable</span> <span class="o">&</span> <span class="n">_ExpressibleByBuiltinFloatLiteral</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex8RationalV"></a>
|
||||
<a name="//apple_ref/swift/Struct/Rational" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Rational</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>A type to represent a rational value.</p>
|
||||
<div class="aside aside-note">
|
||||
<p class="aside-title">Note</p>
|
||||
<code>Ratio</code> is a type alias for <code>Rational<Int></code>.
|
||||
|
||||
</div>
|
||||
|
||||
<p>Create new instances of <code>Rational<T></code> by using integer literals and the
|
||||
division (<code>/</code>) operator. For example:</p>
|
||||
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">x</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">/</span> <span class="mi">3</span> <span class="k">as</span> <span class="kt">Ratio</span> <span class="c1">// `x` is of type `Rational<Int>`</span>
|
||||
<span class="k">let</span> <span class="nv">y</span> <span class="o">=</span> <span class="mi">2</span> <span class="k">as</span> <span class="kt">Ratio</span> <span class="c1">// `y` is of type `Rational<Int>`</span>
|
||||
<span class="k">let</span> <span class="nv">z</span><span class="p">:</span> <span class="kt">Ratio</span> <span class="o">=</span> <span class="mi">2</span> <span class="o">/</span> <span class="mi">3</span> <span class="c1">// `z` is also of type `Rational<Int>`</span>
|
||||
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="n">y</span> <span class="o">+</span> <span class="n">z</span><span class="p">)</span> <span class="c1">// Prints "3"</span>
|
||||
</code></pre>
|
||||
|
||||
<p>You can create an unreduced fraction by using the initializer
|
||||
<code><a href="Structs/Rational.html#/s:12NumericAnnex8RationalVACyxGx9numerator_x11denominatortcfc">Rational<T>.init(numerator:denominator:)</a></code>. For example:</p>
|
||||
<pre class="highlight swift"><code><span class="k">let</span> <span class="nv">a</span> <span class="o">=</span> <span class="kt">Ratio</span><span class="p">(</span><span class="nv">numerator</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span> <span class="nv">denominator</span><span class="p">:</span> <span class="mi">3</span><span class="p">)</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> <span class="c1">// Prints "3/3"</span>
|
||||
</code></pre>
|
||||
|
||||
<p>All arithmetic operations on values in canonical form (i.e. reduced to
|
||||
lowest terms) return results in canonical form. However, operations on
|
||||
values not in canonical form may or may not return results that are
|
||||
themselves in canonical form. The property <code>canonicalized</code> is the canonical
|
||||
form of any value.</p>
|
||||
<h2 id='additional-considerations' class='heading'>Additional Considerations</h2>
|
||||
<h3 id='special-values' class='heading'>Special Values</h3>
|
||||
|
||||
<p><code>Rational<T></code> does not prohibit zero as a denominator. Any instance with a
|
||||
positive numerator and zero denominator represents (positive) infinity; any
|
||||
instance with a negative numerator and zero denominator represents negative
|
||||
infinity; and any instance with zero numerator and zero denominator
|
||||
represents NaN (<q>not a number</q>).</p>
|
||||
|
||||
<p>As with floating-point types, <code><a href="Structs/Rational.html#/s:12NumericAnnex8RationalV8infinityACyxGvZ">Rational<T>.infinity</a></code> compares greater than
|
||||
every finite value and negative infinity, and <code>-Rational<T>.infinity</code>
|
||||
compares less than every finite value and positive infinity. Infinite values
|
||||
of the same sign compare equal to each other.</p>
|
||||
|
||||
<p>As with floating-point types, <code><a href="Structs/Rational.html#/s:12NumericAnnex8RationalV3nanACyxGvZ">Rational<T>.nan</a></code> does not compare equal to
|
||||
any other value, including another NaN. Use the property <code>isNaN</code> to test if
|
||||
a value is NaN. <code>Rational<T></code> arithmetic operations are intended to
|
||||
propagate NaN in the same manner as analogous floating-point operations.</p>
|
||||
<h3 id='numerical-limits' class='heading'>Numerical Limits</h3>
|
||||
|
||||
<p>When a value of type <code>Rational<T></code> is in canonical form, the sign of the
|
||||
numerator is the sign of the value; that is, in canonical form, the sign of
|
||||
the denominator is always positive. Therefore, <code>-1 / T.min</code> cannot be
|
||||
represented as a value of type <code>Rational<T></code> because <code>abs(T.min)</code> cannot be
|
||||
represented as a value of type <code>T</code>.</p>
|
||||
|
||||
<p>To ensure that every representable value of type <code>Rational<T></code> has a
|
||||
representable magnitude and reciprocal of the same type, an overflow trap
|
||||
occurs when the division (<code>/</code>) operator is used to create a value of type
|
||||
<code>Rational<T></code> with numerator <code>T.min</code>.</p>
|
||||
|
||||
<a href="Structs/Rational.html">See more…</a>
|
||||
</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">struct</span> <span class="kt">Rational</span><span class="o"><</span><span class="kt">T</span> <span class="p">:</span> <span class="kt">SignedInteger</span><span class="o">></span> <span class="p">:</span> <span class="kt">Codable</span>
|
||||
<span class="k">where</span> <span class="kt">T</span> <span class="p">:</span> <span class="kt">Codable</span> <span class="o">&</span> <span class="n">_ExpressibleByBuiltinIntegerLiteral</span><span class="p">,</span>
|
||||
<span class="kt">T</span><span class="o">.</span><span class="kt">Magnitude</span> <span class="p">:</span> <span class="kt">UnsignedInteger</span><span class="p">,</span>
|
||||
<span class="kt">T</span><span class="o">.</span><span class="kt">Magnitude</span><span class="o">.</span><span class="kt">Magnitude</span> <span class="o">==</span> <span class="kt">T</span><span class="o">.</span><span class="kt">Magnitude</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,243 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Type Aliases 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 title="Type Aliases 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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>Type Aliases</h1>
|
||||
<p>The following type aliases are available globally.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<details open>
|
||||
<summary>Topics</summary>
|
||||
<div class="wrapper">
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex4Signa">Sign</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="#/s:12NumericAnnex12RoundingRulea">RoundingRule</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<div class="wrapper">
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex4Signa"></a>
|
||||
<a name="//apple_ref/swift/Alias/Sign" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>Sign</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>The mathematical sign of a number.</p>
|
||||
|
||||
</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">typealias</span> <span class="kt">Sign</span> <span class="o">=</span> <span class="kt">FloatingPointSign</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="group">
|
||||
<ul>
|
||||
<li>
|
||||
<div>
|
||||
<a name="/s:12NumericAnnex12RoundingRulea"></a>
|
||||
<a name="//apple_ref/swift/Alias/RoundingRule" class="dashAnchor"></a>
|
||||
<h4>
|
||||
<code>RoundingRule</code>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
<p>A rule for rounding a number.</p>
|
||||
|
||||
</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">typealias</span> <span class="kt">RoundingRule</span> <span class="o">=</span> <span class="kt">FloatingPointRoundingRule</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,186 @@
|
|||
/* Credit to https://gist.github.com/wataru420/2048287 */
|
||||
.highlight {
|
||||
/* Comment */
|
||||
/* Error */
|
||||
/* Keyword */
|
||||
/* Operator */
|
||||
/* Comment.Multiline */
|
||||
/* Comment.Preproc */
|
||||
/* Comment.Single */
|
||||
/* Comment.Special */
|
||||
/* Generic.Deleted */
|
||||
/* Generic.Deleted.Specific */
|
||||
/* Generic.Emph */
|
||||
/* Generic.Error */
|
||||
/* Generic.Heading */
|
||||
/* Generic.Inserted */
|
||||
/* Generic.Inserted.Specific */
|
||||
/* Generic.Output */
|
||||
/* Generic.Prompt */
|
||||
/* Generic.Strong */
|
||||
/* Generic.Subheading */
|
||||
/* Generic.Traceback */
|
||||
/* Keyword.Constant */
|
||||
/* Keyword.Declaration */
|
||||
/* Keyword.Pseudo */
|
||||
/* Keyword.Reserved */
|
||||
/* Keyword.Type */
|
||||
/* Literal.Number */
|
||||
/* Literal.String */
|
||||
/* Name.Attribute */
|
||||
/* Name.Builtin */
|
||||
/* Name.Class */
|
||||
/* Name.Constant */
|
||||
/* Name.Entity */
|
||||
/* Name.Exception */
|
||||
/* Name.Function */
|
||||
/* Name.Namespace */
|
||||
/* Name.Tag */
|
||||
/* Name.Variable */
|
||||
/* Operator.Word */
|
||||
/* Text.Whitespace */
|
||||
/* Literal.Number.Float */
|
||||
/* Literal.Number.Hex */
|
||||
/* Literal.Number.Integer */
|
||||
/* Literal.Number.Oct */
|
||||
/* Literal.String.Backtick */
|
||||
/* Literal.String.Char */
|
||||
/* Literal.String.Doc */
|
||||
/* Literal.String.Double */
|
||||
/* Literal.String.Escape */
|
||||
/* Literal.String.Heredoc */
|
||||
/* Literal.String.Interpol */
|
||||
/* Literal.String.Other */
|
||||
/* Literal.String.Regex */
|
||||
/* Literal.String.Single */
|
||||
/* Literal.String.Symbol */
|
||||
/* Name.Builtin.Pseudo */
|
||||
/* Name.Variable.Class */
|
||||
/* Name.Variable.Global */
|
||||
/* Name.Variable.Instance */
|
||||
/* Literal.Number.Integer.Long */ }
|
||||
.highlight a {
|
||||
color: inherit; }
|
||||
.highlight .c {
|
||||
color: #007400; }
|
||||
.highlight .err {
|
||||
color: #a61717;
|
||||
background-color: #e3d2d2; }
|
||||
.highlight .k {
|
||||
color: #aa0d91; }
|
||||
.highlight .o {
|
||||
color: #000; }
|
||||
.highlight .cm {
|
||||
color: #007400; }
|
||||
.highlight .cp {
|
||||
color: #007400; }
|
||||
.highlight .c1 {
|
||||
color: #007400; }
|
||||
.highlight .cs {
|
||||
color: #007400; }
|
||||
.highlight .gd {
|
||||
color: #000;
|
||||
background-color: #fdd; }
|
||||
.highlight .gd .x {
|
||||
color: #000;
|
||||
background-color: #faa; }
|
||||
.highlight .ge {
|
||||
font-style: italic; }
|
||||
.highlight .gr {
|
||||
color: #a00; }
|
||||
.highlight .gh {
|
||||
color: #999; }
|
||||
.highlight .gi {
|
||||
color: #000;
|
||||
background-color: #dfd; }
|
||||
.highlight .gi .x {
|
||||
color: #000;
|
||||
background-color: #afa; }
|
||||
.highlight .go {
|
||||
color: #888; }
|
||||
.highlight .gp {
|
||||
color: #555; }
|
||||
.highlight .gs {
|
||||
font-weight: bold; }
|
||||
.highlight .gu {
|
||||
color: #aaa; }
|
||||
.highlight .gt {
|
||||
color: #a00; }
|
||||
.highlight .kc {
|
||||
color: #aa0d91; }
|
||||
.highlight .kd {
|
||||
color: #aa0d91; }
|
||||
.highlight .kp {
|
||||
color: #aa0d91; }
|
||||
.highlight .kr {
|
||||
color: #aa0d91; }
|
||||
.highlight .kt {
|
||||
color: #2b839f; }
|
||||
.highlight .m {
|
||||
color: #000; }
|
||||
.highlight .s {
|
||||
color: #a31515; }
|
||||
.highlight .na {
|
||||
color: #2b839f; }
|
||||
.highlight .nb {
|
||||
color: #2b839f; }
|
||||
.highlight .nc {
|
||||
color: #2b839f; }
|
||||
.highlight .no {
|
||||
color: #2b839f; }
|
||||
.highlight .ni {
|
||||
color: #2b839f; }
|
||||
.highlight .ne {
|
||||
color: #2b839f; }
|
||||
.highlight .nf {
|
||||
color: #2b839f; }
|
||||
.highlight .nn {
|
||||
color: #2b839f; }
|
||||
.highlight .nt {
|
||||
color: #2b839f; }
|
||||
.highlight .nv {
|
||||
color: #000; }
|
||||
.highlight .ow {
|
||||
color: #000; }
|
||||
.highlight .w {
|
||||
color: #bbb; }
|
||||
.highlight .mf {
|
||||
color: #1c00cf; }
|
||||
.highlight .mh {
|
||||
color: #1c00cf; }
|
||||
.highlight .mi {
|
||||
color: #1c00cf; }
|
||||
.highlight .mo {
|
||||
color: #1c00cf; }
|
||||
.highlight .sb {
|
||||
color: #c41a16; }
|
||||
.highlight .sc {
|
||||
color: #1c00cf; }
|
||||
.highlight .sd {
|
||||
color: #c41a16; }
|
||||
.highlight .s2 {
|
||||
color: #c41a16; }
|
||||
.highlight .se {
|
||||
color: #c41a16; }
|
||||
.highlight .sh {
|
||||
color: #c41a16; }
|
||||
.highlight .si {
|
||||
color: #c41a16; }
|
||||
.highlight .sx {
|
||||
color: #c41a16; }
|
||||
.highlight .sr {
|
||||
color: #c41a16; }
|
||||
.highlight .s1 {
|
||||
color: #c41a16; }
|
||||
.highlight .ss {
|
||||
color: #c41a16; }
|
||||
.highlight .bp {
|
||||
color: #999; }
|
||||
.highlight .vc {
|
||||
color: #2b839f; }
|
||||
.highlight .vg {
|
||||
color: #2b839f; }
|
||||
.highlight .vi {
|
||||
color: #2b839f; }
|
||||
.highlight .il {
|
||||
color: #1c00cf; }
|
|
@ -0,0 +1,350 @@
|
|||
@import url("https://fonts.googleapis.com/css?family=Roboto+Mono:400,500,700&subset=greek");
|
||||
*, *::before, *::after {
|
||||
box-sizing: inherit; }
|
||||
|
||||
body {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
background: #fff;
|
||||
color: #333;
|
||||
font: 16px/24px -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; }
|
||||
|
||||
h1 {
|
||||
margin: 32px 0 16px;
|
||||
font-weight: 500;
|
||||
font-size: 28px;
|
||||
line-height: 32px; }
|
||||
|
||||
h2 {
|
||||
margin: 32px 0 16px;
|
||||
font-weight: 500;
|
||||
font-size: 24px;
|
||||
line-height: 32px; }
|
||||
|
||||
h3 {
|
||||
margin: 24px 0 16px;
|
||||
font-weight: 500;
|
||||
font-size: 20px;
|
||||
line-height: 24px; }
|
||||
|
||||
h4 {
|
||||
margin: 24px 0 16px;
|
||||
font-weight: 500;
|
||||
font-size: 16px;
|
||||
line-height: 24px; }
|
||||
|
||||
h5 {
|
||||
margin: 24px 0 16px;
|
||||
font-weight: 500;
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
color: #777; }
|
||||
|
||||
h6 {
|
||||
margin: 24px 0 16px;
|
||||
font-weight: 500;
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
color: #aaaaaa; }
|
||||
|
||||
p {
|
||||
margin: 0 0 16px; }
|
||||
|
||||
ul, ol {
|
||||
margin: 0 0 16px;
|
||||
padding: 0 0 0 32px; }
|
||||
|
||||
blockquote {
|
||||
margin: 0 0 16px;
|
||||
border-left: 6px solid #e6e6e6;
|
||||
border-radius: 4px;
|
||||
padding: 16px;
|
||||
background-color: #fafafa;
|
||||
color: #858585; }
|
||||
blockquote > p:last-child {
|
||||
margin-bottom: 0; }
|
||||
|
||||
dl {
|
||||
margin: 0;
|
||||
padding: 0; }
|
||||
|
||||
dt {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-weight: 500; }
|
||||
dt:last-child {
|
||||
margin-bottom: 16px; }
|
||||
|
||||
dd {
|
||||
margin: 0 0 16px;
|
||||
padding: 0 0 0 8px; }
|
||||
|
||||
img {
|
||||
max-width: 100%; }
|
||||
|
||||
a {
|
||||
color: #4183c4;
|
||||
text-decoration: none; }
|
||||
a:hover, a:focus {
|
||||
outline: 0;
|
||||
text-decoration: underline; }
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
margin: 0 0 12px;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
background: #fff; }
|
||||
|
||||
tr:nth-child(2n) {
|
||||
background-color: #fbfbfb; }
|
||||
|
||||
th, td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 7px 11px; }
|
||||
|
||||
pre {
|
||||
overflow: auto;
|
||||
margin: 0 0 16px;
|
||||
border: 1px solid #e6e6e6;
|
||||
border-radius: 4px;
|
||||
padding: calc(12px - 1px) calc(16px - 1px);
|
||||
background: #f9f9f9;
|
||||
font-size: inherit;
|
||||
line-height: inherit;
|
||||
font-family: "Roboto Mono", Menlo, Consolas, "Liberation Mono", Courier, monospace; }
|
||||
|
||||
code {
|
||||
font-size: 16px;
|
||||
line-height: 16px;
|
||||
font-family: "Roboto Mono", Menlo, Consolas, "Liberation Mono", Courier, monospace; }
|
||||
|
||||
pre code {
|
||||
padding: 0;
|
||||
white-space: pre; }
|
||||
|
||||
body > .wrapper {
|
||||
display: flex;
|
||||
flex-direction: column; }
|
||||
@media only screen and (min-width: 1024px) {
|
||||
body > .wrapper {
|
||||
flex-direction: row; } }
|
||||
|
||||
header {
|
||||
display: flex;
|
||||
padding: 8px;
|
||||
background: #333;
|
||||
color: #999;
|
||||
font-size: 14px;
|
||||
line-height: inherit; }
|
||||
|
||||
header p {
|
||||
margin: 0;
|
||||
padding: 0 8px; }
|
||||
|
||||
header p.primary {
|
||||
flex: 1; }
|
||||
|
||||
header a[href] {
|
||||
color: #fff; }
|
||||
|
||||
nav {
|
||||
order: 2; }
|
||||
@media only screen and (min-width: 1024px) {
|
||||
nav {
|
||||
order: 1;
|
||||
flex: 0 0 25%;
|
||||
max-width: 239px;
|
||||
overflow: hidden;
|
||||
border-right: 1px solid #ddd;
|
||||
padding-bottom: 32px;
|
||||
background: #fbfbfb;
|
||||
word-wrap: normal; } }
|
||||
nav > ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 14px;
|
||||
line-height: inherit;
|
||||
list-style: none; }
|
||||
nav > ul > li {
|
||||
margin: 8px 0;
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding: 8px 0 7px 16px; }
|
||||
nav > ul > li:last-child {
|
||||
margin-bottom: 0; }
|
||||
nav > ul > li > p {
|
||||
margin: 0; }
|
||||
nav > ul > li > p > a[href] {
|
||||
color: #333; }
|
||||
nav > ul > li > ul {
|
||||
margin: 8px 0;
|
||||
padding-left: 16px;
|
||||
list-style: inherit; }
|
||||
nav > ul > li > ul > li {
|
||||
white-space: nowrap; }
|
||||
nav > ul > li > ul > li > a[href] {
|
||||
color: #808080; }
|
||||
|
||||
/*
|
||||
@keyframes appear {
|
||||
0% { opacity: 0 }
|
||||
100% { opacity: 1 }
|
||||
}
|
||||
*/
|
||||
article {
|
||||
order: 1;
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding-bottom: 31px; }
|
||||
@media only screen and (min-width: 1024px) {
|
||||
article {
|
||||
order: 2;
|
||||
flex: 1 1 auto;
|
||||
border-bottom: none;
|
||||
padding-bottom: 32px; } }
|
||||
article > section {
|
||||
padding: 0 32px; }
|
||||
article > section:last-child {
|
||||
border-bottom: none; }
|
||||
article > section > .wrapper {
|
||||
max-width: 720px;
|
||||
margin: 0 auto; }
|
||||
|
||||
.declaration .highlight {
|
||||
overflow-x: initial;
|
||||
margin: 0;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
padding: 0;
|
||||
background-color: transparent; }
|
||||
|
||||
.toc {
|
||||
border-top: 1px solid #ddd;
|
||||
border-bottom: 1px solid #ddd;
|
||||
background-color: #fbfbfb; }
|
||||
.toc details {
|
||||
max-width: 720px;
|
||||
margin: 0 auto;
|
||||
padding: 15px 0; }
|
||||
.toc details[open] > summary {
|
||||
margin-bottom: 8px;
|
||||
/*
|
||||
& ~ * {
|
||||
animation: appear .2s ease-in-out;
|
||||
}
|
||||
*/ }
|
||||
.toc details[open] > summary::after {
|
||||
content: ' \2212'; }
|
||||
.toc details > summary {
|
||||
display: block;
|
||||
margin: 0;
|
||||
padding-bottom: 0;
|
||||
color: #666666;
|
||||
font-weight: 500;
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.1em;
|
||||
text-transform: uppercase;
|
||||
user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
outline: none; }
|
||||
.toc details > summary::-webkit-details-marker {
|
||||
display: none; }
|
||||
.toc details > summary::after {
|
||||
content: ' +'; }
|
||||
.toc details > .wrapper {
|
||||
columns: 1; }
|
||||
@media only screen and (min-width: 1024px) {
|
||||
.toc details > .wrapper {
|
||||
columns: 2;
|
||||
column-gap: 16px; } }
|
||||
.toc details > .wrapper p {
|
||||
margin: 0;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
break-after: avoid-column;
|
||||
-webkit-column-break-after: avoid; }
|
||||
.toc details > .wrapper p a[href] {
|
||||
color: inherit; }
|
||||
.toc details > .wrapper ul {
|
||||
margin: 0;
|
||||
padding-left: 0;
|
||||
color: #b3b3b3;
|
||||
list-style: square inside; }
|
||||
.toc details > .wrapper ul a[href] {
|
||||
color: #808080; }
|
||||
|
||||
.group {
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding-top: 0; }
|
||||
.group:last-child {
|
||||
border-bottom: none; }
|
||||
.group:last-child > ul > li:last-child {
|
||||
padding-bottom: 16px; }
|
||||
.group a[name]::before {
|
||||
content: "";
|
||||
display: block; }
|
||||
.group > ul {
|
||||
margin: 0;
|
||||
padding: 0; }
|
||||
.group > ul > li {
|
||||
width: 100%;
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding: 0 0 15px;
|
||||
list-style: none; }
|
||||
.group > ul > li:last-child {
|
||||
border-bottom: none; }
|
||||
.group > ul > li .declaration-note {
|
||||
color: #808080;
|
||||
font-weight: normal;
|
||||
font-size: 16px; }
|
||||
|
||||
.aside, .language {
|
||||
overflow-y: hidden;
|
||||
margin: 16px 0;
|
||||
border-left: 6px solid #d0d0d0;
|
||||
border-radius: 4px;
|
||||
padding: 8px 12px;
|
||||
background-color: #f7f7f7; }
|
||||
.aside .aside-title, .language .aside-title {
|
||||
margin: 0;
|
||||
padding-bottom: 0;
|
||||
color: #aaa;
|
||||
font-weight: 500;
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.1em;
|
||||
text-transform: uppercase;
|
||||
user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
-webkit-user-select: none; }
|
||||
.aside p:last-child, .language p:last-child {
|
||||
margin-bottom: 0; }
|
||||
|
||||
.language {
|
||||
border-left: 6px solid #99bcdf;
|
||||
background-color: #f0f5fa; }
|
||||
.language .aside-title {
|
||||
color: #4183c4; }
|
||||
|
||||
.aside-warning {
|
||||
border-left: 6px solid #ffda73;
|
||||
background-color: #fff8e6; }
|
||||
.aside-warning .aside-title {
|
||||
color: #fb0; }
|
||||
|
||||
footer {
|
||||
padding: 16px;
|
||||
background: #444;
|
||||
color: #ddd;
|
||||
font-size: 14px;
|
||||
line-height: inherit; }
|
||||
footer p {
|
||||
margin: 0; }
|
||||
footer a[href] {
|
||||
color: #fff; }
|
||||
|
||||
html.dash header, html.dash nav {
|
||||
display: none; }
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 216 216"><defs><linearGradient id="a" x1="108" y1="216" x2="108" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0071bc"/><stop offset="1" stop-color="#1a8bd6"/></linearGradient><linearGradient id="b" x1="67.5" y1="144" x2="67.5" y2="72" xlink:href="#a"/><linearGradient id="c" x1="67.5" y1="128.25" x2="67.5" y2="87.75" gradientTransform="translate(127.28 -4.46) rotate(60)" xlink:href="#a"/><linearGradient id="d" x1="67.5" y1="128.25" x2="67.5" y2="87.75" gradientTransform="translate(-59.78 112.46) rotate(-60)" xlink:href="#a"/><linearGradient id="e" x1="148.5" y1="144" x2="148.5" y2="72" xlink:href="#a"/><linearGradient id="f" x1="148.5" y1="128.25" x2="148.5" y2="87.75" gradientTransform="translate(167.78 -74.6) rotate(60)" xlink:href="#a"/><linearGradient id="g" x1="148.5" y1="128.25" x2="148.5" y2="87.75" gradientTransform="translate(-19.28 182.6) rotate(-60)" xlink:href="#a"/></defs><title>NumericAnnex</title><path d="M108,9A99,99,0,1,1,9,108,99,99,0,0,1,108,9m0-9A108,108,0,0,0,31.63,184.37,108,108,0,0,0,184.37,31.63,107.29,107.29,0,0,0,108,0Z" fill="url(#a)"/><rect x="63" y="72" width="9" height="72" rx="4.5" ry="4.5" fill="url(#b)"/><rect x="63" y="72" width="9" height="72" rx="4.5" ry="4.5" transform="translate(-59.78 112.46) rotate(-60)" fill="url(#c)"/><rect x="63" y="72" width="9" height="72" rx="4.5" ry="4.5" transform="translate(127.28 -4.46) rotate(60)" fill="url(#d)"/><rect x="144" y="72" width="9" height="72" rx="4.5" ry="4.5" fill="url(#e)"/><rect x="144" y="72" width="9" height="72" rx="4.5" ry="4.5" transform="translate(-19.28 182.6) rotate(-60)" fill="url(#f)"/><rect x="144" y="72" width="9" height="72" rx="4.5" ry="4.5" transform="matrix(0.5, 0.87, -0.87, 0.5, 167.78, -74.6)" fill="url(#g)"/></svg>
|
After Width: | Height: | Size: 1.8 KiB |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 6.3 KiB |
|
@ -0,0 +1,291 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>NumericAnnex 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 title="NumericAnnex 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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 id='img-src-https-xwu-github-io-numericannex-img-numericannex-2017-09-02-svg-alt-numericannex-height-72-br-numericannex' class='heading'><img src="https://xwu.github.io/NumericAnnex/img/NumericAnnex-2017-09-02.svg" alt="NumericAnnex" height="72"><br>NumericAnnex</h1>
|
||||
|
||||
<p>NumericAnnex supplements the numeric facilities provided in the Swift standard
|
||||
library.</p>
|
||||
|
||||
<p><a href="https://travis-ci.org/xwu/NumericAnnex"><img src="https://travis-ci.org/xwu/NumericAnnex.svg?branch=master" alt="Build Status"></a>
|
||||
<a href="https://codecov.io/gh/xwu/NumericAnnex"><img src="https://codecov.io/gh/xwu/NumericAnnex/branch/master/graph/badge.svg" alt="codecov"></a></p>
|
||||
<h2 id='features' class='heading'>Features</h2>
|
||||
|
||||
<ul>
|
||||
<li>The exponentiation operator <code>**</code> and the compound assignment operator <code>**=</code>.</li>
|
||||
<li>Extension methods for <code>BinaryInteger</code> exponentiation, square root, cube root,
|
||||
greatest common divisor, and least common multiple.</li>
|
||||
<li><code><a href="Protocols/Math.html">Math</a></code>, a protocol for signed numeric types that support elementary functions.</li>
|
||||
<li><code><a href="Protocols/Real.html">Real</a></code>, a protocol for floating-point types that support elementary functions
|
||||
and a selection of special functions.</li>
|
||||
<li><code><a href="Protocols/PRNG.html">PRNG</a></code>, a protocol for pseudo-random number generators.</li>
|
||||
<li><code><a href="Structs/Rational.html">Rational</a></code>, a value type to represent rational values which supports division
|
||||
by zero.</li>
|
||||
<li><code><a href="Structs/Complex.html">Complex</a></code>, a value type to represent complex values in Cartesian form.</li>
|
||||
<li><code><a href="Classes/Random.html">Random</a></code> and <code><a href="Classes/Random/Xoroshiro.html">Random.Xoroshiro</a></code>, two reference types implementing efficient
|
||||
pseudo-random number generators.</li>
|
||||
</ul>
|
||||
|
||||
<blockquote>
|
||||
<p>Note: This project is in the early stages of development and is not
|
||||
production-ready at this time.</p>
|
||||
</blockquote>
|
||||
<h2 id='requirements' class='heading'>Requirements</h2>
|
||||
|
||||
<p>NumericAnnex requires Swift 4.0. On Apple platforms, it also requires the
|
||||
Security framework for cryptographically secure random bytes.</p>
|
||||
<h2 id='installation' class='heading'>Installation</h2>
|
||||
|
||||
<p>After NumericAnnex has been cloned or downloaded locally, build the library
|
||||
using the command <code>swift build</code> (macOS) or <code>swift build -Xcc -D_GNU_SOURCE</code>
|
||||
(Linux). Run tests with the command <code>swift test</code> (macOS) or
|
||||
<code>swift test -Xcc -D_GNU_SOURCE</code> (Linux). An Xcode project can be generated with
|
||||
the command <code>swift package generate-xcodeproj</code>.</p>
|
||||
|
||||
<p>To add the package as a dependency using <a href="https://cocoapods.org">CocoaPods</a>,
|
||||
insert the following line in your <code>Podfile</code>:</p>
|
||||
<pre class="highlight ruby"><code><span class="n">pod</span> <span class="s1">'NumericAnnex'</span><span class="p">,</span> <span class="s1">'~> 0.1.19'</span>
|
||||
</code></pre>
|
||||
|
||||
<p><a href="https://swift.org/package-manager/">Swift Package Manager</a> can also be used to
|
||||
add the package as a dependency. See Swift documentation for details.</p>
|
||||
<h2 id='basic-usage' class='heading'>Basic Usage</h2>
|
||||
<pre class="highlight swift"><code><span class="kd">import</span> <span class="kt">NumericAnnex</span>
|
||||
|
||||
<span class="nf">print</span><span class="p">(</span><span class="mi">2</span> <span class="o">**</span> <span class="mi">3</span><span class="p">)</span>
|
||||
<span class="c1">// Prints "8".</span>
|
||||
|
||||
<span class="nf">print</span><span class="p">(</span><span class="mf">4.0</span> <span class="o">**</span> <span class="mf">5.0</span><span class="p">)</span>
|
||||
<span class="c1">// Prints "1024.0".</span>
|
||||
|
||||
<span class="nf">print</span><span class="p">(</span><span class="kt">Int</span><span class="o">.</span><span class="nf">cbrt</span><span class="p">(</span><span class="mi">8</span><span class="p">))</span>
|
||||
<span class="c1">// Prints "2".</span>
|
||||
|
||||
<span class="nf">print</span><span class="p">(</span><span class="kt">Double</span><span class="o">.</span><span class="nf">cbrt</span><span class="p">(</span><span class="mf">27.0</span><span class="p">))</span>
|
||||
<span class="c1">// Prints "3.0".</span>
|
||||
|
||||
<span class="k">var</span> <span class="nv">x</span><span class="p">:</span> <span class="kt">Ratio</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">/</span> <span class="mi">4</span>
|
||||
<span class="c1">// Ratio is a type alias for Rational<Int>.</span>
|
||||
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">x</span><span class="o">.</span><span class="nf">reciprocal</span><span class="p">())</span>
|
||||
<span class="c1">// Prints "4".</span>
|
||||
|
||||
<span class="n">x</span> <span class="o">*=</span> <span class="mi">8</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="n">x</span><span class="p">)</span>
|
||||
<span class="c1">// Prints "4".</span>
|
||||
|
||||
<span class="n">x</span> <span class="o">=</span> <span class="kt">Ratio</span><span class="p">(</span><span class="kt">Float</span><span class="o">.</span><span class="n">phi</span><span class="p">)</span> <span class="c1">// Golden ratio.</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
|
||||
<span class="c1">// Prints "13573053/8388608".</span>
|
||||
|
||||
<span class="k">var</span> <span class="nv">z</span><span class="p">:</span> <span class="kt">Complex64</span> <span class="o">=</span> <span class="mi">42</span> <span class="o">*</span> <span class="o">.</span><span class="n">i</span>
|
||||
<span class="c1">// Complex64 is a type alias for Complex<Float>.</span>
|
||||
|
||||
<span class="nf">print</span><span class="p">(</span><span class="kt">Complex</span><span class="o">.</span><span class="nf">sqrt</span><span class="p">(</span><span class="n">z</span><span class="p">))</span>
|
||||
<span class="c1">// Prints "4.58258 + 4.58258i".</span>
|
||||
|
||||
<span class="n">z</span> <span class="o">=</span> <span class="o">.</span><span class="n">pi</span> <span class="o">+</span> <span class="o">.</span><span class="n">i</span> <span class="o">*</span> <span class="o">.</span><span class="nf">log</span><span class="p">(</span><span class="mi">2</span> <span class="o">-</span> <span class="o">.</span><span class="nf">sqrt</span><span class="p">(</span><span class="mi">3</span><span class="p">))</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="kt">Complex</span><span class="o">.</span><span class="nf">cos</span><span class="p">(</span><span class="n">z</span><span class="p">)</span><span class="o">.</span><span class="n">real</span><span class="p">)</span>
|
||||
<span class="c1">// Prints "-2.0".</span>
|
||||
</code></pre>
|
||||
<h2 id='documentation' class='heading'>Documentation</h2>
|
||||
|
||||
<p>All public protocols, types, and functions have been carefully documented in the
|
||||
code. See the <a href="https://xwu.github.io/NumericAnnex/">formatted reference</a> for
|
||||
details.</p>
|
||||
|
||||
<p>The project adheres to many design patterns found in the Swift standard library.
|
||||
For example, <code><a href="Protocols/Math.html">Math</a></code> types provide methods such as <code>cubeRoot()</code> and <code>tangent()</code>
|
||||
just as <code>FloatingPoint</code> types provide methods such as <code>squareRoot()</code>.</p>
|
||||
|
||||
<p>No free functions are declared in this library unless they overload existing
|
||||
ones in the Swift standard library. Instead, functions such as <code>cbrt(_:)</code> and
|
||||
<code>tan(_:)</code> are provided as static members. This avoids collisions with C standard
|
||||
library functions that you may wish to use. It also promotes clarity at the call
|
||||
site when the result of a complex operation differs from that of its real
|
||||
counterpart (e.g., <code>Complex128.cbrt(-8) != -2</code>).</p>
|
||||
<h2 id='future-directions' class='heading'>Future Directions</h2>
|
||||
|
||||
<ul>
|
||||
<li>Add more tests, including performance tests</li>
|
||||
<li>Design and implement additional methods on <code><a href="Protocols/PRNG.html">PRNG</a></code></li>
|
||||
</ul>
|
||||
<h2 id='license' class='heading'>License</h2>
|
||||
|
||||
<p>All original work is released under the MIT license. See
|
||||
<a href="https://github.com/xwu/NumericAnnex/blob/master/LICENSE">LICENSE</a> for details.</p>
|
||||
|
||||
<p>Portions of the complex square root and elementary transcendental functions use
|
||||
checks for special values adapted from libc++. Code in libc++ is dual-licensed
|
||||
under the MIT and UIUC/NCSA licenses.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,15 @@
|
|||
window.jazzy = { 'docset': false };
|
||||
if (typeof window.dash != 'undefined') {
|
||||
document.documentElement.className += ' dash';
|
||||
window.jazzy.docset = true;
|
||||
}
|
||||
if (navigator.userAgent.match(/xcode/i)) {
|
||||
document.documentElement.className += ' xcode';
|
||||
window.jazzy.docset = true;
|
||||
}
|
||||
|
||||
// Dumb down quotes within code blocks that delimit strings instead of quotations
|
||||
// https://github.com/realm/jazzy/issues/714
|
||||
$("code q").replaceWith(function () {
|
||||
return ["\"", $(this).contents(), "\""];
|
||||
});
|
4
docsets/NumericAnnex.docset/Contents/Resources/Documents/js/jquery.min.js
vendored
Executable file
4
docsets/NumericAnnex.docset/Contents/Resources/Documents/js/jquery.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
<entry><version>1.0</version><url>https://xwu.github.io/NumericAnnex/docsets/NumericAnnex.tgz</url></entry>
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 216 216"><defs><linearGradient id="a" x1="108" y1="216" x2="108" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0071bc"/><stop offset="1" stop-color="#1a8bd6"/></linearGradient><linearGradient id="b" x1="67.5" y1="144" x2="67.5" y2="72" xlink:href="#a"/><linearGradient id="c" x1="67.5" y1="128.25" x2="67.5" y2="87.75" gradientTransform="translate(127.28 -4.46) rotate(60)" xlink:href="#a"/><linearGradient id="d" x1="67.5" y1="128.25" x2="67.5" y2="87.75" gradientTransform="translate(-59.78 112.46) rotate(-60)" xlink:href="#a"/><linearGradient id="e" x1="148.5" y1="144" x2="148.5" y2="72" xlink:href="#a"/><linearGradient id="f" x1="148.5" y1="128.25" x2="148.5" y2="87.75" gradientTransform="translate(167.78 -74.6) rotate(60)" xlink:href="#a"/><linearGradient id="g" x1="148.5" y1="128.25" x2="148.5" y2="87.75" gradientTransform="translate(-19.28 182.6) rotate(-60)" xlink:href="#a"/></defs><title>NumericAnnex</title><path d="M108,9A99,99,0,1,1,9,108,99,99,0,0,1,108,9m0-9A108,108,0,0,0,31.63,184.37,108,108,0,0,0,184.37,31.63,107.29,107.29,0,0,0,108,0Z" fill="url(#a)"/><rect x="63" y="72" width="9" height="72" rx="4.5" ry="4.5" fill="url(#b)"/><rect x="63" y="72" width="9" height="72" rx="4.5" ry="4.5" transform="translate(-59.78 112.46) rotate(-60)" fill="url(#c)"/><rect x="63" y="72" width="9" height="72" rx="4.5" ry="4.5" transform="translate(127.28 -4.46) rotate(60)" fill="url(#d)"/><rect x="144" y="72" width="9" height="72" rx="4.5" ry="4.5" fill="url(#e)"/><rect x="144" y="72" width="9" height="72" rx="4.5" ry="4.5" transform="translate(-19.28 182.6) rotate(-60)" fill="url(#f)"/><rect x="144" y="72" width="9" height="72" rx="4.5" ry="4.5" transform="matrix(0.5, 0.87, -0.87, 0.5, 167.78, -74.6)" fill="url(#g)"/></svg>
|
After Width: | Height: | Size: 1.8 KiB |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 6.3 KiB |
|
@ -0,0 +1,291 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>NumericAnnex 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 title="NumericAnnex 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/DoubleWidth.html">DoubleWidth</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Float.html">Float</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/FloatingPoint.html">FloatingPoint</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int.html">Int</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int16.html">Int16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int32.html">Int32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int64.html">Int64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/Int8.html">Int8</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt.html">UInt</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt16.html">UInt16</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt32.html">UInt32</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt64.html">UInt64</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="Extensions/UInt8.html">UInt8</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">Structures</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">Type Aliases</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 id='img-src-https-xwu-github-io-numericannex-img-numericannex-2017-09-02-svg-alt-numericannex-height-72-br-numericannex' class='heading'><img src="https://xwu.github.io/NumericAnnex/img/NumericAnnex-2017-09-02.svg" alt="NumericAnnex" height="72"><br>NumericAnnex</h1>
|
||||
|
||||
<p>NumericAnnex supplements the numeric facilities provided in the Swift standard
|
||||
library.</p>
|
||||
|
||||
<p><a href="https://travis-ci.org/xwu/NumericAnnex"><img src="https://travis-ci.org/xwu/NumericAnnex.svg?branch=master" alt="Build Status"></a>
|
||||
<a href="https://codecov.io/gh/xwu/NumericAnnex"><img src="https://codecov.io/gh/xwu/NumericAnnex/branch/master/graph/badge.svg" alt="codecov"></a></p>
|
||||
<h2 id='features' class='heading'>Features</h2>
|
||||
|
||||
<ul>
|
||||
<li>The exponentiation operator <code>**</code> and the compound assignment operator <code>**=</code>.</li>
|
||||
<li>Extension methods for <code>BinaryInteger</code> exponentiation, square root, cube root,
|
||||
greatest common divisor, and least common multiple.</li>
|
||||
<li><code><a href="Protocols/Math.html">Math</a></code>, a protocol for signed numeric types that support elementary functions.</li>
|
||||
<li><code><a href="Protocols/Real.html">Real</a></code>, a protocol for floating-point types that support elementary functions
|
||||
and a selection of special functions.</li>
|
||||
<li><code><a href="Protocols/PRNG.html">PRNG</a></code>, a protocol for pseudo-random number generators.</li>
|
||||
<li><code><a href="Structs/Rational.html">Rational</a></code>, a value type to represent rational values which supports division
|
||||
by zero.</li>
|
||||
<li><code><a href="Structs/Complex.html">Complex</a></code>, a value type to represent complex values in Cartesian form.</li>
|
||||
<li><code><a href="Classes/Random.html">Random</a></code> and <code><a href="Classes/Random/Xoroshiro.html">Random.Xoroshiro</a></code>, two reference types implementing efficient
|
||||
pseudo-random number generators.</li>
|
||||
</ul>
|
||||
|
||||
<blockquote>
|
||||
<p>Note: This project is in the early stages of development and is not
|
||||
production-ready at this time.</p>
|
||||
</blockquote>
|
||||
<h2 id='requirements' class='heading'>Requirements</h2>
|
||||
|
||||
<p>NumericAnnex requires Swift 4.0. On Apple platforms, it also requires the
|
||||
Security framework for cryptographically secure random bytes.</p>
|
||||
<h2 id='installation' class='heading'>Installation</h2>
|
||||
|
||||
<p>After NumericAnnex has been cloned or downloaded locally, build the library
|
||||
using the command <code>swift build</code> (macOS) or <code>swift build -Xcc -D_GNU_SOURCE</code>
|
||||
(Linux). Run tests with the command <code>swift test</code> (macOS) or
|
||||
<code>swift test -Xcc -D_GNU_SOURCE</code> (Linux). An Xcode project can be generated with
|
||||
the command <code>swift package generate-xcodeproj</code>.</p>
|
||||
|
||||
<p>To add the package as a dependency using <a href="https://cocoapods.org">CocoaPods</a>,
|
||||
insert the following line in your <code>Podfile</code>:</p>
|
||||
<pre class="highlight ruby"><code><span class="n">pod</span> <span class="s1">'NumericAnnex'</span><span class="p">,</span> <span class="s1">'~> 0.1.19'</span>
|
||||
</code></pre>
|
||||
|
||||
<p><a href="https://swift.org/package-manager/">Swift Package Manager</a> can also be used to
|
||||
add the package as a dependency. See Swift documentation for details.</p>
|
||||
<h2 id='basic-usage' class='heading'>Basic Usage</h2>
|
||||
<pre class="highlight swift"><code><span class="kd">import</span> <span class="kt">NumericAnnex</span>
|
||||
|
||||
<span class="nf">print</span><span class="p">(</span><span class="mi">2</span> <span class="o">**</span> <span class="mi">3</span><span class="p">)</span>
|
||||
<span class="c1">// Prints "8".</span>
|
||||
|
||||
<span class="nf">print</span><span class="p">(</span><span class="mf">4.0</span> <span class="o">**</span> <span class="mf">5.0</span><span class="p">)</span>
|
||||
<span class="c1">// Prints "1024.0".</span>
|
||||
|
||||
<span class="nf">print</span><span class="p">(</span><span class="kt">Int</span><span class="o">.</span><span class="nf">cbrt</span><span class="p">(</span><span class="mi">8</span><span class="p">))</span>
|
||||
<span class="c1">// Prints "2".</span>
|
||||
|
||||
<span class="nf">print</span><span class="p">(</span><span class="kt">Double</span><span class="o">.</span><span class="nf">cbrt</span><span class="p">(</span><span class="mf">27.0</span><span class="p">))</span>
|
||||
<span class="c1">// Prints "3.0".</span>
|
||||
|
||||
<span class="k">var</span> <span class="nv">x</span><span class="p">:</span> <span class="kt">Ratio</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">/</span> <span class="mi">4</span>
|
||||
<span class="c1">// Ratio is a type alias for Rational<Int>.</span>
|
||||
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">x</span><span class="o">.</span><span class="nf">reciprocal</span><span class="p">())</span>
|
||||
<span class="c1">// Prints "4".</span>
|
||||
|
||||
<span class="n">x</span> <span class="o">*=</span> <span class="mi">8</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="n">x</span><span class="p">)</span>
|
||||
<span class="c1">// Prints "4".</span>
|
||||
|
||||
<span class="n">x</span> <span class="o">=</span> <span class="kt">Ratio</span><span class="p">(</span><span class="kt">Float</span><span class="o">.</span><span class="n">phi</span><span class="p">)</span> <span class="c1">// Golden ratio.</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
|
||||
<span class="c1">// Prints "13573053/8388608".</span>
|
||||
|
||||
<span class="k">var</span> <span class="nv">z</span><span class="p">:</span> <span class="kt">Complex64</span> <span class="o">=</span> <span class="mi">42</span> <span class="o">*</span> <span class="o">.</span><span class="n">i</span>
|
||||
<span class="c1">// Complex64 is a type alias for Complex<Float>.</span>
|
||||
|
||||
<span class="nf">print</span><span class="p">(</span><span class="kt">Complex</span><span class="o">.</span><span class="nf">sqrt</span><span class="p">(</span><span class="n">z</span><span class="p">))</span>
|
||||
<span class="c1">// Prints "4.58258 + 4.58258i".</span>
|
||||
|
||||
<span class="n">z</span> <span class="o">=</span> <span class="o">.</span><span class="n">pi</span> <span class="o">+</span> <span class="o">.</span><span class="n">i</span> <span class="o">*</span> <span class="o">.</span><span class="nf">log</span><span class="p">(</span><span class="mi">2</span> <span class="o">-</span> <span class="o">.</span><span class="nf">sqrt</span><span class="p">(</span><span class="mi">3</span><span class="p">))</span>
|
||||
<span class="nf">print</span><span class="p">(</span><span class="kt">Complex</span><span class="o">.</span><span class="nf">cos</span><span class="p">(</span><span class="n">z</span><span class="p">)</span><span class="o">.</span><span class="n">real</span><span class="p">)</span>
|
||||
<span class="c1">// Prints "-2.0".</span>
|
||||
</code></pre>
|
||||
<h2 id='documentation' class='heading'>Documentation</h2>
|
||||
|
||||
<p>All public protocols, types, and functions have been carefully documented in the
|
||||
code. See the <a href="https://xwu.github.io/NumericAnnex/">formatted reference</a> for
|
||||
details.</p>
|
||||
|
||||
<p>The project adheres to many design patterns found in the Swift standard library.
|
||||
For example, <code><a href="Protocols/Math.html">Math</a></code> types provide methods such as <code>cubeRoot()</code> and <code>tangent()</code>
|
||||
just as <code>FloatingPoint</code> types provide methods such as <code>squareRoot()</code>.</p>
|
||||
|
||||
<p>No free functions are declared in this library unless they overload existing
|
||||
ones in the Swift standard library. Instead, functions such as <code>cbrt(_:)</code> and
|
||||
<code>tan(_:)</code> are provided as static members. This avoids collisions with C standard
|
||||
library functions that you may wish to use. It also promotes clarity at the call
|
||||
site when the result of a complex operation differs from that of its real
|
||||
counterpart (e.g., <code>Complex128.cbrt(-8) != -2</code>).</p>
|
||||
<h2 id='future-directions' class='heading'>Future Directions</h2>
|
||||
|
||||
<ul>
|
||||
<li>Add more tests, including performance tests</li>
|
||||
<li>Design and implement additional methods on <code><a href="Protocols/PRNG.html">PRNG</a></code></li>
|
||||
</ul>
|
||||
<h2 id='license' class='heading'>License</h2>
|
||||
|
||||
<p>All original work is released under the MIT license. See
|
||||
<a href="https://github.com/xwu/NumericAnnex/blob/master/LICENSE">LICENSE</a> for details.</p>
|
||||
|
||||
<p>Portions of the complex square root and elementary transcendental functions use
|
||||
checks for special values adapted from libc++. Code in libc++ is dual-licensed
|
||||
under the MIT and UIUC/NCSA licenses.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>© 2017 <a class="link" href="https://diploid.ca" target="_blank" rel="external">Xiaodi Wu</a>. All rights reserved. (Last updated: 2017-09-30)</p>
|
||||
<p>Generated by <a href="https://github.com/realm/jazzy" target="_blank" rel="external">Jazzy</a> v0.8.4, a <a href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
|
@ -0,0 +1,15 @@
|
|||
window.jazzy = { 'docset': false };
|
||||
if (typeof window.dash != 'undefined') {
|
||||
document.documentElement.className += ' dash';
|
||||
window.jazzy.docset = true;
|
||||
}
|
||||
if (navigator.userAgent.match(/xcode/i)) {
|
||||
document.documentElement.className += ' xcode';
|
||||
window.jazzy.docset = true;
|
||||
}
|
||||
|
||||
// Dumb down quotes within code blocks that delimit strings instead of quotations
|
||||
// https://github.com/realm/jazzy/issues/714
|
||||
$("code q").replaceWith(function () {
|
||||
return ["\"", $(this).contents(), "\""];
|
||||
});
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue