scijs/ndarray-gemm

General matrix multiplication for ndarrays
JavaScript
Latest commit 4e749a6 Jan 6, 2016 Rename to ndarray-gemm
 Failed to load latest commit information. bench Dec 21, 2013 example Dec 21, 2013 lib Dec 21, 2013 test Jul 10, 2015 .gitignore Nov 5, 2013 .npmignore Dec 21, 2013 .travis.yml Jul 10, 2015 LICENSE Nov 5, 2013 README.md Jan 7, 2016 gemm.js Dec 21, 2013 package.json Jan 7, 2016

ndarray-gemm

General matrix multiply for ndarrays. This is analogous to the BLAS level 3 routine xGEMM.

Note that while this implementation is correct, it is not yet very optimized. If someone wants to take over this project or suggest improvements, patches are welcome.

Example

```var zeros = require("zeros")
var ops = require("ndarray-ops")
var gemm = require("ndarray-gemm")

//Create 3 random matrices
var a = zeros([300, 400]) // a is 300 x 400
var b = zeros([400, 500]) // b is 400 x 500
var c = zeros([300, 500]) // c is 300 x 500

ops.random(a)
ops.random(b)
ops.random(c)

//Set c = a * b
gemm(c, a, b)```

Install

Install using npm:

``````npm install ndarray-gemm
``````

API

`require("ndarray-gemm")(c, a, b[, alpha, beta])`

Computes a generalized matrix multiplication. This sets:

`c = alpha * a * b + beta * c`
• `c` is a `[n,m]` shape ndarray
• `a` is a `[n,p]` shape ndarray
• `b` is a `[p,m]` shape ndarray
• `alpha` is a scalar weight which is applied to the product `a * b`
• `beta` is a scalar weight applied to `c` when added back in