WaveletMatrix implementation for JS/JSX/AMD/CommonJS
npm install wavelet-matrix.jsxwavelet-matrix.jsx
===========================================
Synopsis
---------------
WaveletMatrix implementation for JS/JSX/AMD/CommonJS
Motivation
---------------
This code is a part of Oktavia. This is a heart of FM-index search engine.
WaveletMatrix provides O(1) algorithm for the following operation:
* Rank: count the number of specified character in specified range.
Current implementation doesn't provide Select operation.
This module provides Uint32Array version and number[] version.
* http://www.dcc.uchile.cl/~gnavarro/ps/spire12.4.pdf
Code Example
---------------
``js
import "wavelet-matrix.jsx";
class _Main {
static function main(argv : string[]) : void {
// Uint32Array version
var wm = new Uint32WaveletMatrix();
wm.build("abracadabra mississippi");
wm.rank(10, "a".charCodeAt(0));
// number[] version
var wm2 = new ArrayWaveletMatrix();
wm2.build("abracadabra mississippi");
wm2.rank(10, "a".charCodeAt(0));
}
}
`
`js`
var Uint32WaveletMatrix = require('wavelet-matrix.common.js').Uint32WaveletMatrix;
var ArrayWaveletMatrix = require('wavelet-matrix.common.js').ArrayWaveletMatrix;
`js
// use wavelet-matrix.amd.js
define(['wavelet-matrix.js'], function (waveletmatrix) {
var wm = new WaveletMatrix.Uint32WaveletMatrix();
var wm2 = new WaveletMatrix.ArrayWaveletMatrix();
});
`
`html`
`html`
Installation
---------------
`sh`
$ npm install wavelet-matrix.jsx
API Reference
------------------
Constructor.
Constructor.
Return current bit-size setting. Default value is 16.
Set max character code stored in this matrix. Default value is 65535 (UCS2 character code limit).
If you use only latin-1, set 256 and save memory.
Clear matrix.
Build wavelet matrix. You should call this before using rank() or rankLessThan().
Return input string size.
Return the number of specified character in the source string.
Return the x-th character.
Count the number of specified character before the specified position.
Count the number of the character that is smaller than specified character before the specified position.
Export WaveletMatrix.
Import WaveletMatrix.
Development
-------------
Don't be afraid JSX! If you have an experience of JavaScript, you can learn JSX
quickly.
* Static type system and unified class syntax.
* All variables and methods belong to class.
* JSX includes optimizer. You don't have to write tricky unreadalbe code for speed.
* You can use almost all JavaScript API as you know. Some functions become static class functions. See reference.
To create development environment, call following command:
`sh`
$ npm install
* Repository: git://github.com/shibukawa/wavelet-matrix.jsx.git
* Issues: https://github.com/shibukawa/wavelet-matrix.jsx/issues
`sh`
$ grunt test
`sh`
$ grunt build
`sh`
$ grunt doc
Author
---------
* shibukawa / yoshiki@shibu.jp
License
------------
MIT
Complete license is written in LICENSE.md`.