WWalshAster
Workflows

Coding workflows · Integer Walsh–Hadamard transform

03
Built around your work

A concrete starting point

Apply an unnormalized Walsh–Hadamard transform to a nonempty power-of-two sequence of at most 256 bounded integers. Reject invalid lengths and Boolean values, then check that applying the transform twice multiplies the original by its length.

01

Open the context

Choose the project folder and name the files or behavior involved.

02

Define the change

Describe the input, expected output and boundaries that must stay intact.

03

Inspect the work

Review the proposed edits and any commands before relying on their result.

04

Check the outcome

Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

Integer Walsh–Hadamard transform

A concrete starting point
def walsh_transform(values):
    out = list(values)
    n = len(out)
    if not 1 <= n <= 256 or n & (n - 1):
        raise ValueError("length.power_two")
    if any(type(v) is not int or abs(v) > 1000000 for v in out):
        raise ValueError("value.range")
    step = 1
    while step < n:
        for start in range(0, n, 2 * step):
            for j in range(start, start + step):
                a, b = out[j], out[j + step]
                out[j], out[j + step] = a + b, a - b
        step *= 2
    return out

The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.

AI coding workspace

Your next change starts here.

Get the Windows app ↗