# @qiskit/algo

> Quantum Information algorithms for developers

Latest version **0.9.0** (published 2019-05-13) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @qiskit/algo
pnpm add @qiskit/algo
yarn add @qiskit/algo
bun add @qiskit/algo
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.9.0 |
| Published | 2019-05-13 |
| First published | 2019-05-13 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 4 |
| Unpacked size | 17 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 115 |
| Author | IBM RESEARCH |
| Maintainers | abdonrd, qiskit-team, jesusprubio, atilag, jelcaf |
| Keywords | quantum, experience, computing, information, algorithms, random, shor, factor, IBM |

## Links

- npm: https://www.npmjs.com/package/@qiskit/algo
- Repository: https://github.com/Qiskit/qiskit-js
- Issues: https://github.com/Qiskit/qiskit-js/issues
- npm.io page: https://npm.io/package/@qiskit/algo

## Dependencies (4)

- [@qiskit/utils](https://npm.io/package/@qiskit/utils.md) ^0.9.0
- [@qiskit/algo-js](https://npm.io/package/@qiskit/algo-js.md) ^0.9.0
- [@qiskit/algo-anu](https://npm.io/package/@qiskit/algo-anu.md) ^0.9.0
- [@qiskit/algo-ibm](https://npm.io/package/@qiskit/algo-ibm.md) ^0.9.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.9.0 (latest) — 2019-05-13

## README

# Qiskit for developers

:atom_symbol: Quantum Information Science Kit algorithms for developers. The idea is to hide all quantum mechanics complexity exposing only the upper layer.

Please visit the [main repository](https://github.com/Qiskit/qiskit-js) of the project to know about the rest of the tools.

## Install

:coffee: Install lastest [Node.js](https://nodejs.org/download) stable version (or LTS) and then:

```sh
npm i @qiskit/algo
```

## Use

:pencil: As you can see in the next section, we have to use it like in the rest of independent modules. The only difference is we need to pass the engine as any other option.

```js
const qiskit = require('@qiskit/algo');

// With the default engine and length.
qiskit.random().then(rand => console.log(`Random number(default): ${rand}`));

qiskit
  .random({
    engine: 'anu',
    length: 8,
  })
  .then(rand => console.log(`Random number: ${rand}`));
```

## API

:eyes: Full specification. Here are reflected the common options among the different engines, but some of them can receive (even need) extra ones, ie: an API key. Please check the [packages].

### `version`

The actual version of the library.

- `version` (string) - Version number.

### `async random(opts) -> rand | jobId`

Generate a true random number among 0 and 1.

- `opts` (object) - Optional parameters:
  - `engine` (string) - Where to run the operation. Please visit the [packages] to see the supported ones. The number of digits depends on the selected engine. (default: "js")
  - `length` (number) - Number of random hex characters to ask for to the engine. As you can see in the doc referenced before each engine has different limit, they will throw in it's overpassed. (default: 16)
  - `format` (string) - To ask for the result in a different format, supported ("hex").
  - `custom` (string/object) - Custom stuff (API key, inited connector instance, etc) needed for some backends (visit each specific doc).
- `rand` (number) - Generated random number in the desired format if the operation doesn't involves a background job.
- `jobId` (string) - Identifier for the generated background job (see next method).

### `async result(jobId, opts) -> result`

Get the result of a background job generated by an algorithm method. The engine is ommited because IBM Q is the unique which uses background jobs for now.

- `jobId` (string) - Job identifier got as initial response.
- `opts`(object) - Optional parameters:
  - `custom`
- `result` (?) - Depending on the used agorithm:
  - "random": (object) - With nex fields:
    - `status` (string) - To know if the job has finished correctly. Supported: "running", "completed", TODO.
    - `data` (number) - Generated random number. Only present if "status" is "completed".

### `async factor(number) -> prime`

Integer factorization in prime numbers using [Shor's algorithm](https://en.wikipedia.org/wiki/Shor%27s_algorithm). **Only supported in the local simulator for now**, so the engine is also ommited here for now. The result can be invalid, retry in this clase.

- `number` (number/string) - Number to factorize, an integer for now.
- `prime` (number) - Prime factor of the passed one.

[packages]: ./..

---
_Source: https://npm.io/package/@qiskit/algo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
