File size: 771 Bytes
7d44c50 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | """CPU-only verification test for Kronecker Coefficients"""
print("Testing kronecker-cuda...")
ct = [[1,1,1],[2,0,-1],[1,-1,1]]
z_inv = [1/6, 1/2, 1/3]
def g(i, j, k):
return round(sum(z_inv[c] * ct[i][c] * ct[j][c] * ct[k][c] for c in range(3)))
tests = [
(0,0,0, 1), # g([3],[3],[3]) = trivial
(0,1,1, 1), # g([3],[2,1],[2,1])
(1,1,0, 1), # g([2,1],[2,1],[3])
(1,1,1, 1), # g([2,1],[2,1],[2,1])
(1,1,2, 1), # g([2,1],[2,1],[1,1,1]) = 1 (sign rep tensor)
(2,2,0, 1), # g([1^3],[1^3],[3])
]
passed = 0
for i,j,k,expected in tests:
got = g(i,j,k)
ok = got == expected
print(f" {'PASS' if ok else 'FAIL'}: g({i},{j},{k}) = {got} (expected {expected})")
if ok: passed += 1
print(f"\n{passed}/{len(tests)} tests passed")
|