> ## Documentation Index
> Fetch the complete documentation index at: https://numpyts.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# numpy-ts

<Frame>
  <img className="block dark:hidden" src="https://mintcdn.com/none-4568e96a/TklIwzPdQ8Sv_cxD/images/hero-light.svg?fit=max&auto=format&n=TklIwzPdQ8Sv_cxD&q=85&s=a87369e10ad3e6312d8feb804407459e" alt="Hero Light" width="1200" height="600" data-path="images/hero-light.svg" />

  <img className="hidden dark:block" src="https://mintcdn.com/none-4568e96a/TklIwzPdQ8Sv_cxD/images/hero-dark.svg?fit=max&auto=format&n=TklIwzPdQ8Sv_cxD&q=85&s=52b22606b532e049b48888286db95235" alt="Hero Dark" width="1200" height="600" data-path="images/hero-dark.svg" />
</Frame>

# Complete NumPy for TypeScript

The most comprehensive NumPy implementation for TypeScript and JavaScript. Write numerical computing code with the same API you already know from Python -- fully type-safe, tree-shakeable, and validated against NumPy itself.

<Tabs>
  <Tab title="npm">
    ```bash theme={null}
    npm install numpy-ts
    ```
  </Tab>

  <Tab title="yarn">
    ```bash theme={null}
    yarn add numpy-ts
    ```
  </Tab>

  <Tab title="pnpm">
    ```bash theme={null}
    pnpm add numpy-ts
    ```
  </Tab>
</Tabs>

## Why numpy-ts?

<CardGroup cols={3}>
  <Card title="94% API Coverage" icon="chart-pie">
    476 of 507 NumPy functions implemented. From basic arithmetic to FFT, linear algebra, random distributions, and beyond.
  </Card>

  <Card title="Faster than NumPy" icon="gauge-high">
    1.13x faster than NumPy on average across 7,200 benchmarks. Faster in 12 of 18 categories, across all array sizes and dtypes.
  </Card>

  <Card title="Zero Dependencies" icon="box">
    No native modules, no third-party packages. Pure TypeScript + WASM that runs everywhere JavaScript runs.
  </Card>

  <Card title="NumPy-Validated" icon="flask-vial">
    Over 20,000 tests compare outputs directly against NumPy. If NumPy produces a result, numpy-ts matches it.
  </Card>

  <Card title="Type-Safe" icon="shield-check">
    Full TypeScript type definitions for every function, dtype, and array operation. Catch errors at compile time, not runtime.
  </Card>

  <Card title="Tree-Shakeable" icon="leaf">
    Import only what you need. Bundlers eliminate unused code automatically, keeping your production builds small.
  </Card>
</CardGroup>

## Quick Example

```typescript theme={null}
import * as np from 'numpy-ts';

// Create arrays -- just like NumPy
const a = np.array([[1, 2], [3, 4]]);
const b = np.zeros([2, 2]);

// Broadcasting works as expected
const c = a.add(1);        // [[2, 3], [4, 5]]
const d = a.multiply(2);   // [[2, 4], [6, 8]]

// Linear algebra
const inv = np.linalg.inv(a);
const det = np.linalg.det(a); // -2

// Dot products and matrix multiplication
const e = np.dot(a, np.array([[5, 6], [7, 8]]));  // [[19, 22], [43, 50]]

// Reshape, slice, and manipulate
const r = np.arange(12);
const grid = np.reshape(r, [3, 4]);
```

## Get Started

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/quickstart">
    Install numpy-ts and write your first array operations in under 5 minutes.
  </Card>

  <Card title="API Reference" icon="book" href="/api">
    Browse all 476 implemented functions with signatures, parameters, and examples.
  </Card>

  <Card title="Examples" icon="code" href="/examples">
    Real-world examples covering linear algebra, signal processing, statistics, and more.
  </Card>

  <Card title="Benchmarks" icon="gauge-high" href="/performance">
    Detailed performance comparisons against NumPy across 18 categories, multiple dtypes, and array sizes.
  </Card>
</CardGroup>

## Coming from NumPy?

numpy-ts mirrors the NumPy API as closely as possible. Most code translates directly:

<Tabs>
  <Tab title="Python (NumPy)">
    ```python theme={null}
    import numpy as np

    a = np.array([[1, 2], [3, 4]])
    b = np.linalg.inv(a)
    c = np.dot(a, b)          # identity matrix
    d = np.sum(a, axis=0)     # [4, 6]
    e = a[0, :]               # [1, 2]
    ```
  </Tab>

  <Tab title="TypeScript (numpy-ts)">
    ```typescript theme={null}
    import * as np from 'numpy-ts';

    const a = np.array([[1, 2], [3, 4]]);
    const b = np.linalg.inv(a);
    const c = np.dot(a, b);          // identity matrix
    const d = np.sum(a, { axis: 0 }); // [4, 6]
    const e = a.get([0, ':']);        // [1, 2]
    ```
  </Tab>
</Tabs>

See the [NumPy Migration Guide](/migration) for a complete translation reference.

***

<div align="center">
  numpy-ts is brought to you by

  <a href="https://www.cyborg.co/?utm_source=numpy-ts&utm_medium=docs-home">
    <img className="block dark:hidden" src="https://mintcdn.com/none-4568e96a/LOd94mpG5ESu-HdJ/images/sponsors/cyborg-light.svg?fit=max&auto=format&n=LOd94mpG5ESu-HdJ&q=85&s=112d39bfc43ad0b747f79528e623d57e" alt="Cyborg" width="200" data-path="images/sponsors/cyborg-light.svg" />

    <img className="hidden dark:block" src="https://mintcdn.com/none-4568e96a/LOd94mpG5ESu-HdJ/images/sponsors/cyborg-dark.svg?fit=max&auto=format&n=LOd94mpG5ESu-HdJ&q=85&s=1ebe3d2462799c90410943d845772c6a" alt="Cyborg" width="200" data-path="images/sponsors/cyborg-dark.svg" />
  </a>

  <span style={{ fontSize: "0.75rem", opacity: 0.5 }}>Built by [Nico Dupont](https://nico.codes)</span>
</div>
