Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scijs/ndarray
📈 Multidimensional arrays for JavaScript
https://github.com/scijs/ndarray
Last synced: 5 days ago
JSON representation
📈 Multidimensional arrays for JavaScript
- Host: GitHub
- URL: https://github.com/scijs/ndarray
- Owner: scijs
- License: mit
- Created: 2013-02-25T17:27:21.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2022-01-29T18:00:01.000Z (almost 3 years ago)
- Last Synced: 2024-10-29T17:39:52.896Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 98.6 KB
- Stars: 1,211
- Watchers: 39
- Forks: 61
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-frontend - ndarray - Multidimensional arrays. ![](https://img.shields.io/github/stars/scijs/ndarray.svg?style=social&label=Star) (Repository / Math)
- awesome-regl - ndarray - dimensional array data structure (Tools)
- awesome-nodejs-cn - ndarray - 多维数组 (包 / æ•°å¦)
- awesome-nodejs - ndarray - Multidimensional arrays. ![](https://img.shields.io/github/stars/scijs/ndarray.svg?style=social&label=Star) (Repository / Math)
- awesome-nodejs-cn - ndarray - **star:1211** 多维数组 (包 / æ•°å¦)
- awesome-nodejs - ndarray - Multidimensional arrays. (Packages / Math)
- awesome-nodejs - ndarray - Multidimensional arrays for JavaScript - ★ 805 (Math)
- awesome-node - ndarray - Multidimensional arrays. (Packages / Math)
- awesome-nodejs-cn - ndarray - 多维数组. (目录 / æ•°å¦)
README
ndarray
=======
Modular multidimensional arrays for JavaScript.[![browser support](https://ci.testling.com/mikolalysenko/ndarray.png)
](https://ci.testling.com/mikolalysenko/ndarray)[![build status](https://secure.travis-ci.org/scijs/ndarray.png)](http://travis-ci.org/scijs/ndarray)
[![stable](https://rawgithub.com/hughsk/stability-badges/master/dist/frozen.svg)](http://github.com/hughsk/stability-badges)
##### Browse a number of ndarray-compatible modules in the [scijs documentation](http://scijs.net/packages)
##### Coming from MATLAB or numpy? See: [scijs/ndarray for MATLAB users](https://github.com/scijs/scijs-ndarray-for-matlab-users)
##### [Big list of ndarray modules](https://github.com/scijs/ndarray/wiki/ndarray-module-list#core-module)Introduction
============
`ndarrays` provide higher dimensional views of 1D arrays. For example, here is how you can turn a length 4 typed array into an nd-array:```javascript
var mat = ndarray(new Float64Array([1, 0, 0, 1]), [2,2])//Now:
//
// mat = 1 0
// 0 1
//
```Once you have an nd-array you can access elements using `.set` and `.get`. For example, here is an implementation of [Conway's game of life](http://en.wikipedia.org/wiki/Conway's_Game_of_Life) using ndarrays:
```javascript
function stepLife(next_state, cur_state) {//Get array shape
var nx = cur_state.shape[0],
ny = cur_state.shape[1]//Loop over all cells
for(var i=1; i