Nicolas,<div>Thanks.<div>by the way why do I see &quot;dirty&quot; packages even if I did not touch them?</div><div><br></div><div>For a little contribution I want to post </div><div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">
HTTPSocket&gt;&gt;httpGetDocument:args:accept:request:</blockquote></div><div>I see hundreds of changes when I select &#39;Changes&#39; in Monticello Browser</div><div>after step 4) below</div><div><br></div><div>Thanks in advance for your feedback (and eventually sorry if the question is silly)</div>
<div>Bye</div><div>Enrico<br><br><div class="gmail_quote">On Sun, Jan 24, 2010 at 4:10 PM, Nicolas Cellier <span dir="ltr">&lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">2010/1/24 Enrico Spinielli &lt;<a href="mailto:enrico.spinielli@googlemail.com">enrico.spinielli@googlemail.com</a>&gt;:<br>

<div class="im">&gt; No need to thank me, I just enjoyed to implement an algorithm in Squeak and<br>
&gt; signed for MIT license:<br>
&gt; so use/abuse/misuse/... freely.<br>
&gt; We all have to thank you and the others for looking after contributions and<br>
&gt; make them available<br>
&gt; in Trunk or images.<br>
&gt; I think that what Levente discovered from<br>
&gt; DigitalSignatureAlgorithm&gt;&gt;isProbablyPrime:<br>
&gt; is worth some thoughts in terms of cleanup and rationalisation...from the<br>
&gt; version info this<br>
&gt; piece of code seems to precede mine...and confirm the need of primality<br>
&gt; testing for encryption<br>
&gt; (hence big integers)<br>
&gt; Bye<br>
&gt; Enrico<br>
&gt; PS: I tried to see how to contribute, i.e. in the inbox but did not find too<br>
&gt; much of instructions<br>
&gt; (something in Squeak board blog but not too clear for me at least). Any<br>
&gt; suggestion? URL?<br>
&gt;<br>
<br>
</div>The preferred way:<br>
1) make your changes to the image<br>
2) open a Monticello browser,<br>
3) select one dirty packages in left pane (marked with *)<br>
   presumably, it&#39;s Kernel here.<br>
4) select <a href="http://source.squeak.org/inbox" target="_blank">http://source.squeak.org/inbox</a> in right pane<br>
5) press save button<br>
6) repeat step 3 for each dirty package<br>
7) post a message to this list indicating which set of .mcz solves which problem<br>
<br>
If <a href="http://source.squeak.org/inbox" target="_blank">http://source.squeak.org/inbox</a> does not appear for a specific package:<br>
a) unselect package in left pane<br>
b) select  <a href="http://source.squeak.org/inbox" target="_blank">http://source.squeak.org/inbox</a> in right pane<br>
c) choose pop up menu option &#39;add to package...&#39;<br>
d) go to step 3<br>
<br>
Hope I did not forget anything; maybe ask for a free beer to next<br>
Squeak smalltalk event ?<br>
<br>
cheers<br>
<font color="#888888"><br>
Nicolas<br>
</font><div><div></div><div class="h5"><br>
&gt; On Sat, Jan 23, 2010 at 9:51 PM, David T. Lewis &lt;<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; To follow up on this discussion from last month, I updated Squeak trunk<br>
&gt;&gt; such that LargePositiveInteger uses the probabilistic algorithm for<br>
&gt;&gt; #isPrime, and added method comments to explain. A couple of folks<br>
&gt;&gt; suggested<br>
&gt;&gt; this change, and Enrico concurred.<br>
&gt;&gt;<br>
&gt;&gt; It turns out that SmallInteger maxVal is a reasonable point at which<br>
&gt;&gt; to switch from use of #isPrime to #isProbablyPrime. On my system before<br>
&gt;&gt; the change:<br>
&gt;&gt;<br>
&gt;&gt;  count := 1000.<br>
&gt;&gt;  largeMin := SmallInteger maxVal + 1.<br>
&gt;&gt;<br>
&gt;&gt;  &quot;SmallInteger values up to maxVal&quot;<br>
&gt;&gt;  Time millisecondsToRun: [(SmallInteger maxVal - count to: SmallInteger<br>
&gt;&gt; maxVal) do: [:e | e isPrime]]. ==&gt; 120<br>
&gt;&gt;  Time millisecondsToRun: [(SmallInteger maxVal - count to: SmallInteger<br>
&gt;&gt; maxVal) do: [:e | e isProbablyPrime]]. ==&gt; 984<br>
&gt;&gt;<br>
&gt;&gt;  &quot;LargePositiveInteger values just above SmallInteger maxVal&quot;<br>
&gt;&gt;  Time millisecondsToRun: [(largeMin to: largeMin + count) do: [:e | e<br>
&gt;&gt; isPrime]]. ==&gt; 6599<br>
&gt;&gt;  Time millisecondsToRun: [(largeMin to: largeMin + count) do: [:e | e<br>
&gt;&gt; isProbablyPrime]]. ==&gt; 714<br>
&gt;&gt;<br>
&gt;&gt; After changing LargePositiveInteger&gt;&gt;isPrime, we have:<br>
&gt;&gt;<br>
&gt;&gt;  &quot;LargePositiveInteger values just above SmallInteger maxVal&quot;<br>
&gt;&gt;  Time millisecondsToRun: [(largeMin to: largeMin + count) do: [:e | e<br>
&gt;&gt; isPrime]]. ==&gt; 719<br>
&gt;&gt;<br>
&gt;&gt; So the implementation of LargePositiveInteger&gt;&gt;isPrime is now this:<br>
&gt;&gt;<br>
&gt;&gt; isPrime<br>
&gt;&gt;        &quot;Answer true if the receiver is a prime number. Use a probabilistic<br>
&gt;&gt; implementation       that<br>
&gt;&gt;        is much faster for large integers, and that is correct to an<br>
&gt;&gt; extremely high statistical<br>
&gt;&gt;        level of confidence (effectively deterministic).&quot;<br>
&gt;&gt;<br>
&gt;&gt;        ^ self isProbablyPrime<br>
&gt;&gt;<br>
&gt;&gt; Thanks to Enrico for his patience ;-)<br>
&gt;&gt;<br>
&gt;&gt; Dave<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Sat Dec 19 13:58:16 UTC 2009, Enrico Spinielli wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; The original implementation is was has been renamed by ul to<br>
&gt;&gt; &gt; isProbablyPrime<br>
&gt;&gt; &gt; Note that the probability is according to Knuth&#39;s words<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; ...less than (1/4)^25 that such a 25-time-in-a-row procedure gives the<br>
&gt;&gt; &gt; wrong<br>
&gt;&gt; &gt; information about its input. This is less than one chance in a<br>
&gt;&gt; &gt; quadrillion;<br>
&gt;&gt; &gt; [...]<br>
&gt;&gt; &gt; It&#39;s much more likely that our computer has dropped a bit in its<br>
&gt;&gt; &gt; calculations,<br>
&gt;&gt; &gt; due to hardware malfunctions or cosmic radiation, than that Algorithm P<br>
&gt;&gt; &gt; has<br>
&gt;&gt; &gt; repeatedly guessed wrong!<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; So &#39;probabilistic&#39; in this case is very much deterministic!<br>
&gt;&gt; &gt; For accessible rationale about the algoritm (and a non probabilistic<br>
&gt;&gt; &gt; better<br>
&gt;&gt; &gt; one as well)<br>
&gt;&gt; &gt; you can also see &quot;1.2.6 Example: Testing for<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Primality&lt;<a href="http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html#%_sec_1.2.6" target="_blank">http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html#%_sec_1.2.6</a>&gt;&quot;<br>
&gt;&gt; &gt; in SICP.<br>
&gt;&gt; &gt; A possible improvement could have been to keep a list of the first N<br>
&gt;&gt; &gt; prime numbers (i.e. N=1000 or whatever integrer where gain in<br>
&gt;&gt; &gt; performance<br>
&gt;&gt; &gt; and or memory) and resort to the probabilistic test if self<br>
&gt;&gt; &gt; is greater than the bigger in the list.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; The value of original algorithm is all research and reasoning that went<br>
&gt;&gt; &gt; into<br>
&gt;&gt; &gt; it from<br>
&gt;&gt; &gt; Knuth et al. (note the order of growth is log(n), where n is the integer<br>
&gt;&gt; &gt; under scrutiny)<br>
&gt;&gt; &gt; The problem with the new implementation is that it goes thru testing<br>
&gt;&gt; &gt; numbers<br>
&gt;&gt; &gt; which are<br>
&gt;&gt; &gt; clearly not prime, 5, 15, 25, 35...just to mention multiples of 5.<br>
&gt;&gt; &gt; It can possibly be faster for small integers hence the above possible<br>
&gt;&gt; &gt; improvement suggestion...but for the rest it should be thrown away IMHO.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Primality testing is very important for modern electronic<br>
&gt;&gt; &gt; communications,<br>
&gt;&gt; &gt; i.e. encryption<br>
&gt;&gt; &gt; and as such it has to be reliable and performant for big integers.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Hope this clarifies<br>
&gt;&gt; &gt; Bye<br>
&gt;&gt; &gt; Enrico<br>
&gt;&gt; &gt; PS: the comment in the code was explicit enough to allow to research for<br>
&gt;&gt; &gt;       the rationale about the algorithm...we should not fix what works<br>
&gt;&gt; &gt; (well)<br>
&gt;&gt; &gt;       there are so many other fixes waiting...<br>
&gt;&gt; &gt; On Sat, Dec 19, 2009 at 12:56 AM, David T. Lewis &lt;lewis at<br>
&gt;&gt; &gt; <a href="http://mail.msen.com" target="_blank">mail.msen.com</a>&gt;wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; &gt; On Fri, Dec 18, 2009 at 05:25:45PM +0100, Enrico Spinielli wrote:<br>
&gt;&gt; &gt; &gt; &gt; Hi all,<br>
&gt;&gt; &gt; &gt; &gt; I am back to checking Squeak after quite a while and got latest<br>
&gt;&gt; &gt; &gt; &gt; trunk.<br>
&gt;&gt; &gt; &gt; &gt; I looked after one of my contributions Integer&gt;&gt;isPrime<br>
&gt;&gt; &gt; &gt; &gt; and I found my implementation of Algorithm P from Knuth&#39;s AOCP vol 2<br>
&gt;&gt; &gt; &gt; &gt; substituted by an iteration of dividing self by all even numbers<br>
&gt;&gt; &gt; &gt; &gt; starting<br>
&gt;&gt; &gt; &gt; &gt; from 3<br>
&gt;&gt; &gt; &gt; &gt; and (correctly) stopping at self sqrtFloor.<br>
&gt;&gt; &gt; &gt; &gt; This is IMHO a questionable/useless &quot;improvement&quot;, not even looking<br>
&gt;&gt; &gt; &gt; &gt; to<br>
&gt;&gt; &gt; &gt; try<br>
&gt;&gt; &gt; &gt; &gt; to implement the Sieve of Eratostene...!<br>
&gt;&gt; &gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; &gt; Again IMHO isPrime should be reverted back to what has been renamed<br>
&gt;&gt; &gt; &gt; &gt; isProbablyPrime<br>
&gt;&gt; &gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; &gt; Not being anymore used to contribute I just signal it here...<br>
&gt;&gt; &gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; &gt; Hope it helps<br>
&gt;&gt; &gt; &gt; &gt; Bye<br>
&gt;&gt; &gt; &gt; &gt; --<br>
&gt;&gt; &gt; &gt; &gt; Enrico Spinielli<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; Enrico,<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; Is this your original implementation?<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;   isPrime<br>
&gt;&gt; &gt; &gt;        &quot;See isProbablyPrimeWithK:andQ: for the algoritm description.&quot;<br>
&gt;&gt; &gt; &gt;        | k q |<br>
&gt;&gt; &gt; &gt;        self &lt;= 1 ifTrue: [^self error: &#39;operation undefined&#39;].<br>
&gt;&gt; &gt; &gt;        self even ifTrue: [^self = 2].<br>
&gt;&gt; &gt; &gt;        k := 1.<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;        q := self - 1 bitShift: -1.<br>
&gt;&gt; &gt; &gt;        [q odd] whileFalse:<br>
&gt;&gt; &gt; &gt;                        [q := q bitShift: -1.<br>
&gt;&gt; &gt; &gt;                        k := k + 1].<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;        25 timesRepeat: [(self isProbablyPrimeWithK: k andQ: q)<br>
&gt;&gt; &gt; &gt; ifFalse:<br>
&gt;&gt; &gt; &gt; [^false]].<br>
&gt;&gt; &gt; &gt;        ^true<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; It was recently changed as follows:<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; &gt; Name: Kernel-ul.305<br>
&gt;&gt; &gt; &gt; &gt; Author: ul<br>
&gt;&gt; &gt; &gt; &gt; Time: 25 November 2009, 2:55:43.339 am<br>
&gt;&gt; &gt; &gt; &gt; UUID: a95be01c-d87c-154b-bdc6-c582dafad80b<br>
&gt;&gt; &gt; &gt; &gt; Ancestors: Kernel-nice.304<br>
&gt;&gt; &gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; &gt; - added Integer &gt;&gt; #sqrtFloor, which returns the floor of the square<br>
&gt;&gt; &gt; &gt; &gt; root<br>
&gt;&gt; &gt; &gt; of the receiver.<br>
&gt;&gt; &gt; &gt; &gt; - renamed Integer &gt;&gt; #isPrime to #isProbablyPrime.<br>
&gt;&gt; &gt; &gt; &gt; - added Integer &gt;&gt; #isPrime which is implemented as a deterministic<br>
&gt;&gt; &gt; &gt; primality test<br>
&gt;&gt; &gt; &gt; &gt; - both #isPrime and #isProbablyPrime return false for receivers &lt;= 1<br>
&gt;&gt; &gt; &gt; instead of raising an error<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; Is this a reasonable change?<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; Dave<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Enrico Spinielli<br>
&gt; &quot;Do Androids dream of electric sheep?&quot;— Philip K. Dick<br>
&gt; &quot;Hear and forget; see and remember;do and understand.&quot;—Mitchel Resnick<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Enrico Spinielli<br>&quot;Do Androids dream of electric sheep?&quot;— Philip K. Dick<br>&quot;Hear and forget; see and remember;do and understand.&quot;—Mitchel Resnick<br>

</div></div>