Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dy/multiscale-array
Multiscale representation of an array
https://github.com/dy/multiscale-array
array data-structures
Last synced: 9 days ago
JSON representation
Multiscale representation of an array
- Host: GitHub
- URL: https://github.com/dy/multiscale-array
- Owner: dy
- Created: 2016-09-27T20:38:47.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-05T06:56:38.000Z (about 8 years ago)
- Last Synced: 2024-12-31T15:15:20.313Z (15 days ago)
- Topics: array, data-structures
- Language: JavaScript
- Size: 9.77 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# multiscale-array [![unstable](http://badges.github.io/stability-badges/dist/unstable.svg)](http://github.com/badges/stability-badges)
Create multiple scales representation for an array (see [scale-space](https://en.wikipedia.org/wiki/Scale_space) for the concept). It is simplest form of convolution with resampling, where the upper level is perfectly 2 times less than the lower level, with each value made up of two values from the previous level. Similar to mipmaps, but 1d.
[![npm install multiscale-array](https://nodei.co/npm/multiscale-array.png?mini=true)](https://npmjs.org/package/multiscale-array/)
```js
const multiscale = require('multiscale-array')let data = Array(1e7)
let scales = multiscale(data, {
//max group of samples
maxScale: 65536,//how to form upper level from two samples of lower level
reduce: (left, right, i, level) => .5*left + .5*right
})//recalculate scales for the data range, this is O(2N)
scales.update(from?, to?)//replace old data with the new data and recalc scales for it
scales.update(newData, from?, to?)//get data for the scale 2⁴
let scaleData = scales[4];//subset scales, i.e. slice all scales, but mutable (!)
scales.subset(from, to)
```