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

qics

v1.0.3

Published

A Javascript Idealistic Quantum Computer Simulation Library

Downloads

8

Readme

Qics - Quantum Idealistic Computer Simulator

GitHub issues GitHub license Travis npm Greenkeeper badge

Qics is an Idealistic, Quantum Computer Simulation Library. It works by holding a Quantum Register as a Matrix, and then multiplying that against various Gate Matrices. For more information about the working, see the src directory for the source code, or see examples/node.js or the Usage Section for information on the usage of the module.


Features

  • A 'Universally Complete', Quantum Circuit Based Simulator
  • Gate Expansion Function (To make a single qubit gate work on a register with multiple qubits)
  • Relatively Simple To Use
  • Inline Documentation with Docco

Usage

Currently the library is available using Node.js and NPM. To install the module, use the command:

npm install qics

(NOTE: Works with Node.js Versions >= 4)

If you want to use this in the browser, just add the qics.js or qics.min.js from the dist folder

Then you are able to use the module. When it's installed, Qics exposes two classes, qics.Register and qics.gates.

qics.Register is the main class, and is the basis of the simulator. It is used like any other class using the new keyword. Once initiated, there is a number of methods, see below or the Documentation.

qics.gates exposes all of the single qubit gates as 2D arrays. It also has some static methods, such as generateGate(). Again, see the documentation.

Example simulation:

// Import the module
const qics = require('qics');

// Create a new Quantum Register with 3 Qubits
const reg = new qics.Register(3);

// Apply some gates.
// Hadamard Gate
reg.applyGate('H', 1);
// CNOT Gate, with control as qubit 1, and the
// target as qubit 3
reg.applyGate('CNOT', 1, 3) ;

// Now measure the register. Should return either "000" or "101"
console.log(reg.measure());

You can also use your own gates, by inputing them as an Array or Math.Matrix object to the applyGate function.

// Manually Add A NOT Gate

const reg = new qics.Register(2);

reg.applyGate([
  [0, 1],
  [1, 0]
], 1);


// Now measure the register. Should return either "10"
console.log(reg.measure());

Documentation

This library is documented using Inline Prose Comments, and then generated using Docco. The documentation is just source code comments, but the source isn't too complex, and the functions are quite clear to use.

To read the docs, Checkout Here!

To deploy the docs to the github pages, run

git subtree push --prefix docs origin gh-pages

To build the docs, run npm run docs.


Build

First you need to clone the repo from github:

git clone git://github.com/adamisntdead/qics.git
cd qics

Then install the dependencies:

npm install

Then you can run the build script:

npm run build

This will build the module, and output to the lib folder. If you want to build for client side (i.e. in the browser), run npm run build:all and then it will output qics.js and qics.min.js to the dist folder.

Tests

To run the test for this module, after cloning and installing, run:

npm run test

And it will run all of the tests.