Walsh Transform

Author

Eric W. Weisstein
August 18, 2002

This notebook downloaded from http://mathworld.wolfram.com/notebooks/IntegralTransforms/WalshTransform.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/WalshTransform.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Code

WalshArray[s_,{f_,g_}]:=Nest[Apply[Join,f[{Map[Flatten[Map[{#,#}&,#]]&,#],Map[Flatten[Map[{#,-#}&,#]]&,g[#]]}]]&,{{1}},s]

WalshArray[s_,Sequency]:=WalshArray[s,{Identity,Reverse}]

WalshArray[s_,Natural]:=WalshArray[s,{Transpose,Identity}]

WalshArray[s_,Dyadic]:=WalshArray[s,{Identity,Identity}]

WalshTransform[l_List?MatrixQ]:=Module[{n=Length[l]},
l.WalshArray[Log[2,n],Natural]
]

FastWalshTransform[data_List?VectorQ]:=Nest[Flatten[Transpose[Partition[#, 2].{{1,1},{1,-1}}]] &,
data, Log[2, Length[data]]]

FastWalshTransform[data_List?MatrixQ]:=Module[{n=Length[data]},
Partition[FastWalshTransform[Flatten[data]],n]
]

Examples

Show[GraphicsArray[
DensityGraphics[#,Frame->False,Mesh->False]&/@
Join[
{data=CellularAutomaton[220,{{1},0},15]},
data.WalshArray[4,#]&/@{Sequency,Natural,Dyadic}
]
]
]

Show[
DensityGraphics[WalshTransform[CellularAutomaton[220,{{1},0},31]],Frame->False,Mesh->False]
]

Show[GraphicsArray[
DensityGraphics[#,Frame->False,Mesh->False]&/@
Join[
{data=CellularAutomaton[220,{{1},0},15]},
Abs[data.WalshArray[4,#]]&/@{Sequency,Natural,Dyadic}
]
]
]

Show[GraphicsArray[
DensityGraphics[#,Frame->False,Mesh->False]&/@
Join[
{data=CellularAutomaton[124,{{1},0},15]},
Abs[data.WalshArray[4,#]]&/@{Sequency,Natural,Dyadic}
]
]
]

Fast Walsh Transform

data=CellularAutomaton[220,{{1},0},31];

Show[DensityGraphics[data],Frame->False]

Show[DensityGraphics[WalshTransform[data]],Frame->False]