Skip to Content
Qiskit Pocket Guide
book

Qiskit Pocket Guide

by James L. Weaver, Frank J. Harkins
June 2022
Intermediate to advanced content levelIntermediate to advanced
218 pages
4h 4m
English
O'Reilly Media, Inc.
Content preview from Qiskit Pocket Guide

Chapter 5. Quantum Information

The first three letters in the name Qiskit stand for quantum information science, which is the study of how quantum systems may be used to represent, process, and transmit information. The quantum_info module of Qiskit contains classes and functions that focus on those capabilities.

Using Quantum Information States

The qiskit.quantum_info module contains a few classes, shown in Table 5-1, that represent quantum information states.

Table 5-1. Classes that represent states in the qiskit.quantum⁠_​info module
Class name Description

Statevector

Represents a statevector

DensityMatrix

Represents a density matrix

StabilizerState

Simulation of stabilizer circuits

We’ll focus on the two most commonly used of these, namely the Statevector and DensityMatrix classes.

Using the Statevector Class

The Statevector class represents a quantum statevector and contains functionality for initializing and operating on the statevector. For example, as shown in the following code snippet, a Statevector may be instantiated by passing in a QuantumCircuit instance:

from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector

qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)

statevector = Statevector(qc)
print(statevector.data)

output:
  [0.70710678+0.j 0.+0.j 0.+0.j 0.7071+0.j]

Notice that instead of running the circuit on a quantum simulator to get the statevector (as shown in the code in “Using the AerSimulator to calculate and hold a statevector” ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Design of Everyday Things

The Design of Everyday Things

Donald A. Norman
The Kaggle Book

The Kaggle Book

Konrad Banachewicz, Luca Massaron
Storytelling with You

Storytelling with You

Cole Nussbaumer Knaflic
The Goal

The Goal

Eliyahu M. Goldratt, Jeff Cox

Publisher Resources

ISBN: 9781098112462Errata PageSupplemental Content