From 25d23a53194949dc53ab74e39175e3db34aea7ec Mon Sep 17 00:00:00 2001 From: kaustubh Date: Mon, 25 May 2026 13:57:50 +0530 Subject: [PATCH] feat: add blas/base/ndarray/scasum --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../blas/base/ndarray/scasum/README.md | 126 ++++++++++++ .../ndarray/scasum/benchmark/benchmark.js | 104 ++++++++++ .../scasum/docs/img/equation_l1norm.svg | 44 +++++ .../blas/base/ndarray/scasum/docs/repl.txt | 26 +++ .../base/ndarray/scasum/docs/types/index.d.ts | 50 +++++ .../base/ndarray/scasum/docs/types/test.ts | 57 ++++++ .../base/ndarray/scasum/examples/index.js | 34 ++++ .../blas/base/ndarray/scasum/lib/index.js | 43 +++++ .../blas/base/ndarray/scasum/lib/main.js | 60 ++++++ .../blas/base/ndarray/scasum/package.json | 73 +++++++ .../blas/base/ndarray/scasum/test/test.js | 180 ++++++++++++++++++ 11 files changed, 797 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/scasum/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/scasum/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/scasum/docs/img/equation_l1norm.svg create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/scasum/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/scasum/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/scasum/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/scasum/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/scasum/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/scasum/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/scasum/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/ndarray/scasum/test/test.js diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/scasum/README.md b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/README.md new file mode 100644 index 000000000000..8b6a7500d6a8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/README.md @@ -0,0 +1,126 @@ + + +# scasum + +> Calculate the sum of absolute values for all elements in a one-dimensional single-precision complex floating-point ndarray. + +
+ +The [_L1_ norm][l1norm] is defined as + + + +```math +\|\mathbf{x}\|_1 = \sum_{i=0}^{n-1} \vert x_i \vert +``` + + + + + +
+ + + +
+ +## Usage + +```javascript +var scasum = require( '@stdlib/blas/base/ndarray/scasum' ); +``` + +#### scasum( arrays ) + +Computes the sum of absolute values for all elements in a one-dimensional single-precision complex floating-point ndarray. + +```javascript +var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' ); + +var x = new Complex64Vector( [ 1.0, -2.0, 3.0, -4.0 ] ); + +var y = scasum( [ x ] ); +// returns 10.0 +``` + +The function has the following parameters: + +- **arrays**: array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + +
+ + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var scasum = require( '@stdlib/blas/base/ndarray/scasum' ); + +var opts = { + 'dtype': 'float32' +}; + +var x = new Complex64Vector( discreteUniform( 10, -500, 500, opts ) ); +console.log( ndarray2array( x ) ); + +var out = scasum( [ x ] ); +console.log( out ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/scasum/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/benchmark/benchmark.js new file mode 100644 index 000000000000..1add8328c04a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/benchmark/benchmark.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var scasum = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var xbuf; + var x; + + xbuf = uniform( len*2, -100.0, 100.0, { + 'dtype': 'float32' + }); + x = new Complex64Vector( xbuf.buffer ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = scasum( [ x ] ); + if ( isnanf( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/scasum/docs/img/equation_l1norm.svg b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/docs/img/equation_l1norm.svg new file mode 100644 index 000000000000..4dbb928da546 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/docs/img/equation_l1norm.svg @@ -0,0 +1,44 @@ + +double-vertical-bar bold x double-vertical-bar Subscript 1 Baseline equals sigma-summation Underscript i equals 0 Overscript n minus 1 Endscripts StartAbsoluteValue x Subscript i Baseline EndAbsoluteValue + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/scasum/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/docs/repl.txt new file mode 100644 index 000000000000..7798406e1a20 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/docs/repl.txt @@ -0,0 +1,26 @@ + +{{alias}}( arrays ) + Computes the sum of absolute values for all elements in a one-dimensional + single-precision complex floating-point ndarray. + + If provided an empty input ndarray, the function returns `0.0`. + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing a one-dimensional input ndarray. + + Returns + ------- + out: number + The sum of absolute values. + + Examples + -------- + > var x = new {{alias:@stdlib/ndarray/vector/complex64}}( [ 1.0, -2.0, 3.0, -4.0 ] ); + > {{alias}}( [ x ] ) + 10.0 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/scasum/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/docs/types/index.d.ts new file mode 100644 index 000000000000..cd04eaa0b10d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/docs/types/index.d.ts @@ -0,0 +1,50 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { complex64ndarray } from '@stdlib/types/ndarray'; + +/** +* Computes the sum of absolute values for all elements in a one-dimensional single-precision complex floating-point ndarray. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* +* @param arrays - array-like object containing ndarrays +* @returns sum +* +* @example +* var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' ); +* +* var x = new Complex64Vector( [ 1.0, -2.0, 3.0, -4.0 ] ); +* +* var y = scasum( [ x ] ); +* // returns 10.0 +*/ +declare function scasum( arrays: [ complex64ndarray ] ): number; + + +// EXPORTS // + +export = scasum; diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/scasum/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/docs/types/test.ts new file mode 100644 index 000000000000..cfcd3edd8069 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/docs/types/test.ts @@ -0,0 +1,57 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable space-in-parens */ + +import zeros = require( '@stdlib/ndarray/zeros' ); +import scasum = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const x = zeros( [ 10 ], { + 'dtype': 'complex64' + }); + + scasum( [ x ] ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + scasum( '10' ); // $ExpectError + scasum( 10 ); // $ExpectError + scasum( true ); // $ExpectError + scasum( false ); // $ExpectError + scasum( null ); // $ExpectError + scasum( undefined ); // $ExpectError + scasum( [] ); // $ExpectError + scasum( {} ); // $ExpectError + scasum( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 10 ], { + 'dtype': 'complex64' + }); + + scasum(); // $ExpectError + scasum( [ x ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/scasum/examples/index.js b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/examples/index.js new file mode 100644 index 000000000000..6c5f54ee6871 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/examples/index.js @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var scasum = require( './../lib' ); + +var opts = { + 'dtype': 'float32' +}; + +var x = new Complex64Vector( discreteUniform( 10, -500, 500, opts ) ); +console.log( ndarray2array( x ) ); + +var out = scasum( [ x ] ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/scasum/lib/index.js b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/lib/index.js new file mode 100644 index 000000000000..a8be677e4f57 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/lib/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* BLAS level 1 routine to compute the sum of absolute values for all elements in a one-dimensional single-precision complex floating-point ndarray. +* +* @module @stdlib/blas/base/ndarray/scasum +* +* @example +* var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' ); +* var scasum = require( '@stdlib/blas/base/ndarray/scasum' ); +* +* var x = new Complex64Vector( [ 1.0, -2.0, 3.0, -4.0 ] ); +* +* var y = scasum( [ x ] ); +* // returns 10.0 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/scasum/lib/main.js b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/lib/main.js new file mode 100644 index 000000000000..0676eb1f57d1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/lib/main.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var numelDimension = require( '@stdlib/ndarray/base/numel-dimension' ); +var getStride = require( '@stdlib/ndarray/base/stride' ); +var getOffset = require( '@stdlib/ndarray/base/offset' ); +var getData = require( '@stdlib/ndarray/base/data-buffer' ); +var strided = require( '@stdlib/blas/base/scasum' ).ndarray; + + +// MAIN // + +/** +* Computes the sum of absolute values for all elements in a one-dimensional single-precision complex floating-point ndarray. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* +* @param {ArrayLikeObject} arrays - array-like object containing ndarrays +* @returns {number} sum +* +* @example +* var Complex64Vector = require( '@stdlib/ndarray/vector/complex64' ); +* +* var x = new Complex64Vector( [ 1.0, -2.0, 3.0, -4.0 ] ); +* +* var y = scasum( [ x ] ); +* // returns 10.0 +*/ +function scasum( arrays ) { + var x = arrays[ 0 ]; + return strided( numelDimension( x, 0 ), getData( x ), getStride( x, 0 ), getOffset( x ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = scasum; diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/scasum/package.json b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/package.json new file mode 100644 index 000000000000..a5dd05074fb8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/package.json @@ -0,0 +1,73 @@ +{ + "name": "@stdlib/blas/base/ndarray/scasum", + "version": "0.0.0", + "description": "Compute the sum of absolute values for all elements in a one-dimensional single-precision complex floating-point ndarray.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "level 1", + "linear", + "algebra", + "subroutines", + "scasum", + "dasum", + "asum", + "sum", + "absolute", + "absolute value", + "norm", + "float32", + "single", + "vector", + "ndarray" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ndarray/scasum/test/test.js b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/test/test.js new file mode 100644 index 000000000000..d31edc6eec1f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ndarray/scasum/test/test.js @@ -0,0 +1,180 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var scasum = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Collection} buffer - underlying data buffer +* @param {NonNegativeInteger} length - number of indexed elements +* @param {integer} stride - stride length +* @param {NonNegativeInteger} offset - index offset +* @returns {ndarray} one-dimensional ndarray +*/ +function vector( buffer, length, stride, offset ) { + return new ndarray( 'complex64', buffer, [ length ], [ stride ], offset, 'row-major' ); +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof scasum, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 1', function test( t ) { + t.strictEqual( scasum.length, 1, 'has expected arity' ); + t.end(); +}); + +tape( 'the function calculates the sum of absolute values for all elements in a one-dimensional ndarray', function test( t ) { + var xbuf; + var x; + var y; + + xbuf = new Complex64Array([ + 1.0, // 0 + -2.0, // 0 + 3.0, // 1 + -4.0, // 1 + 5.0, // 2 + -6.0 // 2 + ]); + x = vector( xbuf, 3, 1, 0 ); + y = scasum( [ x ] ); + + t.strictEqual( y, 21.0, 'returns expected value' ); + + xbuf = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 2.0, // 1 + 4.0 // 1 + ]); + x = vector( xbuf, 2, 1, 0 ); + y = scasum( [ x ] ); + + t.strictEqual( y, 9.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an empty ndarray, the function returns `0.0`', function test( t ) { + var xbuf; + var x; + var y; + + xbuf = new Complex64Array( [] ); + x = vector( xbuf, 0, 1, 0 ); + + y = scasum( [ x ] ); + t.strictEqual( y, 0.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports one-dimensional ndarrays having non-unit strides', function test( t ) { + var xbuf; + var x; + var y; + + xbuf = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 0.0, + 0.0, + 2.0, // 1 + 4.0, // 1 + 0.0, + 0.0, + 0.0, // 2 + 0.0 // 2 + ]); + x = vector( xbuf, 3, 2, 0 ); + + y = scasum( [ x ] ); + t.strictEqual( y, 9.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports one-dimensional ndarrays having negative strides', function test( t ) { + var xbuf; + var x; + var y; + + xbuf = new Complex64Array([ + 1.0, // 2 + 2.0, // 2 + 0.0, + 0.0, + 2.0, // 1 + 4.0, // 1 + 0.0, + 0.0, + 0.0, // 0 + 0.0 // 0 + ]); + x = vector( xbuf, 3, -2, 4 ); + + y = scasum( [ x ] ); + t.strictEqual( y, 9.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports one-dimensional ndarrays having non-zero offsets', function test( t ) { + var xbuf; + var x; + var y; + + xbuf = new Complex64Array([ + 0.0, + 0.0, + 1.0, // 0 + 2.0, // 0 + 0.0, + 0.0, + 2.0, // 1 + 4.0, // 1 + 0.0, + 0.0, + 0.0, // 2 + 0.0 // 2 + ]); + x = vector( xbuf, 3, 2, 1 ); + + y = scasum( [ x ] ); + t.strictEqual( y, 9.0, 'returns expected value' ); + + t.end(); +});