Skip to main content

inserted

Method of Qbit.

Overloads

NameDescription
inserted(const integer site) -> QbitReturns a copy of the product state with a qubit in the 00 state inserted to the left of the qubit at the specified site.
inserted(const integer site, const bool value) -> QbitReturns a copy of the product state with a qubit in the specified state inserted to the left of the qubit at the specified site.
inserted(const integer site, const integer value) -> QbitReturns a copy of the product state with a qubit in the specified state inserted to the left of the qubit at the specified site.

inserted(const integer site) -> Qbit

Returns a copy of the product state with a qubit in the 00 state inserted 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").inserted(2) // Returns (1 + 0i)|00011>
Qbit("0011").inserted(3) // Returns (1 + 0i)|00101>
// Qbit("0011").inserted(4) //Error "The specified site is out of bound."

inserted(const integer site, const bool value) -> Qbit

Returns a copy of the product state with a qubit in the specified state inserted to the left of the qubit 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").inserted(2,0) // Returns (1 + 0i)|00011>
Qbit("0011").inserted(3,0) // Returns (1 + 0i)|00101>
Qbit("0011").inserted(3,1) // Returns (1 + 0i)|00111>
// Qbit("0011").inserted(4,1) //Error "The specified site is out of bound."

inserted(const integer site, const integer value) -> Qbit

Returns a copy of the product state with a qubit in the specified state inserted to the left of the qubit 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").inserted(2,0) // Returns (1 + 0i)|00011>
Qbit("0011").inserted(3,0) // Returns (1 + 0i)|00101>
Qbit("0011").inserted(3,1) // Returns (1 + 0i)|00111>
// Qbit("0011").inserted(4,1) //Error "The specified site is out of bound."