Hi Ralf,<br>
Thanks for your help on this problem!<br>
The code I sent was intended to give some idea of what I was
doing. Luckily, I discovered that the problem was with the aldor
optimizer. Down the road of compilation it did wrong additions
because of the way I used some variables. <br>
<br>
As an Example:<br>
k had value 0, j also 0 and m 2 but the optimizer gave
index k+j+m as 7 in some few instances when I tried to access an array
with A.(k+j+m) instead of:<br><br>
kjm := k+j+m and then A.kjm.<br>
<br>
This was an intermittent problem that disappeard when I
surrounded the code with extraneous stdouts but is fixed now at my code level. I will file a bug report later.<br>
<br>
As for the usage of the PrimeField, this is the spec:<br>
%27 >> PrimeField<br>
() @ (p: AldorInteger) -> (<br>
PrimeFieldCategory with <br>
== PrimeField0(p) add ()<br>
)<br>
<br>
That means PrimeField(p:AldorInteger) is permissible.<br>
<br>
I have also been told by some Aldor experts to do "macro constv ==
value" which I do follow even though I don't see the penalty of constv
== value to define a constant.<br>
<br>
Thanks again for all your time.<br>
Akpodigha.<br>
<br>
<br><br><div><span class="gmail_quote">On 9/28/05, <b class="gmail_sendername">Ralf Hemmecke</b> <<a href="mailto:ralf@hemmecke.de">ralf@hemmecke.de</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Akpodigha,<br><br>I cannot compile your code. It is incomplete. Neither<br>FFTMultiplicationPackage nor PrimitiveRootOfUnitFinder is in my Aldor<br>distribution. So I cannot reproduce your bug. Maybe it is even better do
<br>file your problem with complete code at<br><a href="http://www.aldor.org/bugreport.html">http://www.aldor.org/bugreport.html</a><br>so that the compiler people can try to trace the bug. I cannot because,<br>I don't have the compiler sources.
<br><br>But perhaps I can give some experiences with some constructions.<br><br> > p:Z := 17;<br> > K == PrimeField(p);<br><br>I really wonder whether this should compile at all. p is a variable here<br>and thus the compiler should reject it as an argument to PrimeField.
<br>Only constants are allowed as an argument to a domain constructor.<br><br>A workaround would be to put things inside a function<br><br>foo(p: Z): () == {<br> K == PrimeField p;<br> U == DenseUnivariatePolynomial(K,-"x");
<br> ...<br>}<br><br>and then call foo(17).<br><br>Further, I remember that I often had problems with defining domain<br>constants in my code. Like the<br><br> K == PrimeField p;<br><br>line above. I was told by some Aldor developer long ago that I should
<br>try something like<br> macro K == PrimeField p;<br>instead. I don't know what the compiler does exactly in both cases, but<br>if one looks at instantiations in both cases PrimeField(p) gets only<br>instantiated once even if it is used later several times.
<br>If some compiler developer could say some words here, I would be happy.<br><br>Ralf<br><br>Akpodigha Filatei wrote:<br>> On Tue, 27 Sep 2005, Ralf Hemmecke wrote:<br>> Thanks Ralf for your reply. I have corrected my algebrad usage
<br>> according to the documentation you referred to with same result.<br>> Pasted below is the content of a revised <a href="http://dfttest.as">dfttest.as</a>. Here I test the<br>> 'dft' in the package aliased as FFTMPKG against an exact (same) function
<br>> local to <a href="http://dfttest.as">dfttest.as</a> and got diff results with -lalgebra but correct same<br>> result with -lalgebrad.<br>><br>> One more weird thing about this is that I could get it to work by
<br>> placing "stderr" or "stdout" in the dft function at the package. This,<br>> I noticed by chance as I was profiling the function. It is taking me a<br>> heck of a time to specify exact location and minimum number of
<br>> stderr/stdout statements that would make it make but I am willing to do<br>> this.<br>><br>> I think you are right to say this is a compiler bug but I am working on<br>> a work-around as I have had to do in some other instances.
<br>><br>> #include "algebra"<br>><br>> macro {<br>> Z==Integer;<br>> MI == MachineInteger;<br>> FFTMPKG == FFTMultiplicationPackage;<br>> PRUF == PrimitiveRootOfUnityFinder;
<br>> }<br>><br>> import from TextWriter,String,Character,Symbol;<br>> p:Z := 17;<br>><br>> K == PrimeField(p);<br>><br>> U == DenseUnivariatePolynomial(K,-"x");<br>> PAK == PrimitiveArray K;
<br>><br>> import from K,U,FFTMPKG(K,U),Partial(K), PRUF(K);<br>> import from PAK,MI;<br>> x == monom;<br>><br>> main():() == {<br>> local n,k:MI;<br>> Y1:U := x^(3@Z) + x^(2@Z)+x+1::K::U;
<br>
> Y2:U := x^(3@Z) + (3::K)*x + 1::K::U;<br>><br>> s:MI := fftSize(Y1,Y2);<br>> stdout << "fftSize? "<< s <<newline;<br>><br>> n := shift(1,s); -- 2^s<br>> ww:Partial(K) := primitiveRootOfUnity(n);
<br>><br>> assert( not failed?(ww) );<br>><br>> w := retract(ww);<br>><br>> y1a:PAK := new(n,0$K);<br>> y11a:PAK := new(n,0$K);<br>><br>> kk := 0;<br>> for k in coefficients(Y1) repeat {
<br>> y1a.kk := k;<br>> kk := next(kk);<br>> }<br>><br>> wp:PAK := omegaPowers(w,n);<br>><br>> stdout << " DFT TEST ----- " << newline;<br>><br>> dftres11:PAK := dftt(s,y1a,wp);
<br>> dftres21:PAK := dft!(s,y1a,wp);<br>><br>> stdout<<"dft local [";<br>> for k in 0..prev(n) repeat {<br>> stdout << dftres11.k <<" ";<br>> }
<br>><br>> stdout<<"]"<<newline;<br>><br>> stdout<<"dft from package [ ";<br>><br>> for k in 0..prev(n) repeat {<br>> stdout << dftres21.k
<<" ";<br>> }<br>> stdout<<"]"<<newline;<br>><br>> }<br>><br>> dftt(s:MI,pol:PAK,wp:PAK):PAK == {....}<br>><br>> main()<br></blockquote></div><br><br clear="all">