MCPcopy Create free account
hub / github.com/NVlabs/LongLive / array_code_gen

Function array_code_gen

fouroversix/scripts/hadamard_code_gen.py:84–95  ·  view source on GitHub ↗
(arr: np.ndarray)

Source from the content-addressed store, hash-verified

82
83
84def array_code_gen(arr: np.ndarray) -> str:
85 n = arr.shape[0]
86 if arr.shape[0] != arr.shape[1]:
87 msg = f"Hadamard matrix is not square: {arr.shape}"
88 raise ValueError(msg)
89 out = [
90 f"out[{i}] = "
91 + " ".join([f"{'+' if arr[i, j] == 1 else '-'} x[{j}]" for j in range(n)])
92 + ";"
93 for i in range(n)
94 ]
95 return template.replace("{N}", str(n)).replace("{code}", "\n ".join(out))
96
97
98def main() -> None:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected