Calculate the dot product of two one-dimensional ndarrays.
The dot product (or scalar product) is defined as
var gdot = require( '@stdlib/blas/base/ndarray/gdot' );Computes the dot product of two one-dimensional ndarrays.
var ndarray = require( '@stdlib/ndarray/base/ctor' );
var xbuf = [ 4.0, 2.0, -3.0, 5.0, -1.0 ];
var x = new ndarray( 'generic', xbuf, [ 5 ], [ 1 ], 0, 'row-major' );
var ybuf = [ 2.0, 6.0, -1.0, -4.0, 8.0 ];
var y = new ndarray( 'generic', ybuf, [ 5 ], [ 1 ], 0, 'row-major' );
var z = gdot( [ x, y ] );
// returns -5.0The function has the following parameters:
- arrays: array-like object containing two one-dimensional input ndarrays.
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var ndarray = require( '@stdlib/ndarray/base/ctor' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var gdot = require( '@stdlib/blas/base/ndarray/gdot' );
var opts = {
'dtype': 'generic'
};
var xbuf = discreteUniform( 10, 0, 500, opts );
var x = new ndarray( opts.dtype, xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
console.log( ndarray2array( x ) );
var ybuf = discreteUniform( 10, 0, 255, opts );
var y = new ndarray( opts.dtype, ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' );
console.log( ndarray2array( y ) );
var out = gdot( [ x, y ] );
console.log( out );