diff --git a/lib/node_modules/@stdlib/math/base/complex/negate/README.md b/lib/node_modules/@stdlib/math/base/complex/negate/README.md index f7aabb8c8894..4864b14ac45f 100644 --- a/lib/node_modules/@stdlib/math/base/complex/negate/README.md +++ b/lib/node_modules/@stdlib/math/base/complex/negate/README.md @@ -46,13 +46,13 @@ Negates a `complex` number comprised of a **real** component `re` and an **imagi ```javascript var v = cnegate( -4.2, 5.5 ); -// returns [ TODO, TODO ] +// returns [ 4.2, -5.5 ] v = cnegate( 0.0, 0.0 ); -// returns [ TODO, TODO ] +// returns [ -0.0, -0.0 ] v = cnegate( NaN, NaN ); -// returns [ TODO, TODO ] +// returns [ NaN, NaN ] ``` By default, the function returns real and imaginary components as a two-element `array`. To avoid unnecessary memory allocation, the function supports providing an output (destination) object. @@ -63,7 +63,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var out = new Float64Array( 2 ); var v = cnegate( out, -4.2, 5.5 ); -// returns [ TODO, TODO ] +// returns [ 4.2, -5.5 ] var bool = ( v === out ); // returns true diff --git a/lib/node_modules/@stdlib/math/base/complex/negate/docs/repl.txt b/lib/node_modules/@stdlib/math/base/complex/negate/docs/repl.txt index 36d244f0fe1b..17da52ec96ac 100644 --- a/lib/node_modules/@stdlib/math/base/complex/negate/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/complex/negate/docs/repl.txt @@ -20,13 +20,13 @@ Examples -------- - > var out = {{alias}}( TODO, TODO ) - TODO + > var out = {{alias}}( -4.2, 5.5 ) + [ 4.2, -5.5 ] // Provide an output array: > out = new {{alias:@stdlib/array/float64}}( 2 ); - > var v = {{alias}}( out, TODO, TODO ) - [ TODO, TODO ] + > var v = {{alias}}( out, -4.2, 5.5 ) + [ 4.2, -5.5 ] > var bool = ( v === out ) true diff --git a/lib/node_modules/@stdlib/math/base/complex/negate/lib/cnegate.js b/lib/node_modules/@stdlib/math/base/complex/negate/lib/cnegate.js index ecfd4aa83d3b..c2ef6250787e 100644 --- a/lib/node_modules/@stdlib/math/base/complex/negate/lib/cnegate.js +++ b/lib/node_modules/@stdlib/math/base/complex/negate/lib/cnegate.js @@ -32,8 +32,8 @@ * @example * var out = new Array( 2 ); * -* var v = cnegate( out, TODO, TODO ); -* // returns [ TODO, TODO ] +* var v = cnegate( out, -4.2, 5.5 ); +* // returns [ 4.2, -5.5 ] * * var bool = ( v === out ); * // returns true @@ -41,15 +41,17 @@ * @example * var out = new Array( 2 ); * var v = cnegate( out, 0.0, 0.0 ); -* // returns [ TODO, TODO ] +* // returns [ -0.0, -0.0 ] * * @example * var out = new Array( 2 ); * var v = cnegate( out, NaN, NaN ); -* // returns [ TODO, TODO ] +* // returns [ NaN, NaN ] */ function cnegate( out, re, im ) { - // TODO: implementation + out[ 0 ] = -re; + out[ 1 ] = -im; + return out; } diff --git a/lib/node_modules/@stdlib/math/base/complex/negate/lib/index.js b/lib/node_modules/@stdlib/math/base/complex/negate/lib/index.js index f694f0db9de6..c452649c537c 100644 --- a/lib/node_modules/@stdlib/math/base/complex/negate/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/complex/negate/lib/index.js @@ -27,13 +27,13 @@ * var cnegate = require( '@stdlib/math/base/complex/negate' ); * * var v = cnegate( -4.2, 5.5 ); -* // returns [ TODO, TODO ] +* // returns [ 4.2, -5.5 ] * * v = cnegate( 0.0, 0.0 ); -* // returns [ TODO, TODO ] +* // returns [ -0.0, -0.0 ] * * v = cnegate( NaN, NaN ); -* // returns [ TODO, TODO ] +* // returns [ NaN, NaN ] * * @example * var cnegate = require( '@stdlib/math/base/complex/negate' ); @@ -41,7 +41,7 @@ * var out = new Array( 2 ); * * var v = cnegate( out, -4.2, 5.5 ); -* // returns [ TODO, TODO ] +* // returns [ 4.2, -5.5 ] * * var bool = ( v === out ); * // returns true diff --git a/lib/node_modules/@stdlib/math/base/complex/negate/lib/main.js b/lib/node_modules/@stdlib/math/base/complex/negate/lib/main.js index cdf3067d487d..f300dd85cb3d 100644 --- a/lib/node_modules/@stdlib/math/base/complex/negate/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/complex/negate/lib/main.js @@ -35,24 +35,24 @@ var negate = require( './cnegate.js' ); * * @example * var v = cnegate( -4.2, 5.5 ); -* // returns [ TODO, TODO ] +* // returns [ 4.2, -5.5 ] * * @example * var out = new Array( 2 ); * * var v = cnegate( out, -4.2, 5.5 ); -* // returns [ TODO, TODO ] +* // returns [ 4.2, -5.5 ] * * var bool = ( v === out ); * // returns true * * @example * var v = cnegate( 0.0, 0.0 ); -* // returns [ TODO, TODO ] +* // returns [ -0.0, -0.0 ] * * @example * var v = cnegate( NaN, NaN ); -* // returns [ TODO, TODO ] +* // returns [ NaN, NaN ] */ function cnegate( out, re, im ) { if ( arguments.length === 2 ) { diff --git a/lib/node_modules/@stdlib/math/base/complex/negate/test/test.js b/lib/node_modules/@stdlib/math/base/complex/negate/test/test.js index 2fd279d6ff9c..ccec6c0bfbf4 100644 --- a/lib/node_modules/@stdlib/math/base/complex/negate/test/test.js +++ b/lib/node_modules/@stdlib/math/base/complex/negate/test/test.js @@ -42,8 +42,20 @@ tape( 'the function negates real and imaginary components', function test( t ) { var expected; var actual; - // TODO: tests + actual = cnegate( -4.2, 5.5 ); + expected = [ 4.2, -5.5 ]; + t.deepEqual( actual, expected, 'returns expected value' ); + + actual = cnegate( 9.99999, 0.1 ); + expected = [ -9.99999, -0.1 ]; + t.deepEqual( actual, expected, 'returns expected value' ); + + actual = cnegate( 4.0, 7.0 ); + expected = [ -4.0, -7.0 ]; + t.deepEqual( actual, expected, 'returns expected value' ); + actual = cnegate( -4.0, -7.0 ); + expected = [ 4.0, 7.0 ]; t.deepEqual( actual, expected, 'returns expected value' ); t.end(); @@ -54,7 +66,10 @@ tape( 'the function negates real and imaginary components (output array)', funct var actual; var out; - // TODO: tests + out = new Array( 2 ); + actual = cnegate( out, -4.2, 5.5 ); + + expected = [ 4.2, -5.5 ]; t.deepEqual( actual, expected, 'returns expected value' ); t.strictEqual( actual, out, 'returns output value' ); @@ -67,7 +82,10 @@ tape( 'the function negates real and imaginary components (output typed array)', var actual; var out; - // TODO: tests + out = new Float64Array( 2 ); + actual = cnegate( out, 9.99999, 0.1 ); + + expected = new Float64Array( [ -9.99999, -0.1 ] ); t.deepEqual( actual, expected, 'returns expected value' ); t.strictEqual( actual, out, 'returns output value' ); @@ -80,7 +98,13 @@ tape( 'the function negates real and imaginary components (output object)', func var actual; var out; - // TODO: tests + out = {}; + actual = cnegate( out, 4.2, -5.5 ); + + expected = { + '0': -4.2, + '1': 5.5 + }; t.deepEqual( actual, expected, 'returns expected value' ); t.strictEqual( actual, out, 'returns output value' );