Skip to content

Commit f3a591e

Browse files
authored
docs: improve doctests for complex number instances in math/base/special/croundn
PR-URL: #9008 Ref: #8641 Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent 1c82f0d commit f3a591e

File tree

6 files changed

+19
-143
lines changed

6 files changed

+19
-143
lines changed

lib/node_modules/@stdlib/math/base/special/croundn/README.md

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -36,44 +36,18 @@ Rounds each component of a double-precision complex floating-point number to the
3636

3737
```javascript
3838
var Complex128 = require( '@stdlib/complex/float64/ctor' );
39-
var real = require( '@stdlib/complex/float64/real' );
40-
var imag = require( '@stdlib/complex/float64/imag' );
4139

4240
var v = croundn( new Complex128( -3.141592653589793, 3.141592653589793 ), -2 );
43-
// returns <Complex128>
44-
45-
var re = real( v );
46-
// returns -3.14
47-
48-
var im = imag( v );
49-
// returns 3.14
41+
// returns <Complex128>[ -3.14, 3.14 ]
5042

5143
v = croundn( new Complex128( -3.141592653589793, 3.141592653589793 ), 0 );
52-
// returns <Complex128>
53-
54-
re = real( v );
55-
// returns -3.0
56-
57-
im = imag( v );
58-
// returns 3.0
44+
// returns <Complex128>[ -3.0, 3.0 ]
5945

6046
v = croundn( new Complex128( -12368.0, 12368.0 ), 3 );
61-
// returns <Complex128>
62-
63-
re = real( v );
64-
// returns -12000.0
65-
66-
im = imag( v );
67-
// returns 12000.0
47+
// returns <Complex128>[ -12000.0, 12000.0 ]
6848

6949
v = croundn( new Complex128( NaN, NaN ), 3 );
70-
// returns <Complex128>
71-
72-
re = real( v );
73-
// returns NaN
74-
75-
im = imag( v );
76-
// returns NaN
50+
// returns <Complex128>[ NaN, NaN ]
7751
```
7852

7953
</section>
@@ -88,21 +62,13 @@ im = imag( v );
8862

8963
```javascript
9064
var Complex128 = require( '@stdlib/complex/float64/ctor' );
91-
var real = require( '@stdlib/complex/float64/real' );
92-
var imag = require( '@stdlib/complex/float64/imag' );
9365

9466
var x = 0.2 + 0.1;
9567
// returns 0.30000000000000004
9668

9769
// Should round components to 0.3:
9870
var v = croundn( new Complex128( x, x ), -16 );
99-
// returns <Complex128>
100-
101-
var re = real( v );
102-
// returns 0.3000000000000001
103-
104-
var im = imag( v );
105-
// returns 0.3000000000000001
71+
// returns <Complex128>[ 0.3000000000000001, 0.3000000000000001 ]
10672
```
10773

10874
</section>

lib/node_modules/@stdlib/math/base/special/croundn/docs/repl.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@
2222
Examples
2323
--------
2424
> var v = {{alias}}( new {{alias:@stdlib/complex/float64/ctor}}( 5.555, -3.336 ), -2 )
25-
<Complex128>
26-
> var re = {{alias:@stdlib/complex/float64/real}}( v )
27-
5.56
28-
> var im = {{alias:@stdlib/complex/float64/imag}}( v )
29-
-3.34
25+
<Complex128>[ 5.56, -3.34 ]
3026

3127
See Also
3228
--------

lib/node_modules/@stdlib/math/base/special/croundn/docs/types/index.d.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,9 @@ import { Complex128 } from '@stdlib/types/complex';
3535
*
3636
* @example
3737
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
38-
* var real = require( '@stdlib/complex/float64/real' );
39-
* var imag = require( '@stdlib/complex/float64/imag' );
4038
*
4139
* var v = croundn( new Complex128( 5.555, -3.333 ), -2 );
42-
* // returns <Complex128>
43-
*
44-
* var re = real( v );
45-
* // returns 5.56
46-
*
47-
* var im = imag( v );
48-
* // returns -3.33
40+
* // returns <Complex128>[ 5.56, -3.33 ]
4941
*/
5042
declare function croundn( z: Complex128, n: number ): Complex128;
5143

lib/node_modules/@stdlib/math/base/special/croundn/lib/index.js

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,47 +25,21 @@
2525
*
2626
* @example
2727
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
28-
* var real = require( '@stdlib/complex/float64/real' );
29-
* var imag = require( '@stdlib/complex/float64/imag' );
3028
* var croundn = require( '@stdlib/math/base/special/croundn' );
3129
*
3230
* var v = croundn( new Complex128( -3.141592653589793, 3.141592653589793 ), -2 );
33-
* // returns <Complex128>
34-
*
35-
* var re = real( v );
36-
* // returns -3.14
37-
*
38-
* var im = imag( v );
39-
* // returns 3.14
31+
* // returns <Complex128>[ -3.14, 3.14 ]
4032
*
4133
* // If n = 0, `croundn` behaves like `cround`:
4234
* v = croundn( new Complex128( 9.99999, 0.1 ), 0 );
43-
* // returns <Complex128>
44-
*
45-
* re = real( v );
46-
* // returns 10.0
47-
*
48-
* im = imag( v );
49-
* // returns 0.0
35+
* // returns <Complex128>[ 10.0, 0.0 ]
5036
*
5137
* // Round components to the nearest thousand:
5238
* v = croundn( new Complex128( 12368.0, -12368.0 ), 3 );
53-
* // returns <Complex128>
54-
*
55-
* re = real( v );
56-
* // returns 12000.0
57-
*
58-
* im = imag( v );
59-
* // returns -12000.0
39+
* // returns <Complex128>[ 12000.0, -12000.0 ]
6040
*
6141
* v = croundn( new Complex128( NaN, NaN ), 2 );
62-
* // returns <Complex128>
63-
*
64-
* re = real( v );
65-
* // returns NaN
66-
*
67-
* im = imag( v );
68-
* // returns NaN
42+
* // returns <Complex128>[ NaN, NaN ]
6943
*/
7044

7145
// MODULES //

lib/node_modules/@stdlib/math/base/special/croundn/lib/main.js

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,46 +37,20 @@ var imag = require( '@stdlib/complex/float64/imag' );
3737
*
3838
* @example
3939
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
40-
* var real = require( '@stdlib/complex/float64/real' );
41-
* var imag = require( '@stdlib/complex/float64/imag' );
4240
*
4341
* var v = croundn( new Complex128( -3.141592653589793, 3.141592653589793 ), -2 );
44-
* // returns <Complex128>
45-
*
46-
* var re = real( v );
47-
* // returns -3.14
48-
*
49-
* var im = imag( v );
50-
* // returns 3.14
42+
* // returns <Complex128>[ -3.14, 3.14 ]
5143
*
5244
* // If n = 0, `croundn` behaves like `cround`:
5345
* v = croundn( new Complex128( 9.99999, 0.1 ), 0 );
54-
* // returns <Complex128>
55-
*
56-
* re = real( v );
57-
* // returns 10.0
58-
*
59-
* im = imag( v );
60-
* // returns 0.0
46+
* // returns <Complex128>[ 10.0, 0.0 ]
6147
*
6248
* // Round components to the nearest thousand:
6349
* v = croundn( new Complex128( 12368.0, -12368.0 ), 3 );
64-
* // returns <Complex128>
65-
*
66-
* re = real( v );
67-
* // returns 12000.0
68-
*
69-
* im = imag( v );
70-
* // returns -12000.0
50+
* // returns <Complex128>[ 12000.0, -12000.0 ]
7151
*
7252
* v = croundn( new Complex128( NaN, NaN ), 2 );
73-
* // returns <Complex128>
74-
*
75-
* re = real( v );
76-
* // returns NaN
77-
*
78-
* im = imag( v );
79-
* // returns NaN
53+
* // returns <Complex128>[ NaN, NaN ]
8054
*/
8155
function croundn( z, n ) {
8256
return new Complex128( roundn( real( z ), n ), roundn( imag( z ), n ) );

lib/node_modules/@stdlib/math/base/special/croundn/lib/native.js

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -36,46 +36,20 @@ var addon = require( './../src/addon.node' );
3636
*
3737
* @example
3838
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
39-
* var real = require( '@stdlib/complex/float64/real' );
40-
* var imag = require( '@stdlib/complex/float64/imag' );
4139
*
4240
* var v = croundn( new Complex128( -3.141592653589793, 3.141592653589793 ), -2 );
43-
* // returns <Complex128>
44-
*
45-
* var re = real( v );
46-
* // returns -3.14
47-
*
48-
* var im = imag( v );
49-
* // returns 3.14
41+
* // returns <Complex128>[ -3.14, 3.14 ]
5042
*
5143
* // If n = 0, `croundn` behaves like `cround`:
5244
* v = croundn( new Complex128( 9.99999, 0.1 ), 0 );
53-
* // returns <Complex128>
54-
*
55-
* re = real( v );
56-
* // returns 10.0
57-
*
58-
* im = imag( v );
59-
* // returns 0.0
45+
* // returns <Complex128>[ 10.0, 0.0 ]
6046
*
6147
* // Round components to the nearest thousand:
6248
* v = croundn( new Complex128( 12368.0, -12368.0 ), 3 );
63-
* // returns <Complex128>
64-
*
65-
* re = real( v );
66-
* // returns 12000.0
67-
*
68-
* im = imag( v );
69-
* // returns -12000.0
49+
* // returns <Complex128>[ 12000.0, -12000.0 ]
7050
*
7151
* v = croundn( new Complex128( NaN, NaN ), 2 );
72-
* // returns <Complex128>
73-
*
74-
* re = real( v );
75-
* // returns NaN
76-
*
77-
* im = imag( v );
78-
* // returns NaN
52+
* // returns <Complex128>[ NaN, NaN ]
7953
*/
8054
function croundn( z, n ) {
8155
var v = addon( z, n );

0 commit comments

Comments
 (0)