Walsh matrix: Difference between revisions
m
→{{header|Wren}}: Changed to Wren S/H
m (→{{header|Wren}}: Changed to Wren S/H) |
|||
(4 intermediate revisions by one other user not shown) | |||
Line 798:
'''Works with jaq, the Rust implementation of jq'''
This entry uses a non-recursive method for creating Walsh matrices, but the `kprod` definition
at [[Kronecker_product#jq]] could also be used as follows:
<syntaxhighlight lang="jq">
## Generate a Walsh matrix of size 2^$n for $n >= 1
def walsh:
. as $n
| [[1, 1], [1, -1]] as $w2
| if $n < 2 then $w2 else kprod($w2; $n - 1 | walsh) end;
</syntaxhighlight>
<syntaxhighlight lang="jq">
## Generic matrix functions
Line 845 ⟶ 855:
| .k = 1
| until (.k >= $n;
| .walsh[$i+$k][$j] = $wij
| .walsh[$i][$j+$k] = $wij
| .walsh[$i+$k][$j+$k] = -$wij ))
| .k += .k )
| .walsh ;
Line 1,491 ⟶ 1,501:
===Wren-cli===
Text mode version.
<syntaxhighlight lang="
import "./fmt" for Fmt
Line 1,663 ⟶ 1,673:
{{libheader|Wren-polygon}}
Image mode version.
<syntaxhighlight lang="
import "input" for Keyboard
import "graphics" for Canvas, Color
|