insert
Method of Qbit.
Overloads
| Name | Description |
|---|---|
insert(const integer site, const integer value) -> Qbit | Inserts a qubit set to the specified value at the specified site. |
insert(const integer site, const bool value) -> Qbit | Inserts a qubit set to the specified value at the specified site. |
insert(const integer site) -> Qbit | Inserts a qubit set to 0 at the specified site. |
insert(const integer site, const integer value) -> Qbit
Inserts a qubit set to the specified value at the specified site.
Parameters
- site: The site of the qubit being queried in the product state.
- value: The value of the inserted state (0 or 1)
Example
Qbit("0011").insert(2,0) // Returns (1 + 0i)|00011>
Qbit("0011").insert(3,0) // Returns (1 + 0i)|00101>
Qbit("0011").insert(3,1) // Returns (1 + 0i)|00111>
// Qbit("0011").insert(4,0) //Error "The specified site is out of bound."
insert(const integer site, const bool value) -> Qbit
Inserts a qubit set to the specified value at the specified site.
Parameters
- site: The site of the qubit being queried in the product state.
- value: The value of the inserted state (0 or 1)
Example
Qbit("0011").insert(2,0) // Returns (1 + 0i)|00011>
Qbit("0011").insert(3,0) // Returns (1 + 0i)|00101>
Qbit("0011").insert(3,1) // Returns (1 + 0i)|00111>
// Qbit("0011").insert(4,0) //Error "The specified site is out of bound."
insert(const integer site) -> Qbit
Inserts a qubit set to 0 at the specified site.
Modifies the Qbit object in place by adding a qubit in the state to the left of the qubit at the specified site.
Parameters
- site: The site of the qubit being queried in the product state.
Example
Qbit("0011").insert(2) // Returns (1 + 0i)|00011>
Qbit("0011").insert(3) // Returns (1 + 0i)|00101>
// Qbit("0011").insert(4) //Error "The specified site is out of bound."