-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5037139
Showing
500 changed files
with
24,734 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: 2 | ||
plugins: | ||
duplication: | ||
enabled: false | ||
tslint: | ||
config: tsconfig.json | ||
enabled: true | ||
exclude_patterns: | ||
- 'gulpfile.js' | ||
- 'src/bench.ts' | ||
- 'src/*.spec.ts' | ||
- 'src/*.bench.ts' | ||
- 'dist/' | ||
- 'examples/' | ||
- 'benchmarks/' | ||
- 'docs/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- "*" | ||
- "!master" | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
test: | ||
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
node_version: [16] | ||
os: [ubuntu-latest, macOS-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
|
||
- name: Setup C++ environment on linux | ||
uses: kurocha/setup-cpp@v1 | ||
if: runner.os == 'Linux' | ||
|
||
- name: Install dependencies on linux | ||
run: sudo apt-get install -yq libblas-dev liblapack-dev liblapacke-dev | ||
if: runner.os == 'Linux' | ||
|
||
- name: Install dependencies on mac | ||
run: brew install lapack | ||
if: runner.os == 'macOS' | ||
|
||
- name: Install package dependencies | ||
run: npm ci | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- name: Test | ||
run: npm test | ||
|
||
- name: Publish coverage to CodeClimate | ||
uses: paambaati/codeclimate-action@v3.0.0 | ||
env: | ||
CC_TEST_REPORTER_ID: 7bc2ff765ac0619975d32fe57959db6374d14a96780a1438ec68ea14036748e1 | ||
with: | ||
coverageLocations: ${{github.workspace}}/coverage/lcov.info:lcov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- run: | | ||
git config --global user.name 'Mateo Gianolio' | ||
git config --global user.email 'mateogianolio@users.noreply.github.com' | ||
- name: Use Node.js 16 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
cache: 'npm' | ||
|
||
- name: Setup C++ environment on linux | ||
uses: kurocha/setup-cpp@v1 | ||
|
||
- name: Install dependencies on linux | ||
run: sudo apt-get install -yq libblas-dev liblapack-dev liblapacke-dev | ||
|
||
- name: Install sphinx-js | ||
run: pip install sphinx-js pydata-sphinx-theme | ||
|
||
- name: Install package dependencies | ||
run: npm ci | ||
|
||
- name: Build dist/ | ||
run: npm run build | ||
|
||
- name: Test | ||
run: npm test | ||
|
||
- name: Publish coverage to CodeClimate | ||
uses: paambaati/codeclimate-action@v3.0.0 | ||
env: | ||
CC_TEST_REPORTER_ID: 7bc2ff765ac0619975d32fe57959db6374d14a96780a1438ec68ea14036748e1 | ||
with: | ||
coverageLocations: ${{github.workspace}}/coverage/lcov.info:lcov | ||
|
||
- name: Build and deploy docs | ||
run: | | ||
npm run docs | ||
./docs/deploy.sh | ||
- name: Publish dist | ||
run: | | ||
git add dist | ||
git commit --amend --no-edit | ||
git push --force origin master | ||
- name: Publish package to npm | ||
id: publish | ||
uses: JS-DevTools/npm-publish@v1 | ||
with: | ||
token: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Publish git tag | ||
if: steps.publish.outputs.type != 'none' | ||
run: | | ||
git tag ${{ steps.publish.outputs.version }} | ||
git push origin ${{ steps.publish.outputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.nyc_output | ||
node_modules | ||
coverage | ||
.DS_Store | ||
built | ||
benchmarks | ||
docs/code | ||
docs/_build/**/* | ||
!docs/_build/CNAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Bart van Andel <bavanandel@gmail.com> <bvanandel@cyclomedia.com> | ||
Daniel Wang <pvnr0082t@gmail.com> | ||
James Vickers <james@metabench.com> | ||
Jarrad Whitaker <akdor1154@gmail.com> | ||
Mateo Gianolio <gianoliomateo@gmail.com> | ||
Michael Schock <mschock@ocf.berkeley.edu> | ||
Phillip Wang <lucidrains@gmail.com> | ||
Waylon Flinn <waylonflinn@gmail.com> | ||
Xuefeng Zhu <xzhu15@illinois.edu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.github | ||
benchmarks | ||
coverage | ||
dist | ||
docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"semi": true, | ||
"tabWidth": 2, | ||
"printWidth": 100, | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"jsxBracketSameLine": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"esbonio.sphinx.confDir": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# The MIT License (MIT) | ||
|
||
_Copyright (c) 2021 Mateo Gianolio_ | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
<p align="center"> | ||
<img src="https://github.com/mateogianolio/vectorious/raw/master/logo.gif" alt="Vectorious Logo" /> | ||
</p> | ||
|
||
<p align="center"> | ||
A linear algebra library, written in TypeScript and accelerated with C++ bindings to BLAS and LAPACK. | ||
</p> | ||
|
||
<p align="center"> | ||
<img src="https://img.shields.io/npm/v/vectorious.svg" /> <img src="https://img.shields.io/npm/dm/vectorious" /> <img src="https://img.shields.io/github/actions/workflow/status/mateogianolio/vectorious/release.yml?branch=master" /> <img src="https://img.shields.io/codeclimate/maintainability/mateogianolio/vectorious" /> <img src="https://img.shields.io/codeclimate/coverage/mateogianolio/vectorious" /> | ||
</p> | ||
|
||
### Installation | ||
|
||
Follow the installation instructions in [nlapack](https://github.com/nperf/nlapack) and [nblas](https://github.com/nperf/nblas) to get maximum performance. | ||
|
||
```bash | ||
# with C++ bindings | ||
$ npm install vectorious | ||
|
||
# or, if you don't want C++ bindings | ||
$ npm install vectorious --no-optional | ||
``` | ||
|
||
There are three output bundles exposed in this package. | ||
|
||
#### CommonJS | ||
|
||
A node.js bundle, can be found in `dist/index.js` and imported with the `require()` syntax: | ||
|
||
```typescript | ||
const v = require('vectorious'); | ||
``` | ||
|
||
#### Browser | ||
|
||
A browser bundle, can be found in `dist/index.browser.js` and imported with the `<script>` tag: | ||
|
||
```html | ||
<script src="dist/index.browser.js" /> | ||
``` | ||
It exposes a global variable named `v` in the `window` object and can be accessed like this: | ||
```html | ||
<script> | ||
const x = v.array([1, 2, 3]); | ||
</script> | ||
``` | ||
|
||
#### ES module | ||
|
||
Added in version 6.1.0, vectorious exposes an ES module bundle at `dist/index.esm.js` which can be imported using the `import` syntax: | ||
|
||
```typescript | ||
import { array } from 'vectorious'; | ||
|
||
const x = array([1, 2, 3]); | ||
``` | ||
|
||
### Usage | ||
|
||
Unless stated otherwise, all operations are in-place, meaning that the result of the operation overwrites data in the current (or in the static case leftmost) array. To avoid this, an explicit `copy` call is needed before the operation (`copy(x)` or `x.copy()`). | ||
|
||
```javascript | ||
import { array, random, range } from 'vectorious'; | ||
|
||
// Create a random 2x2 matrix | ||
const x = random(2, 2); | ||
/* | ||
array([ | ||
[ | ||
0.26472008228302, | ||
0.4102575480937958 | ||
], | ||
[ | ||
0.4068726599216461, | ||
0.4589384198188782 | ||
] | ||
], dtype=float64) | ||
*/ | ||
|
||
// Create a one-dimensional vector with values from | ||
// 0 through 8 and reshape it into a 3x3 matrix | ||
const y = range(0, 9).reshape(3, 3); | ||
/* | ||
array([ | ||
[ 0, 1, 2 ], | ||
[ 3, 4, 5 ], | ||
[ 6, 7, 8 ] | ||
], dtype=float64) | ||
*/ | ||
|
||
// Add the second row of x to the first row of x | ||
y.slice(0, 1).add(y.slice(1, 2)); | ||
/* | ||
array([ | ||
[ 3, 5, 7 ], | ||
[ 3, 4, 5 ], | ||
[ 6, 7, 8 ] | ||
], dtype=float64) | ||
*/ | ||
|
||
// Swap the first and second rows of x | ||
y.swap(0, 1); | ||
/* | ||
array([ | ||
[ 3, 4, 5 ], | ||
[ 3, 5, 7 ], | ||
[ 6, 7, 8 ] | ||
], dtype=float64) | ||
*/ | ||
|
||
// Create a 2x2x1 tensor | ||
const z = array([ | ||
[[1], [2]], | ||
[[3], [4]], | ||
]); | ||
/* | ||
array([ | ||
[ [ 1 ], [ 2 ] ], | ||
[ [ 3 ], [ 4 ] ] | ||
], dtype=float64) | ||
*/ | ||
``` | ||
|
||
### Documentation | ||
|
||
- [**API Documentation**](https://docs.vectorious.org/vectorious/6.1.0/) | ||
|
||
### Examples | ||
|
||
**Basic** | ||
|
||
- [**Solving linear systems of equations**](https://github.com/mateogianolio/vectorious/tree/master/examples/solve.ts) | ||
- [**Using low-level BLAS routines**](https://github.com/mateogianolio/vectorious/tree/master/examples/blas.ts) | ||
|
||
**Machine learning** | ||
|
||
- [**Neural network**](https://github.com/mateogianolio/vectorious/tree/master/examples/neural-network.ts) (by [@lucidrains](https://github.com/lucidrains)) | ||
- [**Logistic regression**](https://github.com/mateogianolio/vectorious/tree/master/examples/logistic-regression.ts) | ||
|
||
### Testing | ||
|
||
All functions are accompanied with a `.spec.ts` file. | ||
|
||
The Jest testing framework is used for testing and the whole test suite can be run using a single command: | ||
|
||
```sh | ||
$ npm test | ||
``` | ||
|
||
### Benchmarks | ||
|
||
All functions are accompanied with a `.bench.ts` file. | ||
|
||
Run all benchmarks with: | ||
|
||
```bash | ||
$ npm run benchmark | ||
``` | ||
|
||
Or for a single function with: | ||
|
||
``` | ||
$ npx ts-node src/core/abs.bench.ts | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { TypedArray, DType } from './types'; | ||
export declare const NoTrans: any; | ||
export declare const Trans: any; | ||
export declare function axpy(dtype: DType, n: number, alpha: number, x: TypedArray, inc_x: number, y: TypedArray, inc_y: number): any; | ||
export declare function dot(dtype: DType, n: number, x: TypedArray, inc_x: number, y: TypedArray, inc_y: number): any; | ||
export declare function iamax(dtype: DType, n: number, x: TypedArray, inc_x: number): any; | ||
export declare function gemm(dtype: DType, transx: number, transy: number, m: number, n: number, k: number, alpha: number, x: TypedArray, ldx: number, y: TypedArray, ldy: number, beta: number, z: TypedArray, ldz: number): any; | ||
export declare function nrm2(dtype: DType, n: number, x: TypedArray, inc_x: number): any; | ||
export declare function scal(dtype: DType, n: number, alpha: number, x: TypedArray, inc_x: number): any; |
Oops, something went wrong.