# ndarray-scratch

> Pooled memory for ndarrays

Latest version **1.2.0** (published 2015-07-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install ndarray-scratch
pnpm add ndarray-scratch
yarn add ndarray-scratch
bun add ndarray-scratch
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2015-07-27 |
| First published | 2013-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/ndarray-scratch) |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Mikola Lysenko |
| Maintainers | mikolalysenko, rreusser, planeshifter, jaspervdg, hughsk, substack |
| Keywords | ndarray, pool, memory, typedarray, scratch, malloc, free |

## Links

- npm: https://www.npmjs.com/package/ndarray-scratch
- Repository: https://github.com/mikolalysenko/ndarray-scratch
- Homepage: https://github.com/mikolalysenko/ndarray-scratch#readme
- Issues: https://github.com/mikolalysenko/ndarray-scratch/issues
- npm.io page: https://npm.io/package/ndarray-scratch

## Dependencies (3)

- [ndarray](https://npm.io/package/ndarray.md) ^1.0.14
- [ndarray-ops](https://npm.io/package/ndarray-ops.md) ^1.2.1
- [typedarray-pool](https://npm.io/package/typedarray-pool.md) ^1.0.2

## Recent versions

- 1.2.0 (latest) — 2015-07-27
- 1.1.1 — 2014-05-28
- 1.1.0 — 2014-04-30
- 1.0.0 — 2014-03-26
- 0.0.1 — 2013-07-02
- 0.0.0 — 2013-07-02

## README

ndarray-scratch
===============
A simple wrapper for typedarray-pool.  I got tired of manually constructing ndarrays from typedarrays, and so this module saves some keystrokes/sanity.

[![testling badge](https://ci.testling.com/scijs/ndarray-scratch.png)](https://ci.testling.com/scijs/ndarray-scratch)

[![build status](https://secure.travis-ci.org/scijs/ndarray-scratch.png)](http://travis-ci.org/scijs/ndarray-scratch)

# Example

```javascript
var pool = require("ndarray-scratch")

//Create a temporary typed array
var x = pool.malloc([100,100])

//Do stuff with x

//Release x
pool.free(x)
```

# Install

    npm install ndarray-scratch

# API

```javascript
var pool = require("ndarray-pool")
```

### `pool.malloc(shape[, dtype])`
Allocates a temporary ndarray

* `shape` is the shape of the array to allocate
* `dtype` is the dtype of the array to allocate (default `"double"`)

**Returns** a temporary ndarray

### `pool.zeros(shape[,dtype])`
Creates a scratch ndarray initialized to `0`

* `shape` is the shape of the resulting array
* `dtype` is the datatype of the array (default `"double"`)

**Returns** A temporary ndarray initialized to 0

### `pool.ones(shape[,dtype])`
Creates a scratch ndarray initialized to `1`

* `shape` is the shape of the resulting array
* `dtype` is the datatype of the array (default `"double"`)

**Returns** A temporary ndarray initialized to 1

### `pool.eye(shape[,dtype])`
Creates a scratch ndarray initialized to `1` if all indices equal, `0` otherwise.

* `shape` is the shape of the resulting array
* `dtype` is the datatype of the array (default `"double"`)

**Returns** A temporary ndarray initialized to the identity matrix

### `pool.free(array)`
Releases a temporary ndarray

* `array` is the ndarray to release.

### `pool.clone(array)`
Creates a copy of an ndarray with row-major order.

* `array` is an ndarray

**Returns** A temporary copy of `array`

# Credits
(c) 2013-2014 Mikola Lysenko. MIT License

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