Skip to content
DeepForgeby svx
All problems
EasyLinear Algebrala-192

Hadamard Transform 4-point

Problem

Multiply a length-4 vector v by the 4-point Hadamard matrix:

H4 = [[1,1,1,1],[1,-1,1,-1],[1,1,-1,-1],[1,-1,-1,1]]

Return H4 * v as a list of four values.

Hint

Each output is a signed sum of the inputs with signs given by a row of H4.

Test cases

case 1
in: [[1,0,0,0]]
expected: [1,1,1,1]
case 2
in: [[1,1,1,1]]
expected: [4,0,0,0]
case 3
in: [[1,2,3,4]]
expected: [10,-2,-4,0]
case 4
in: [[0,0,0,1]]
expected: [1,-1,-1,1]
Starter codePython
def hadamard_transform_4(v):
    # Your code here
    pass

4 test cases · run your code against them in the editor