Walsh matrix: Difference between revisions

no edit summary
(Added Algol 68)
imported>Maxima enthusiast
No edit summary
Line 380:
</pre>
[[File:Walsh_subplots.svg|center]]
 
=={{header|Maxima}}==
Using altern_kronecker as defined in Kronecker product task
<syntaxhighlight lang="maxima">
/* Function that attempts to implement recursion but only works for n when already called for every antecessor */
auxwalsh(n):=if n=1 then w[1]:matrix([1,1],[1,-1]) else
block(w[2]:matrix([1,1,1,1],[1,-1,1,-1],[1,1,-1,-1],[1,-1,-1,1]),w[n]:altern_kronecker(w[1],w[n-1]),w[n])$
 
/* Function that guarantees an output for integer n */
walsh(n):=block(makelist(auxwalsh(i),i,1,n),last(%%))$
 
/* Examples */
walsh(4)$
wxdraw2d(palette = [red,gray,green], image(%,0,0,30,30))$
 
walsh(6)$
wxdraw2d(palette = [red,gray,green], image(%,0,0,30,30))$
</syntaxhighlight>
[[File:Walsh4Maxima.png|thumb|center]]
[[File:Walsh6Maxima.png|thumb|center]]
 
=={{header|Phix}}==