does not work over N = 1000, possibly lack of gpu memory