nblas
v2.1.13
Published
C++ bindings for all single- and double-precision CBLAS (Basic Linear Algebra Subprograms) routines.
Downloads
1,470
Readme
nBLAS
Node >=6.9
C++ bindings for all single- and double-precision CBLAS (Basic Linear Algebra Subprograms) routines.
$ npm install nblas
$ npm test
BLAS Level 1 Routines and Functions
- [x]
?asum (x)
- [x]
?axpy (x, y, [alpha = 1.0])
- [x]
?copy (x, y)
- [x]
?dot (x, y)
- [x]
?nrm2 (x)
- [x]
?rot (x, y, c, s)
- [x]
?rotg (x, y, c, s)
- [x]
?rotm (x, y, param)
- [x]
?rotmg (d1, d2, x1, y1, param)
- [x]
?scal (x, alpha)
- [x]
?swap (x, y)
- [x]
i?amax (x)
- [x]
- [x]
?gbmv (a, x, y, [kl = 0], [ku = 0], [alpha = 1.0], [beta = 0], [trans = nblas.NoTrans])
- [x]
?gemv (a, x, y, [alpha = 1.0], [beta = 0], [trans = nblas.NoTrans])
- [x]
?ger (a, x, y, [alpha = 1.0])
- [x]
?sbmv (a, x, y, [uplo = nblas.Upper], [alpha = 1.0], [beta = 0])
- [x]
?spmv (ap, x, y, [uplo = nblas.Upper], [alpha = 1.0], [beta = 0])
- [x]
?spr (ap, x, [uplo = nblas.Upper], [alpha = 1.0])
- [x]
?spr2 (ap, x, y, [uplo = nblas.Upper], [alpha = 1.0])
- [x]
?symv (a, x, y, [uplo = nblas.Upper], [alpha = 1.0], [beta = 0])
- [x]
?syr (a, x, [uplo = nblas.Upper], [alpha = 1.0])
- [x]
?syr2 (a, x, y, [uplo = nblas.Upper], [alpha = 1.0], [beta = 0])
- [x]
?tbmv (a, x, y, [uplo = nblas.Upper], [trans = nblas.NoTrans], [diag = nblas.NonUnit])
- [x]
?tbsv (a, x, [uplo = nblas.Upper], [diag = nblas.NonUnit])
- [x]
?tpmv (ap, x, [uplo = nblas.Upper], [trans = nblas.NoTrans], [diag = nblas.NonUnit])
- [x]
?tpsv (ap, x, [uplo = nblas.Upper], [trans = nblas.NoTrans], [diag = nblas.NonUnit])
- [x]
?trmv (a, x, [uplo = nblas.Upper], [trans = nblas.NoTrans], [diag = nblas.NonUnit])
- [x]
?trsv (a, x, [uplo = nblas.Upper], [trans = nblas.NoTrans], [diag = nblas.NonUnit])
- [x]
- [x]
?gemm (a, b, c, m, n, k, [transa = 111], [transb = 111], [alpha = 1.0], [beta = 0])
- [x]
?symm (a, b, c, m, n, [side = nblas.Left], [uplo = nblas.Upper], [alpha = 1.0], [beta = 0])
- [x]
?syrk (a, c, n, k, [uplo = nblas.Upper], [trans = nblas.NoTrans], [alpha = 1.0], [beta = 0])
- [x]
?syr2k (a, b, c, n, k, [uplo = nblas.Upper], [trans = nblas.NoTrans], [alpha = 1.0], [beta = 0])
- [x]
?trmm (a, b, m, n, [side = nblas.Left], [uplo = nblas.Upper], [transa = 111], [diag = nblas.NonUnit], [alpha = 1.0])
- [x]
?trsm (a, b, m, n, [diag = nblas.NonUnit], [uplo = nblas.Upper], [transa = 111], [diag = nblas.NonUnit], [alpha = 1.0])
- [x]
Matrix layout enums
- Matrix transpose (
trans
)nblas.NoTrans (default)
nblas.Trans
nblas.ConjTrans
- Upper/lower matrix (
uplo
)nblas.Upper (default)
nblas.Lower
- Matrix diagonal (
diag
)nblas.NonUnit (default)
nblas.Unit
- Matrix side (
side
)nblas.Left (default)
nblas.Right
- Matrix transpose (
Works out of the box with OSX since CBLAS is included in the standard Accelerate framework. You might have to download and build LAPACK from source on other operating systems (LINUX: sudo apt-get libblas-dev
).
import { dot, ddot, sdot, dznrm2 } from './src';
const f64a = new Float64Array([1, 2, 3]);
const f64b = new Float64Array([4, 5, 6]);
console.log(dot(f64a, f64b));
// 32
console.log(ddot(3, f64a, 1, f64b, 1));
// 32
const f32a = new Float32Array([1, 2, 3]);
const f32b = new Float32Array([4, 5, 6]);
console.log(dot(f32a, f32b));
// 32
console.log(sdot(3, f32a, 1, f32b, 1));
// 32
// complex arrays are packed like this: [Re, Im, Re, Im, ...]
// this is equivalent to [1 + 2i, 3 + 4i]
const c16 = new Float64Array([1, 2, 3, 4]);
// complex l2 norm
console.log(dznrm2(2, c16, 1));
// sqrt(1^2 + 2^2 + 3^2 + 4^2) ~ 5.477
Double precision functions expect Float64Array
vectors, single precision functions expect Float32Array
vectors.