@stdlib/blas-base-ndarray-ddot
v0.1.1
Published
Compute the dot product of two one-dimensional double-precision floating-point ndarrays.
Readme
ddot
Calculate the dot product of two one-dimensional double-precision floating-point ndarrays.
The dot product (or scalar product) is defined as
Installation
npm install @stdlib/blas-base-ndarray-ddotUsage
var ddot = require( '@stdlib/blas-base-ndarray-ddot' );ddot( arrays )
Computes the dot product of two one-dimensional double-precision floating-point ndarrays.
var Float64Array = require( '@stdlib/array-float64' );
var ndarray = require( '@stdlib/ndarray-base-ctor' );
var xbuf = new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] );
var x = new ndarray( 'float64', xbuf, [ 5 ], [ 1 ], 0, 'row-major' );
var ybuf = new Float64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] );
var y = new ndarray( 'float64', ybuf, [ 5 ], [ 1 ], 0, 'row-major' );
var z = ddot( [ x, y ] );
// returns -5.0The function has the following parameters:
- arrays: array-like object containing two one-dimensional input ndarrays.
Examples
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
var ndarray = require( '@stdlib/ndarray-base-ctor' );
var ndarray2array = require( '@stdlib/ndarray-to-array' );
var ddot = require( '@stdlib/blas-base-ndarray-ddot' );
var opts = {
'dtype': 'float64'
};
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 = ddot( [ x, y ] );
console.log( out );Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
