#!/usr/bin/python3 """Test reimplementation of hadamardsin.js. It's much slower! """ import numpy def hada(xs): if len(xs) < 2: return xs half = len(xs) // 2 left, right = hada(xs[:half]), hada(xs[half:]) return numpy.concatenate((left + right, left - right)) if __name__ == '__main__': for i in range(16): a = numpy.zeros(16) a[i] = 1 print(a, hada(a)) b = numpy.zeros(1024*256) b[0] = 1 b[7] = 3 print(sum(hada(b)))