ddot
Computes the dot product of
x
andy
.
The algebraic definition of the dot product between two vectors x
and y
is
Installation
$ npm install blas-ddot
Usage
var ddot = ;
ddot( N, x, strideX, offsetX, y, strideY, offsetY )
Computes the dot product of x
and y
.
var x = 1 2 3 4 5 ;var y = 6 7 8 9 10 ;var val = ;// returns 6+14+24+36+50 = 130
The function
accepts the following parameters:
- N: number of accessed elements.
- x: input
array
ortyped array
. - strideX: index increment for
x
. - offsetX: starting index for
x
. - y: input
array
ortyped array
. - strideY: index increment for
y
. - offsetY: starting index for
y
.
The N
, stride
, and offset
parameters determine how elements are accessed during runtime. For example, to compute the dot product between every other element in x
starting from its second element and the last N
elements in y
starting from its last element,
var x = 1 2 3 4 5 6 ;var y = 7 8 9 10 11 12 ;var N = Math;var val = ;// returns 24+44+60 = 128
If N <= 0
, the function
returns undefined
.
Notes
Examples
var ddot = ;var x;var y;var i;x = 10 ;y = 10 ;for i = 0; i < xlength; i++x i = Math;y i = Math;// Compute the dot product between `x` and the reverse of `y`:console;
To run the example code from the top-level application directory,
$ node ./examples/index.js
Tests
Unit
This repository uses tape for unit tests. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
Test Coverage
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ make view-cov
Browser Support
This repository uses Testling for browser testing. To run the tests in a (headless) local web browser, execute the following command in the top-level application directory:
$ make test-browsers
To view the tests in a local web browser,
$ make view-browser-tests
License
Copyright
Copyright © 2016. The Compute.io Authors.