diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/README.md new file mode 100644 index 000000000000..0cd14e8205d5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/README.md @@ -0,0 +1,86 @@ + + +# cfill + +> Fill a complex single-precision floating-point ndarray with a specified scalar constant. + +## Usage + +```javascript +var cfill = require( '@stdlib/blas/ext/base/ndarray/cfill' ); +``` + +#### cfill( x, alpha ) + +Fills a complex single-precision floating-point ndarray `x` with a specified scalar constant `alpha`. + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); + +var buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var x = new ndarray( 'complex64', buffer, [ 2 ], [ 1 ], 0, 'row-major' ); + +var alpha = new Complex64( 10.0, 10.0 ); + +cfill( x, alpha ); + +var v = x.get( 0 ); +// returns + +var re = v.re; +// returns 10.0 + +var im = v.im; +// returns 10.0 +``` + +## Examples + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var cfill = require( '@stdlib/blas/ext/base/ndarray/cfill' ); + +var buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var x = new ndarray( 'complex64', buffer, [ 3 ], [ 1 ], 0, 'row-major' ); + +var alpha = new Complex64( 10.0, 10.0 ); + +cfill( x, alpha ); + +var v = x.get( 0 ); +console.log( 'x[0] = %d + %di', realf( v ), imagf( v ) ); +// => 'x[0] = 10 + 10i' + +v = x.get( 1 ); +console.log( 'x[1] = %d + %di', realf( v ), imagf( v ) ); +// => 'x[1] = 10 + 10i' + +v = x.get( 2 ); +console.log( 'x[2] = %d + %di', realf( v ), imagf( v ) ); +// => 'x[2] = 10 + 10i' +``` + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/benchmark/benchmark.js new file mode 100644 index 000000000000..317bb5e6c942 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/benchmark/benchmark.js @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Complex64Array = require( '@stdlib/array/complex64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var isComplex64 = require( '@stdlib/assert/is-complex64' ); +var pkg = require( './../package.json' ).name; +var cfill = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var alpha; + var buf; + var x; + var i; + + buf = new Complex64Array( 100 ); + x = new ndarray( 'complex64', buf, [ 100 ], [ 1 ], 0, 'row-major' ); + alpha = new Complex64( 5.0, 5.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + cfill( x, alpha ); + if ( !isComplex64( x.get( 0 ) ) ) { + b.fail( 'should return a Complex64' ); + } + } + b.toc(); + if ( !isComplex64( x.get( 0 ) ) ) { + b.fail( 'should return a Complex64' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/docs/repl.txt new file mode 100644 index 000000000000..39037090099f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/docs/repl.txt @@ -0,0 +1,38 @@ + +{{alias}}( x, alpha ) + Fills a complex single-precision floating-point ndarray with a specified + scalar constant. + + Parameters + ---------- + x: ndarray + Input ndarray. + + alpha: ComplexLike + Scalar constant. + + Returns + ------- + out: ndarray + Input ndarray. + + Examples + -------- + > var buf = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0 ] ) + + > var x = {{alias:@stdlib/ndarray/ctor}}( 'complex64', buf, [ 2 ], [ 1 ], 0, 'row-major' ) + + > var alpha = new {{alias:@stdlib/complex/float32/ctor}}( 10.0, 10.0 ) + + > {{alias}}( x, alpha ) + + > var v = x.get( 0 ) + + > var re = v.re + 10.0 + > var im = v.im + 10.0 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/docs/types/index.d.ts new file mode 100644 index 000000000000..81486b549c9e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/docs/types/index.d.ts @@ -0,0 +1,53 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; +import { Complex64 } from '@stdlib/types/complex'; + +/** +* Fills a complex single-precision floating-point ndarray with a specified scalar constant. +* +* @param x - input ndarray +* @param alpha - scalar constant +* @returns input ndarray +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* +* var buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var x = new ndarray( 'complex64', buffer, [ 2 ], [ 1 ], 0, 'row-major' ); +* +* var alpha = new Complex64( 10.0, 10.0 ); +* +* cfill( x, alpha ); +* +* var v = x.get( 0 ); +* // returns +*/ +declare function cfill( x: complex64ndarray, alpha: Complex64 ): complex64ndarray; + + +// EXPORTS // + +export = cfill; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/docs/types/test.ts new file mode 100644 index 000000000000..7f0eec8966ab --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/docs/types/test.ts @@ -0,0 +1,76 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +import Complex64Array = require( '@stdlib/array/complex64' ); +import Complex64 = require( '@stdlib/complex/float32/ctor' ); +import ndarray = require( '@stdlib/ndarray/ctor' ); +import cfill = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const x = new ndarray( 'complex64', buffer, [ 2 ], [ 1 ], 0, 'row-major' ); + const alpha = new Complex64( 10.0, 10.0 ); + + cfill( x, alpha ); // $ExpectType complex64ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an ndarray... +{ + const alpha = new Complex64( 10.0, 10.0 ); + + cfill( '10', alpha ); // $ExpectError + cfill( 10, alpha ); // $ExpectError + cfill( true, alpha ); // $ExpectError + cfill( false, alpha ); // $ExpectError + cfill( null, alpha ); // $ExpectError + cfill( undefined, alpha ); // $ExpectError + cfill( [], alpha ); // $ExpectError + cfill( {}, alpha ); // $ExpectError + cfill( ( x: number ): number => x, alpha ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a complex number... +{ + const buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const x = new ndarray( 'complex64', buffer, [ 2 ], [ 1 ], 0, 'row-major' ); + + cfill( x, '10' ); // $ExpectError + cfill( x, 10 ); // $ExpectError + cfill( x, true ); // $ExpectError + cfill( x, false ); // $ExpectError + cfill( x, null ); // $ExpectError + cfill( x, undefined ); // $ExpectError + cfill( x, [] ); // $ExpectError + cfill( x, {} ); // $ExpectError + cfill( x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const x = new ndarray( 'complex64', buffer, [ 2 ], [ 1 ], 0, 'row-major' ); + const alpha = new Complex64( 10.0, 10.0 ); + + cfill(); // $ExpectError + cfill( x ); // $ExpectError + cfill( x, alpha, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/examples/index.js new file mode 100644 index 000000000000..754541fb2f17 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/examples/index.js @@ -0,0 +1,45 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Complex64Array = require( '@stdlib/array/complex64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var cfill = require( './../lib' ); + +var buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var x = new ndarray( 'complex64', buffer, [ 3 ], [ 1 ], 0, 'row-major' ); + +var alpha = new Complex64( 10.0, 10.0 ); + +cfill( x, alpha ); + +var v = x.get( 0 ); +console.log( 'x[0] = %d + %di', realf( v ), imagf( v ) ); +// => 'x[0] = 10 + 10i' + +v = x.get( 1 ); +console.log( 'x[1] = %d + %di', realf( v ), imagf( v ) ); +// => 'x[1] = 10 + 10i' + +v = x.get( 2 ); +console.log( 'x[2] = %d + %di', realf( v ), imagf( v ) ); +// => 'x[2] = 10 + 10i' diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/lib/index.js new file mode 100644 index 000000000000..98836b96b2d0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/lib/index.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Fill a complex single-precision floating-point ndarray with a specified scalar constant. +* +* @module @stdlib/blas/ext/base/ndarray/cfill +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* var cfill = require( '@stdlib/blas/ext/base/ndarray/cfill' ); +* +* var buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var x = new ndarray( 'complex64', buffer, [ 2 ], [ 1 ], 0, 'row-major' ); +* +* var alpha = new Complex64( 10.0, 10.0 ); +* +* cfill( x, alpha ); +* +* var v = x.get( 0 ); +* // returns +* +* var re = v.re; +* // returns 10.0 +* +* var im = v.im; +* // returns 10.0 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/lib/main.js new file mode 100644 index 000000000000..18b9e9b47bca --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/lib/main.js @@ -0,0 +1,81 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 strided = require( '@stdlib/blas/ext/base/cfill' ).ndarray; +var getStride = require( '@stdlib/ndarray/base/stride' ); +var getOffset = require( '@stdlib/ndarray/base/offset' ); +var getData = require( '@stdlib/ndarray/base/data-buffer' ); + + +// MAIN // + +/** +* Fills a complex single-precision floating-point ndarray with a specified scalar constant. +* +* @param {complex64ndarray} x - input ndarray +* @param {ComplexLike} alpha - scalar constant +* @returns {complex64ndarray} input ndarray +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* +* var buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var x = new ndarray( 'complex64', buffer, [ 2 ], [ 1 ], 0, 'row-major' ); +* +* var alpha = new Complex64( 10.0, 10.0 ); +* +* cfill( x, alpha ); +* +* var v = x.get( 0 ); +* // returns +* +* var re = v.re; +* // returns 10.0 +* +* var im = v.im; +* // returns 10.0 +*/ +function cfill( x, alpha ) { + var buf; + var ox; + var sx; + var N; + + N = numelDimension( x, 0 ); + if ( N <= 0 ) { + return x; + } + buf = getData( x ); + sx = getStride( x, 0 ); + ox = getOffset( x ); + + strided( N, alpha, buf, sx, ox ); + return x; +} + + +// EXPORTS // + +module.exports = cfill; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/package.json new file mode 100644 index 000000000000..cf1bdcb5c8da --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/cfill", + "version": "0.0.0", + "description": "Fill a complex single-precision floating-point ndarray with a specified scalar constant.", + "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", + "stdtypes", + "types", + "data", + "structure", + "ndarray", + "blas", + "extend", + "extended", + "extension", + "base", + "fill", + "array", + "typed", + "complex", + "complex64", + "float", + "float32", + "single" + ] +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/test/test.js new file mode 100644 index 000000000000..caa81174919c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/cfill/test/test.js @@ -0,0 +1,156 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var cfill = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof cfill, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function fills an ndarray with a specified scalar constant', function test( t ) { + var alpha; + var raw; + var buf; + var x; + var v; + + raw = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + buf = new Complex64Array( raw ); + x = new ndarray( 'complex64', buf, [ 2 ], [ 1 ], 0, 'row-major' ); + + alpha = new Complex64( 5.0, -3.0 ); + + cfill( x, alpha ); + + v = x.get( 0 ); + t.strictEqual( realf( v ), 5.0, 'returns expected real component for element 0' ); + t.strictEqual( imagf( v ), -3.0, 'returns expected imaginary component for element 0' ); + + v = x.get( 1 ); + t.strictEqual( realf( v ), 5.0, 'returns expected real component for element 1' ); + t.strictEqual( imagf( v ), -3.0, 'returns expected imaginary component for element 1' ); + + t.end(); +}); + +tape( 'the function returns the input ndarray', function test( t ) { + var alpha; + var raw; + var buf; + var out; + var x; + + raw = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + buf = new Complex64Array( raw ); + x = new ndarray( 'complex64', buf, [ 2 ], [ 1 ], 0, 'row-major' ); + + alpha = new Complex64( 10.0, 10.0 ); + + out = cfill( x, alpha ); + + t.strictEqual( out, x, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var alpha; + var raw; + var buf; + var x; + var v; + + raw = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + buf = new Complex64Array( raw ); + x = new ndarray( 'complex64', buf, [ 2 ], [ -1 ], 1, 'row-major' ); + + alpha = new Complex64( 7.0, 8.0 ); + + cfill( x, alpha ); + + v = x.get( 0 ); + t.strictEqual( realf( v ), 7.0, 'returns expected real component for element 0' ); + t.strictEqual( imagf( v ), 8.0, 'returns expected imaginary component for element 0' ); + + v = x.get( 1 ); + t.strictEqual( realf( v ), 7.0, 'returns expected real component for element 1' ); + t.strictEqual( imagf( v ), 8.0, 'returns expected imaginary component for element 1' ); + + t.end(); +}); + +tape( 'the function supports an offset', function test( t ) { + var alpha; + var raw; + var buf; + var x; + var v; + + raw = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + buf = new Complex64Array( raw ); + x = new ndarray( 'complex64', buf, [ 2 ], [ 1 ], 1, 'row-major' ); + + alpha = new Complex64( 9.0, -2.0 ); + + cfill( x, alpha ); + + v = buf.get( 0 ); + t.strictEqual( realf( v ), 1.0, 'element 0 unchanged (real)' ); + t.strictEqual( imagf( v ), 2.0, 'element 0 unchanged (imag)' ); + + v = x.get( 0 ); + t.strictEqual( realf( v ), 9.0, 'returns expected real component for element at offset' ); + t.strictEqual( imagf( v ), -2.0, 'returns expected imaginary component for element at offset' ); + + t.end(); +}); + +tape( 'the function handles zero-length dimensions', function test( t ) { + var alpha; + var raw; + var buf; + var x; + + raw = new Float32Array( [ 1.0, 2.0 ] ); + buf = new Complex64Array( raw ); + x = new ndarray( 'complex64', buf, [ 0 ], [ 1 ], 0, 'row-major' ); + + alpha = new Complex64( 5.0, 5.0 ); + + cfill( x, alpha ); + + t.strictEqual( realf( buf.get( 0 ) ), 1.0, 'buffer unchanged' ); + t.strictEqual( imagf( buf.get( 0 ) ), 2.0, 'buffer unchanged' ); + + t.end(); +});