Skip to main content

count

Method of Qbit.

Overloads​

NameDescription
count() -> integerReturns the sum of the qubit states (interpreted as integers) in the product state.
count(const List<integer> sites) -> integerReturns the sum of the qubit states on a subset of indices (interpreted as integers) in the product state.

count() -> integer​

Returns the sum of the qubit states (interpreted as integers) in the product state.

Example​

Qbit("10010001").count() // Returns 3

count(const List<integer> sites) -> integer​

Returns the sum of the qubit states on a subset of indices (interpreted as integers) in the product state.

Parameters​

  • sites: The subset of sites that are used to compute the sum.

Example​

Qbit("10010001").count([0,1,2,3]) // Returns 2