Python | Fast Walsh Hadamard Transform

Python Methods and Functions

sympy.discrete.transforms.fwht (): can Walsh-Hadamard transform (WHT) . This method uses the order of the Hadamard sequence. 
The sequence is automatically padded with zeros to the right, because the FXHT for radix-2 requires the number of sample points as a power of 2.

  Parameters:  - & gt;  seq:  [iterable] sequence on which WHT is to be applied.  Returns:  Fast Walsh Hadamard Transform Transform 

Example # 1:

# import sympy

from sympy import fwht

 
# sequence

seq = [ 23

56

12

555 ]

 
# hwht

transform = fwht (seq)

print ( "Transform :" , transform)

Output:

 Transform: [646, -576, -488, 510] 


Example # 2:

# import sympy

from sympy import fwht

 
# sequence

seq = [ 15 , 21 , 13 , 44 ]

 
# hwht

transform = fwht (seq)

print ( "Transform :" , transform)

Output:

 Transform: [93, -37, -21, 25] 




Tutorials