Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perm() returns 0.0 for large matrices #5

Closed
benkj opened this issue Jan 25, 2019 · 3 comments
Closed

perm() returns 0.0 for large matrices #5

benkj opened this issue Jan 25, 2019 · 3 comments
Labels
bug Something isn't working C++

Comments

@benkj
Copy link

benkj commented Jan 25, 2019

Consider the following code with hafnian++

import hafnian as haf
import numpy as np

n = 16
A = np.array([[0.308549, 0.350677], [0.350677, 0.398558]])
Atot = haf.kron_reduced(A,[n,n])
print(haf.perm(Atot))

it produces 0.0 as an outcome almost instantaneously. The same code with n=15 provides an output ~5e16 after a few seconds. The zero outcome with n=16 doesn't look right...

@nquesada
Copy link
Collaborator

Note that the unsigned long int ctype c goes all the way to 2^32-1. Thus basically the variable that contains the number of iterations is being overflowed. For this problem one can either change the variable type or embed the permanent into the hafnian and use Kan's formula (which will be much faster for a system with so many repetitions). Also note that for general permanents of that size the accuracy of the computation is compromised. Thanks for the report @benkj !

@josh146 josh146 added bug Something isn't working C++ labels Jul 1, 2019
@josh146
Copy link
Member

josh146 commented Jul 1, 2019

@bgupt, is this fixed now that #20 is merged?

@bgupt
Copy link
Contributor

bgupt commented Jul 9, 2019

yeah, it is fixed!

@josh146 josh146 closed this as completed Jul 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working C++
Projects
None yet
Development

No branches or pull requests

4 participants