thewalrus
thewalrus copied to clipboard
Allow user to choose algorithm in hafnian wrapper
Currently, when calling the hafnian Python wrapper, all you specify is whether recursive is True
or False
:
hafnian(A, loop=True, recursive=True, quad=True, approx=False, etc...)
We then apply logic to call the best case hafnian algorithm considering the matrix+options the user has provided.
We should modify it to look like this:
hafnian(A, loop=True, algorithm="best", options={})
where algorithm is a string containing the algorithm to use:
-
best
is the current logic (and the default) -
recursive
-
trace
-
approx
and options are the algorithm specific options, i.e. options={'samples': 100}
for the approx algorithm, options={'quad': True}
for the recursive, options={'powtrace': 'eigenvalues'}
for the trace algorithm, etc.
Note: the moment/repeated hafnian will have to remain its own function, since it also takes rpt
as an argument.
@nquesada is this still relevant? Current function signature here