guilgautier / guilgautier/DPPy

Support complex-valued kernels

Open
#78 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
240
Forks
56
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**
The [documentation](https://dppy.readthedocs.io/en/latest/finite_dpps/definition.html#definition) says that the correlation kernel can be a complex Hermitian matrix with eigenvalues between 0 and 1. However, if you pass such a complex-valued matrix, it complains that the array is not symmetric:

```python
import numpy as np
from dppy.finite_dpps import FiniteDPP

rng = np.random.default_rng(12345)
dim = 5
mat = rng.standard_normal((dim, dim)) + 1j * rng.standard_normal((dim, dim))
mat @= mat.T.conj()
mat /= np.trace(mat)
assert np.allclose(mat, mat.T.conj())
eigs, vecs = np.linalg.eigh(mat)
assert all(0 <= e <= 1 for e in eigs)
dpp = FiniteDPP("correlation", K=mat)
```
```
Traceback (most recent call last):
File "/home/kjs/projects/ffsim/scratch/repro.py", line 12, in
dpp = FiniteDPP("correlation", K=mat)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/kjs/.pyenv/versions/ffsim/lib/python3.12/site-packages/dppy/finite_dpps.py", line 121, in __init__
self.K = is_symmetric(params.get('K', None))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/kjs/.pyenv/versions/ffsim/lib/python3.12/site-packages/dppy/utils.py", line 133, in is_symmetric
raise ValueError('array not symmetric: M.T != M')
ValueError: array not symmetric: M.T != M
```

The same issue exists for the likelihood kernel,
```python
dpp = FiniteDPP("likelihood", L=mat)
```

**Describe the solution you'd like**
Complex-valued kernels should be supported.

**Describe alternatives you've considered**
N/A

**Additional context**
Complex-valued kernels arise when using DPPs to sample from fermionic systems.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.