diff --git a/docs/repl.txt b/docs/repl.txt index 60b3a63..50f540a 100644 --- a/docs/repl.txt +++ b/docs/repl.txt @@ -8,7 +8,7 @@ Indexing is relative to the first index. To introduce an offset, use a typed array view. - If `N <= 0`, the function returns `0.0`. + If `N <= 0`, the function returns `0`. Parameters ---------- @@ -29,7 +29,7 @@ Returns ------- - dot: float + out: float The dot product. Examples @@ -37,13 +37,13 @@ // Standard usage: > var x = new {{alias:@stdlib/array/float32}}( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] ); > var y = new {{alias:@stdlib/array/float32}}( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] ); - > var dot = {{alias}}( x.length, x, 1, y, 1 ) + > var out = {{alias}}( x.length, x, 1, y, 1 ) -5.0 // Strides: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - > dot = {{alias}}( 3, x, 2, y, -1 ) + > out = {{alias}}( 3, x, 2, y, -1 ) 9.0 // Using view offsets: @@ -51,7 +51,7 @@ > y = new {{alias:@stdlib/array/float32}}( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); > var x1 = new {{alias:@stdlib/array/float32}}( x.buffer, x.BYTES_PER_ELEMENT*1 ); > var y1 = new {{alias:@stdlib/array/float32}}( y.buffer, y.BYTES_PER_ELEMENT*3 ); - > dot = {{alias}}( 3, x1, -2, y1, 1 ) + > out = {{alias}}( 3, x1, -2, y1, 1 ) 128.0 @@ -87,7 +87,7 @@ Returns ------- - dot: float + out: float The dot product. Examples @@ -95,19 +95,19 @@ // Standard usage: > var x = new {{alias:@stdlib/array/float32}}( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] ); > var y = new {{alias:@stdlib/array/float32}}( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] ); - > var dot = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) + > var out = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) -5.0 // Strides: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - > dot = {{alias}}.ndarray( 3, x, 2, 0, y, 2, 0 ) + > out = {{alias}}.ndarray( 3, x, 2, 0, y, 2, 0 ) 9.0 // Using offset indices: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > y = new {{alias:@stdlib/array/float32}}( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - > dot = {{alias}}.ndarray( 3, x, -2, x.length-1, y, 1, 3 ) + > out = {{alias}}.ndarray( 3, x, -2, x.length-1, y, 1, 3 ) 128.0 See Also diff --git a/examples/c/example.c b/examples/c/example.c index 321efdc..dd07f29 100644 --- a/examples/c/example.c +++ b/examples/c/example.c @@ -21,8 +21,8 @@ int main( void ) { // Create strided arrays: - const float x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; - const float y[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; + const float x[] = { 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f }; + const float y[] = { 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f }; // Specify the number of indexed elements: const int N = 8; diff --git a/manifest.json b/manifest.json index 1d09355..c59c988 100644 --- a/manifest.json +++ b/manifest.json @@ -1,150 +1,171 @@ { - "options": { - "os": "linux", - "blas": "" - }, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "os": "linux", - "blas": "", - "src": [ - "./src/sdot.f", - "./src/sdotsub.f", - "./src/sdot_f.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/napi-export", - "@stdlib/napi-argv", - "@stdlib/napi-argv-int64", - "@stdlib/napi-argv-strided-float32array" - ] - }, - { - "os": "linux", - "blas": "openblas", - "src": [ - "./src/sdot_cblas.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lopenblas", - "-lpthread" - ], - "libpath": [], - "dependencies": [ - "@stdlib/napi-export", - "@stdlib/napi-argv", - "@stdlib/napi-argv-int64", - "@stdlib/napi-argv-strided-float32array" - ] - }, - { - "os": "mac", - "blas": "", - "src": [ - "./src/sdot.f", - "./src/sdotsub.f", - "./src/sdot_f.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/napi-export", - "@stdlib/napi-argv", - "@stdlib/napi-argv-int64", - "@stdlib/napi-argv-strided-float32array" - ] - }, - { - "os": "mac", - "blas": "apple_accelerate_framework", - "src": [ - "./src/sdot_cblas.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lblas" - ], - "libpath": [], - "dependencies": [ - "@stdlib/napi-export", - "@stdlib/napi-argv", - "@stdlib/napi-argv-int64", - "@stdlib/napi-argv-strided-float32array" - ] - }, - { - "os": "mac", - "blas": "openblas", - "src": [ - "./src/sdot_cblas.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lopenblas", - "-lpthread" - ], - "libpath": [], - "dependencies": [ - "@stdlib/napi-export", - "@stdlib/napi-argv", - "@stdlib/napi-argv-int64", - "@stdlib/napi-argv-strided-float32array" - ] - }, - { - "os": "win", - "blas": "", - "src": [ - "./src/sdot.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/napi-export", - "@stdlib/napi-argv", - "@stdlib/napi-argv-int64", - "@stdlib/napi-argv-strided-float32array" - ] - } - ] + "options": { + "os": "linux", + "blas": "", + "wasm": false + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/sdot.f", + "./src/sdotsub.f", + "./src/sdot_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi-export", + "@stdlib/napi-argv", + "@stdlib/napi-argv-int64", + "@stdlib/napi-argv-strided-float32array" + ] + }, + { + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/sdot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi-export", + "@stdlib/napi-argv", + "@stdlib/napi-argv-int64", + "@stdlib/napi-argv-strided-float32array" + ] + }, + { + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/sdot.f", + "./src/sdotsub.f", + "./src/sdot_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi-export", + "@stdlib/napi-argv", + "@stdlib/napi-argv-int64", + "@stdlib/napi-argv-strided-float32array" + ] + }, + { + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/sdot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi-export", + "@stdlib/napi-argv", + "@stdlib/napi-argv-int64", + "@stdlib/napi-argv-strided-float32array" + ] + }, + { + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/sdot_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi-export", + "@stdlib/napi-argv", + "@stdlib/napi-argv-int64", + "@stdlib/napi-argv-strided-float32array" + ] + }, + { + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/sdot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi-export", + "@stdlib/napi-argv", + "@stdlib/napi-argv-int64", + "@stdlib/napi-argv-strided-float32array" + ] + }, + { + "os": "", + "blas": "", + "wasm": true, + "src": [ + "./src/sdot.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [] + } + ] } diff --git a/src/addon.c b/src/addon.c index 9af4050..35291e3 100644 --- a/src/addon.c +++ b/src/addon.c @@ -41,7 +41,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 3 ); napi_value v; - napi_status status = napi_create_double( env, (double)c_sdot( N, (float *)X, strideX, (float *)Y, strideY ), &v ); + napi_status status = napi_create_double( env, (double)c_sdot( N, X, strideX, Y, strideY ), &v ); assert( status == napi_ok ); return v; diff --git a/src/sdot.c b/src/sdot.c index df34efb..e983ccf 100644 --- a/src/sdot.c +++ b/src/sdot.c @@ -17,10 +17,10 @@ */ /** - * Compute the dot product of two single-precision floating-point vectors. - * - * @see sdot - */ +* Compute the dot product of two single-precision floating-point vectors. +* +* @see sdot +*/ #include "stdlib/blas/base/sdot.h" /** @@ -31,7 +31,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns the dot product of X and Y +* @returns the dot product */ float c_sdot( const int N, const float *X, const int strideX, const float *Y, const int strideY ) { float dot; diff --git a/src/sdot.f b/src/sdot.f index cf2426e..bf37168 100644 --- a/src/sdot.f +++ b/src/sdot.f @@ -52,7 +52,7 @@ ! @param {integer} strideX - `sx` stride length ! @param {Array} sy - second array ! @param {integer} strideY - `sy` stride length -! @returns {real} the dot product of `sx` and `sy` +! @returns {real} the dot product !< real function sdot( N, sx, strideX, sy, strideY ) implicit none diff --git a/src/sdot_cblas.c b/src/sdot_cblas.c index 4c52cdd..9408010 100644 --- a/src/sdot_cblas.c +++ b/src/sdot_cblas.c @@ -27,7 +27,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns the dot product of X and Y +* @returns the dot product */ float c_sdot( const int N, const float *X, const int strideX, const float *Y, const int strideY ) { return cblas_sdot( N, X, strideX, Y, strideY ); diff --git a/src/sdot_f.c b/src/sdot_f.c index bcde964..34997c6 100644 --- a/src/sdot_f.c +++ b/src/sdot_f.c @@ -17,10 +17,10 @@ */ /** - * Compute the dot product of two single-precision floating-point vectors. - * - * @see sdot - */ +* Compute the dot product of two single-precision floating-point vectors. +* +* @see sdot +*/ #include "stdlib/blas/base/sdot.h" #include "stdlib/blas/base/sdot_fortran.h" @@ -34,7 +34,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns the dot product of X and Y +* @returns the dot product */ float c_sdot( const int N, const float *X, const int strideX, const float *Y, const int strideY ) { float dot; diff --git a/test/test.js b/test/test.js index 437b83e..ae11845 100644 --- a/test/test.js +++ b/test/test.js @@ -51,7 +51,7 @@ tape( 'if a native implementation is available, the main export is the native im '@stdlib/utils-try-require': tryRequire }); - t.strictEqual( sdot, mock, 'returns native implementation' ); + t.strictEqual( sdot, mock, 'returns expected value' ); t.end(); function tryRequire() { @@ -73,7 +73,7 @@ tape( 'if a native implementation is not available, the main export is a JavaScr '@stdlib/utils-try-require': tryRequire }); - t.strictEqual( sdot, main, 'returns JavaScript implementation' ); + t.strictEqual( sdot, main, 'returns expected value' ); t.end(); function tryRequire() { diff --git a/test/test.ndarray.js b/test/test.ndarray.js index 01d9965..b75f5d3 100644 --- a/test/test.ndarray.js +++ b/test/test.ndarray.js @@ -34,7 +34,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 7', function test( t ) { - t.strictEqual( sdot.length, 7, 'has expected arity' ); + t.strictEqual( sdot.length, 7, 'returns expected value' ); t.end(); }); diff --git a/test/test.ndarray.native.js b/test/test.ndarray.native.js index db02c9d..c5127d7 100644 --- a/test/test.ndarray.native.js +++ b/test/test.ndarray.native.js @@ -43,7 +43,7 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function has an arity of 7', opts, function test( t ) { - t.strictEqual( sdot.length, 7, 'has expected arity' ); + t.strictEqual( sdot.length, 7, 'returns expected value' ); t.end(); }); diff --git a/test/test.sdot.js b/test/test.sdot.js index 8900fd9..19706fd 100644 --- a/test/test.sdot.js +++ b/test/test.sdot.js @@ -34,7 +34,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 5', function test( t ) { - t.strictEqual( sdot.length, 5, 'has expected arity' ); + t.strictEqual( sdot.length, 5, 'returns expected value' ); t.end(); }); diff --git a/test/test.sdot.native.js b/test/test.sdot.native.js index bd26ace..9e8a255 100644 --- a/test/test.sdot.native.js +++ b/test/test.sdot.native.js @@ -43,7 +43,7 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function has an arity of 5', opts, function test( t ) { - t.strictEqual( sdot.length, 5, 'has expected arity' ); + t.strictEqual( sdot.length, 5, 'returns expected value' ); t.end(); });