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;
reduce range (0;.k) as $i (.;k
| reduce range (0;. $k) as $ji (.;
.walsh[reduce range (0; $i][$j]k) as $wijj (.;
| .kwalsh[$i][$j] as $kwij
| .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="ecmascriptwren">import "./matrix" for Matrix
import "./fmt" for Fmt
 
Line 1,663 ⟶ 1,673:
{{libheader|Wren-polygon}}
Image mode version.
<syntaxhighlight lang="ecmascriptwren">import "dome" for Window
import "input" for Keyboard
import "graphics" for Canvas, Color
9,482

edits