You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
6.0 KiB
HTML
113 lines
6.0 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<!-- This manual describes how to install and use the GNU multiple precision
|
|
arithmetic library, version 6.1.0.
|
|
|
|
Copyright 1991, 1993-2015 Free Software Foundation, Inc.
|
|
|
|
Permission is granted to copy, distribute and/or modify this document under
|
|
the terms of the GNU Free Documentation License, Version 1.3 or any later
|
|
version published by the Free Software Foundation; with no Invariant Sections,
|
|
with the Front-Cover Texts being "A GNU Manual", and with the Back-Cover
|
|
Texts being "You have freedom to copy and modify this GNU Manual, like GNU
|
|
software". A copy of the license is included in
|
|
GNU Free Documentation License. -->
|
|
<!-- Created by GNU Texinfo 6.4, http://www.gnu.org/software/texinfo/ -->
|
|
<head>
|
|
<title>Divide and Conquer Division (GNU MP 6.1.0)</title>
|
|
|
|
<meta name="description" content="How to install and use the GNU multiple precision arithmetic library, version 6.1.0.">
|
|
<meta name="keywords" content="Divide and Conquer Division (GNU MP 6.1.0)">
|
|
<meta name="resource-type" content="document">
|
|
<meta name="distribution" content="global">
|
|
<meta name="Generator" content="makeinfo">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link href="index.html#Top" rel="start" title="Top">
|
|
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
|
|
<link href="Division-Algorithms.html#Division-Algorithms" rel="up" title="Division Algorithms">
|
|
<link href="Block_002dWise-Barrett-Division.html#Block_002dWise-Barrett-Division" rel="next" title="Block-Wise Barrett Division">
|
|
<link href="Basecase-Division.html#Basecase-Division" rel="prev" title="Basecase Division">
|
|
<style type="text/css">
|
|
<!--
|
|
a.summary-letter {text-decoration: none}
|
|
blockquote.indentedblock {margin-right: 0em}
|
|
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
|
|
blockquote.smallquotation {font-size: smaller}
|
|
div.display {margin-left: 3.2em}
|
|
div.example {margin-left: 3.2em}
|
|
div.lisp {margin-left: 3.2em}
|
|
div.smalldisplay {margin-left: 3.2em}
|
|
div.smallexample {margin-left: 3.2em}
|
|
div.smalllisp {margin-left: 3.2em}
|
|
kbd {font-style: oblique}
|
|
pre.display {font-family: inherit}
|
|
pre.format {font-family: inherit}
|
|
pre.menu-comment {font-family: serif}
|
|
pre.menu-preformatted {font-family: serif}
|
|
pre.smalldisplay {font-family: inherit; font-size: smaller}
|
|
pre.smallexample {font-size: smaller}
|
|
pre.smallformat {font-family: inherit; font-size: smaller}
|
|
pre.smalllisp {font-size: smaller}
|
|
span.nolinebreak {white-space: nowrap}
|
|
span.roman {font-family: initial; font-weight: normal}
|
|
span.sansserif {font-family: sans-serif; font-weight: normal}
|
|
ul.no-bullet {list-style: none}
|
|
-->
|
|
</style>
|
|
|
|
|
|
</head>
|
|
|
|
<body lang="en">
|
|
<a name="Divide-and-Conquer-Division"></a>
|
|
<div class="header">
|
|
<p>
|
|
Next: <a href="Block_002dWise-Barrett-Division.html#Block_002dWise-Barrett-Division" accesskey="n" rel="next">Block-Wise Barrett Division</a>, Previous: <a href="Basecase-Division.html#Basecase-Division" accesskey="p" rel="prev">Basecase Division</a>, Up: <a href="Division-Algorithms.html#Division-Algorithms" accesskey="u" rel="up">Division Algorithms</a> [<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<hr>
|
|
<a name="Divide-and-Conquer-Division-1"></a>
|
|
<h4 class="subsection">15.2.3 Divide and Conquer Division</h4>
|
|
|
|
<p>For divisors larger than <code>DC_DIV_QR_THRESHOLD</code>, division is done by dividing.
|
|
Or to be precise by a recursive divide and conquer algorithm based on work by
|
|
Moenck and Borodin, Jebelean, and Burnikel and Ziegler (see <a href="References.html#References">References</a>).
|
|
</p>
|
|
<p>The algorithm consists essentially of recognising that a 2NxN division
|
|
can be done with the basecase division algorithm (see <a href="Basecase-Division.html#Basecase-Division">Basecase Division</a>),
|
|
but using N/2 limbs as a base, not just a single limb. This way the
|
|
multiplications that arise are (N/2)x(N/2) and can take advantage of
|
|
Karatsuba and higher multiplication algorithms (see <a href="Multiplication-Algorithms.html#Multiplication-Algorithms">Multiplication Algorithms</a>). The two “digits” of the quotient are formed by recursive
|
|
Nx(N/2) divisions.
|
|
</p>
|
|
<p>If the (N/2)x(N/2) multiplies are done with a basecase multiplication
|
|
then the work is about the same as a basecase division, but with more function
|
|
call overheads and with some subtractions separated from the multiplies.
|
|
These overheads mean that it’s only when N/2 is above
|
|
<code>MUL_TOOM22_THRESHOLD</code> that divide and conquer is of use.
|
|
</p>
|
|
<p><code>DC_DIV_QR_THRESHOLD</code> is based on the divisor size N, so it will be somewhere
|
|
above twice <code>MUL_TOOM22_THRESHOLD</code>, but how much above depends on the
|
|
CPU. An optimized <code>mpn_mul_basecase</code> can lower <code>DC_DIV_QR_THRESHOLD</code> a
|
|
little by offering a ready-made advantage over repeated <code>mpn_submul_1</code>
|
|
calls.
|
|
</p>
|
|
<p>Divide and conquer is asymptotically <em>O(M(N)*log(N))</em> where
|
|
<em>M(N)</em> is the time for an NxN multiplication done with FFTs. The
|
|
actual time is a sum over multiplications of the recursed sizes, as can be
|
|
seen near the end of section 2.2 of Burnikel and Ziegler. For example, within
|
|
the Toom-3 range, divide and conquer is <em>2.63*M(N)</em>. With higher
|
|
algorithms the <em>M(N)</em> term improves and the multiplier tends to <em>log(N)</em>. In practice, at moderate to large sizes, a 2NxN division
|
|
is about 2 to 4 times slower than an NxN multiplication.
|
|
</p>
|
|
|
|
<hr>
|
|
<div class="header">
|
|
<p>
|
|
Next: <a href="Block_002dWise-Barrett-Division.html#Block_002dWise-Barrett-Division" accesskey="n" rel="next">Block-Wise Barrett Division</a>, Previous: <a href="Basecase-Division.html#Basecase-Division" accesskey="p" rel="prev">Basecase Division</a>, Up: <a href="Division-Algorithms.html#Division-Algorithms" accesskey="u" rel="up">Division Algorithms</a> [<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|