<br><br><div class="gmail_quote">2008/12/11 Matthew Woehlke <span dir="ltr">&lt;<a href="mailto:mw_triad@users.sourceforge.net">mw_triad@users.sourceforge.net</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">Cyrille Berger wrote:<br>
&gt; it&#39;s not erand... We need a non recursive function to be able to compute it&#39;s<br>
&gt; value at every pixel independentely of other values. Being integer based<br>
&gt; (unlike the current one) would be a huge bonus, since I discovered since that<br>
&gt; time that floating point units in CPU are buggy and give very different<br>
&gt; results from one arch to an other...<br>
<br>
</div>Honestly I&#39;m not clear why erand48 doesn&#39;t work (it doesn&#39;t, I&#39;ve been<br>
playing with it in a stand-alone program). You&#39;d think with suitably<br>
large and semi-prime numbers, you could get a distribution where A*x % b<br>
results in a halfway decent f(x) for reasonable B. Alas, seems not.<br>
<br>
Well, what I did for my plasma stand-alone is run (x%5 + y%37)<br>
iterations. It seems to give an acceptable result, but it&#39;s relatively<br>
expensive :-).<br>
<div class="Ih2E3d"><br>
&gt; On Thursday 11 December 2008, Matthew Woehlke wrote:<br>
</div><div class="Ih2E3d">&gt;&gt; The png is substantial (500+kb), so I dumped it at<br>
&gt;&gt; <a href="http://img124.imageshack.us/img124/9986/noisetesthq8.png" target="_blank">http://img124.imageshack.us/img124/9986/noisetesthq8.png</a>. (Um. And<br>
&gt;&gt; ImageShack no longer works without scripting or View Source; guess I<br>
&gt;&gt; won&#39;t be using them any more.)<br>
&gt; Here is what I get: <a href="http://cyrille.diwi.org/tmp/noise.png" target="_blank">http://cyrille.diwi.org/tmp/noise.png</a><br>
<br>
</div>It&#39;s not as bad, but I would say there are artifacts there also. Hmm...<br>
I wonder how much difference using long double makes, it may be that<br>
you&#39;re getting 80-bit calculations and I am not?<br>
<br>
Anyway, this simple change... well, looks at least as good as yours,<br>
maybe a *tiny* bit better. I&#39;m wondering if some of it is just in my<br>
head ;-). Regardless, this makes things on /my/ end a lot better:<br>
<br>
Index: image/kis_random_generator.cc<br>
===================================================================<br>
--- image/kis_random_generator.cc &nbsp; &nbsp; &nbsp; (revision 895863)<br>
+++ image/kis_random_generator.cc &nbsp; &nbsp; &nbsp; (working copy)<br>
@@ -46,8 +46,8 @@<br>
 &nbsp; &nbsp; &nbsp;// To plot it in Octave :<br>
 &nbsp; &nbsp; &nbsp;// t = 1:1:100000;<br>
 &nbsp; &nbsp; &nbsp;//plot (t, sort(0.5*(cos( cos(cos(t.*t.*t.*t))) + 1)));<br>
- &nbsp; &nbsp;// This function has a near-gaussian distribtution<br>
- &nbsp; &nbsp;int n = x + (y + 1) * d-&gt;seed;<br>
+ &nbsp; &nbsp;// This function has a near-gaussian distribution<br>
+ &nbsp; &nbsp;quint64 n = (quint64(x) * 1103515249) + (quint64(y) * 91573) + d-&gt;seed;<br>
 &nbsp; &nbsp; &nbsp;return 0.5*(cos(pow(n, 4)) + 1);<br>
 &nbsp;}<br>
<br>
(note also the spelling correction ;-) )<br>
<br>
I may keep fiddling with a pure-integer random function.<br>
<div class="Ih2E3d"><br>
--<br>
Matthew<br>
Please do not quote my e-mail address unobfuscated in message bodies.<br>
</div></blockquote></div><br>I use random in Sumi-e brush. You can look how it is used in brush.cpp<br><br>But basiclly<br>#ifdef _WIN32<br>#define srand48 srand<br>#define drand48 rand<br>#endif<br><br>and I&#39;m using drand48();<br>
<br>Works quite fast :)<br>