New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

qclib

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qclib

A quantum computing library using qiskit

  • 0.1.12
  • PyPI
  • Socket score

Maintainers
2

Quantum computing library (qclib)

Qclib is a quantum computing library implemented using qiskit.

The focus of qclib is on preparing quantum states, but it is not limited to that.

Instalation

The easiest way of installing qclib is by using pip:

pip install qclib

Initializing your first quantum state with qclib

Now that qclib is installed, you can start building quantum circuits to prepare quantum states. Here is a basic example:

$ python
import numpy as np
from qiskit import transpile
from qiskit_aer import AerSimulator
from qclib.state_preparation import LowRankInitialize

# Generate 3-qubit random input state vector
n = 3
rnd = np.random.RandomState(42)
input_vector = rnd.rand(2 ** n) + rnd.rand(2 ** n) * 1j
input_vector = input_vector / np.linalg.norm(input_vector)

# Build a quantum circuit to initialize the input vector
circuit = LowRankInitialize(input_vector).definition

# Construct an ideal simulator
backend = AerSimulator()

# Tests whether the produced state vector is equal to the input vector.
t_circuit = transpile(circuit, backend)
t_circuit.save_statevector()
state_vector = backend.run(t_circuit).result().get_statevector()
print('Equal:', np.allclose(state_vector, input_vector))
# Equal: True

Comparing algorithms for quantum state preparation

The following table shows the depth, number of qubits, and CNOTs of circuits produced by different state preparation methods for the same random 15-qubit state.

methodlibqubitscnotsdepth
low-rankqclib153099853643
svdqclib153881471580
ucgqclib153275265505
isometryqiskit153275265505
multiplexorqiskit1565504131025
bdspqclib1151723201603
dcspqclib32767262016899

You can reproduce the results here.

Authors

The first version of qclib was developed at Centro de Informática - UFPE. Qclib is an active project, and other people have contributed.

If you are doing research using qclib, please cite our project. We use a CITATION.cff file, so you can easily copy the citation information from the repository landing page.

License

qclib is free and open source, released under the Apache License, Version 2.0.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc