Repository: jcmgray/quimb

Issue:
Add "phase" and "cphase" aliases for "u1" and "cu1"
### Is your feature request related to a problem?

The phase gate has the matrix `diag(1, e^{i theta})` (reference: [PhaseGate in Qiskit](https://docs.quantum.ibm.com/api/qiskit/qiskit.circuit.library.PhaseGate)).
The controlled phase gate has the matrix `diag(1, 1, 1, e^{i theta})` (reference: [CPhaseGate in Qiskit](https://docs.quantum.ibm.com/api/qiskit/qiskit.circuit.library.CPhaseGate)).

The phase gate is equivalent to RZ up to global phase, and the controlled phase gate can be implemented with one RZZ and two RZ. Still, these are common gates so it would be nice to have them. If these are welcome,  I can submit a PR.

### Describe the solution you'd like

_No response_

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Discussion:
pep8speaks: Hello @kevinsung! Thanks for opening this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:

* In the file [`quimb/tensor/circuit.py`](https://github.com/jcmgray/quimb/blob/b51323ede4af289bb437e4a224bb994245d4c533/quimb/tensor/circuit.py):

> [Line 2158:80](https://github.com/jcmgray/quimb/blob/b51323ede4af289bb437e4a224bb994245d4c533/quimb/tensor/circuit.py#L2158): [E501](https://duckduckgo.com/?q=pep8%20E501) line too long (80 > 79 characters)





Patch:
diff --git a/quimb/tensor/circuit.py b/quimb/tensor/circuit.py
index 16a1723..39157e3 100644
--- a/quimb/tensor/circuit.py
+++ b/quimb/tensor/circuit.py
@@ -556,6 +556,7 @@ def u1_gate_param_gen(params):
 
 
 register_param_gate("U1", u1_gate_param_gen, 1)
+register_param_gate("PHASE", u1_gate_param_gen, 1)
 
 
 # two qubit parametrizable gates
@@ -629,6 +630,7 @@ def cu1_param_gen(params):
 
 
 register_param_gate("CU1", cu1_param_gen, 2)
+register_param_gate("CPHASE", cu1_param_gen, 2)
 
 
 def crx_param_gen(params):
@@ -2095,6 +2097,16 @@ class Circuit:
             **kwargs,
         )
 
+    def phase(self, lamda, i, gate_round=None, parametrize=False, **kwargs):
+        self.apply_gate(
+            "PHASE",
+            lamda,
+            i,
+            gate_round=gate_round,
+            parametrize=parametrize,
+            **kwargs,
+        )
+
     def cu3(
         self,
         theta,
@@ -2143,6 +2155,19 @@ class Circuit:
             **kwargs,
         )
 
+    def cphase(
+        self, lamda, i, j, gate_round=None, parametrize=False, **kwargs
+    ):
+        self.apply_gate(
+            "CPHASE",
+            lamda,
+            i,
+            j,
+            gate_round=gate_round,
+            parametrize=parametrize,
+            **kwargs,
+        )
+
     def fsim(
         self, theta, phi, i, j, gate_round=None, parametrize=False, **kwargs
     ):


Test patch:
diff --git a/tests/test_tensor/test_circuit.py b/tests/test_tensor/test_circuit.py
index 11533aa..0629271 100644
--- a/tests/test_tensor/test_circuit.py
+++ b/tests/test_tensor/test_circuit.py
@@ -250,6 +250,7 @@ class TestCircuit:
             ("u3", 1, 3),
             ("u2", 1, 2),
             ("u1", 1, 1),
+            ("phase", 1, 1),
             # two qubit
             ("cx", 2, 0),
             ("cy", 2, 0),
@@ -267,6 +268,7 @@ class TestCircuit:
             ("cu3", 2, 3),
             ("cu2", 2, 2),
             ("cu1", 2, 1),
+            ("cphase", 2, 1),
             ("fsim", 2, 2),
             ("fsimg", 2, 5),
             ("givens", 2, 1),