Clojure JIRA
http://dev.clojure.org/jira/secure/IssueNavigator.jspa?reset=true&jqlQuery=project+%3D+MTOWER+ORDER+BY+updated+DESC%2C+priority+DESC%2C+created+ASC
An XML representation of a search requesten-us4.464925-07-2011[MTOWER-3] BigDecimal: unnecessary reflection used in math functions for coercion (bigint)
http://dev.clojure.org/jira/browse/MTOWER-3
math.numeric-tower<p>This improves performance, because no reflection has to be used (bigint):</p>
<p>Patched:<br/>
clojure.math.numeric-tower> (time (let <span class="error">[b (BigDecimal. "2.2")]</span> (dotimes <span class="error">[x 10000000]</span> (round b))))<br/>
"Elapsed time: 1640.177041 msecs" <br/>
Orig: <br/>
clojure.math.numeric-tower> (time (let <span class="error">[b (BigDecimal. "2.2")]</span> (dotimes <span class="error">[x 10000000]</span> (round b))))<br/>
"Elapsed time: 3498.339271 msecs"</p>
MTOWER-3BigDecimal: unnecessary reflection used in math functions for coercion (bigint)EnhancementMinorClosedDeclinedMark EngelbergJürgen HötzelMon, 13 May 2013 14:48:19 -0500Thu, 2 Jan 2014 00:39:29 -0600Thu, 2 Jan 2014 00:39:28 -060001<p>Andy, thanks for letting me know about this issue. I had no idea it's been sitting here in JIRA for months.</p>
<p>1. These numbers really do need to be converted to BigInt, not BigInteger.</p>
<p>2. There's nothing inherently problematic with the call to bigint. In my tests, it appears that this patch doesn't meaningfully improve the performance of floor or ceiling, only round. That's because it's not the call to bigint that is slow, but in round, you've used a call to .setScale with ROUND_HALF_UP, and that's faster than the method used in the code (adding 0.5M and then flooring).</p>
<p>3. Even though .setScale with ROUND_HALF_UP is faster than the current code, it <b>does not return the correct results</b> for negative numbers like -4.5M. The goal is to make the behavior match Math/round on doubles. For some reason, BigDecimal's ROUND_HALF_UP does the wrong thing for negative numbers (rounding up in magnitude, rather than rounding up in the sense of making it more positive).</p>
<p>So this patch is a no-go. The changes to floor and ceiling return BigInteger rather than BigInt and when modified to return BigInt, do not yield speed benefits. The change to round does yield a speed benefit, but the results are incorrect for negative numbers halfway between integers.</p>
<p>If you find a faster way to round decimal numbers than the existing mechanism that yields the correct results for negative numbers, let me know.</p>Global RankPatchCode[MTOWER-4] Typo in sqrt-ratio
http://dev.clojure.org/jira/browse/MTOWER-4
math.numeric-tower<p><tt>sqrt-ratio</tt> checks twice if <tt>sqrtnum</tt> is a floating-point number:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>(defn- sqrt-ratio [^clojure.lang.Ratio n]
(if (neg? n) Double/NaN
(let [numerator (.numerator n),
denominator (.denominator n),
sqrtnum (sqrt numerator)]
(if (float? sqrtnum)
(Math/sqrt n)
(let [sqrtden (sqrt denominator)]
(if (float? sqrtnum)
(Math/sqrt n)
(/ sqrtnum sqrtden)))))))
</pre>
</div></div>
<p>The second check should be a check for the type of <tt>sqrtden</tt> or the check(s) should be removed (and let <tt>/</tt> do the job).</p>MTOWER-4Typo in sqrt-ratioDefectMinorClosedCompletedMark EngelbergOlivier MielFri, 20 Dec 2013 11:52:52 -0600Sun, 29 Dec 2013 20:12:11 -0600Sun, 29 Dec 2013 20:11:43 -060000<p>Fixed and released as 0.0.3</p>Global Rank[MTOWER-2] Eliminate a few uses of Reflection in math.numeric-tower
http://dev.clojure.org/jira/browse/MTOWER-2
math.numeric-tower<p>There are a few cases where calls to .numerator and .denominator on clojure.lang.Ratio's cause reflection, because the Ratio is not type hinted as such.</p>MTOWER-2Eliminate a few uses of Reflection in math.numeric-towerEnhancementMinorResolvedCompletedMark EngelbergAndy FingerhutSun, 28 Oct 2012 19:47:00 -0500Fri, 23 Nov 2012 03:30:48 -0600Fri, 23 Nov 2012 03:30:48 -060000<p>mtower-2-eliminate-reflection-v1.txt dated Oct 28 2012 eliminates a few instances of reflection in math.numeric-tower.</p><p>Applied patch, updated version number to 0.0.2</p>Global Rank[MTOWER-1] README should be updated to conform to contrib standard
http://dev.clojure.org/jira/browse/MTOWER-1
math.numeric-tower<p>As per Sean Corfield's suggestion here: <a href="https://groups.google.com/forum/?fromgroups=#!searchin/clojure-dev/math/clojure-dev/p5oz42gR_sk/cesMHO9cDWEJ">https://groups.google.com/forum/?fromgroups=#!searchin/clojure-dev/math/clojure-dev/p5oz42gR_sk/cesMHO9cDWEJ</a><br/>
the math.numeric-tower README.md should be updated to be more useful, especially to newbies. </p>MTOWER-1README should be updated to conform to contrib standardEnhancementTrivialResolvedCompletedMark EngelbergChristian RomneySun, 16 Sep 2012 22:32:43 -0500Mon, 17 Sep 2012 11:33:44 -0500Mon, 17 Sep 2012 11:33:44 -050000<p>Please ignore previous patch (doesn't format code examples correctly). This one looks better on Github. You can see it here: <a href="https://github.com/xmlblog/math.numeric-tower">https://github.com/xmlblog/math.numeric-tower</a></p><p>Patch applied.</p>Global RankPatchCode