pyquil icon indicating copy to clipboard operation
pyquil copied to clipboard

Defgate matrices should be type np.complex_

Open bramathon opened this issue 1 year ago • 0 comments

Pre-Report Checklist

  • [ ] I am running the latest versions of pyQuil and the Forest SDK
  • [ ] I checked to make sure that this bug has not already been reported

Issue Description

Matrices in DefGates contain complex numbers, but they are stored as objects rather than np.complex128 (or better yet np.complex256). This causes some common numpy operations such as np.real to fail.

How to Reproduce

image

import numpy as np
from pyquil.quilbase import DefGate

theta, phi = rng.random(2)*2*np.pi
defgate = DefGate(f"FSIM_{theta_deg}_{phi_deg}", matrix=matrices.FSIM(theta, phi))
defgate.matrix

bramathon avatar Feb 11 '24 21:02 bramathon