npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nomyx/qcomplex

v0.1.0

Published

High-performance quantum computing library with WASM acceleration

Downloads

64

Readme

QComplex

A high-performance quantum computing library with WASM acceleration.

Features

  • High-performance complex number operations using WebAssembly
  • Quantum state vectors with automatic normalization
  • Common quantum gates (Hadamard, CNOT, etc.)
  • Bell state preparation and manipulation
  • Quantum measurements
  • Quantum teleportation simulation
  • TypeScript support with full type definitions

Installation

npm install @qcomplex/core

Usage

Basic Complex Numbers

import { complexWASM, init } from '@qcomplex/core';

// Initialize WASM module
await init();

// Create complex numbers
const z1 = complexWASM.createComplex(1, 2);  // 1 + 2i
const z2 = complexWASM.createComplex(3, -1); // 3 - i

// Basic operations
console.log(z1.abs());     // Magnitude
console.log(z1.phase());   // Phase angle

Quantum States

import { quantum, complexWASM, init } from '@qcomplex/core';

await init();

// Create a quantum state
const state = quantum.createState([
    complexWASM.createComplex(1, 0),  // |0⟩
    complexWASM.createComplex(0, 0)   // |1⟩
]);

// Get state properties
console.log(state.get_probability(0)); // Probability of measuring |0⟩
console.log(state.get_probability(1)); // Probability of measuring |1⟩

Quantum Gates

import { quantum, init } from '@qcomplex/core';

await init();

// Create a basis state |0⟩
const state = quantum.utils.create_basis_state(0, 2);

// Apply Hadamard gate to create superposition
const hadamard = quantum.gates.hadamard();
const superposition = hadamard.apply(state);

// Apply CNOT gate
const cnot = quantum.gates.cnot();
const entangled = cnot.apply(superposition);

Bell States

import { quantum, init } from '@qcomplex/core';

await init();

// Create Bell state |Φ+⟩ = (|00⟩ + |11⟩)/√2
const bellState = quantum.utils.create_bell_state(0);

// Measure the state
const result = quantum.utils.measure(bellState);
console.log(`Measured: ${result}`); // Will be either 0 or 3

API Reference

ComplexNumber

  • real(): Get real part
  • imag(): Get imaginary part
  • abs(): Get magnitude
  • phase(): Get phase angle
  • scale(factor): Scale by real number
  • add(other): Add complex numbers
  • multiply(other): Multiply complex numbers

QuantumState

  • get_amplitude(index): Get amplitude at index
  • get_probability(index): Get probability at index
  • dimension(): Get state space dimension
  • tensor_product(other): Tensor product with another state

QuantumGates

  • hadamard(): Create Hadamard gate
  • pauli_x(): Create Pauli-X (NOT) gate
  • pauli_y(): Create Pauli-Y gate
  • pauli_z(): Create Pauli-Z gate
  • cnot(): Create CNOT gate
  • phase(theta): Create phase shift gate

QuantumUtils

  • create_basis_state(n, dimension): Create basis state |n⟩
  • create_bell_state(index): Create Bell state
  • measure(state): Perform measurement

Development

# Install dependencies
npm install

# Build WASM and TypeScript
npm run build

# Run tests
npm test

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.