Skip to content

Commit 062b80e

Browse files
docs: improve doctests for complex number instances in strided/base/zmap
PR-URL: #9044 Ref: #8641 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 9e37c3a commit 062b80e

File tree

6 files changed

+18
-126
lines changed

6 files changed

+18
-126
lines changed

lib/node_modules/@stdlib/strided/base/zmap/README.md

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ Applies a unary function to a double-precision complex floating-point strided in
4242

4343
```javascript
4444
var Complex128Array = require( '@stdlib/array/complex128' );
45-
var real = require( '@stdlib/complex/float64/real' );
46-
var imag = require( '@stdlib/complex/float64/imag' );
4745
var cceil = require( '@stdlib/math/base/special/cceil' );
4846

4947
var x = new Complex128Array( [ -2.3, 1.5, 3.1, -5.2, 4.8, 0.0, -1.6, 3.4 ] );
@@ -52,13 +50,7 @@ var y = new Complex128Array( x.length );
5250
zmap( x.length, x, 1, y, 1, cceil );
5351

5452
var v = y.get( 0 );
55-
// returns <Complex128>
56-
57-
var re = real( v );
58-
// returns -2.0
59-
60-
var im = imag( v );
61-
// returns 2.0
53+
// returns <Complex128>[ -2.0, 2.0 ]
6254
```
6355

6456
The function accepts the following arguments:
@@ -74,8 +66,6 @@ The `N` and stride parameters determine which elements in the strided arrays are
7466

7567
```javascript
7668
var Complex128Array = require( '@stdlib/array/complex128' );
77-
var real = require( '@stdlib/complex/float64/real' );
78-
var imag = require( '@stdlib/complex/float64/imag' );
7969
var cceil = require( '@stdlib/math/base/special/cceil' );
8070

8171
var x = new Complex128Array( [ -2.3, 1.5, 3.1, -5.2, 4.8, 0.0, -1.6, 3.4 ] );
@@ -84,21 +74,13 @@ var y = new Complex128Array( x.length );
8474
zmap( 2, x, 2, y, -1, cceil );
8575

8676
var v = y.get( 0 );
87-
// returns <Complex128>
88-
89-
var re = real( v );
90-
// returns 5.0
91-
92-
var im = imag( v );
93-
// returns 0.0
77+
// returns <Complex128>[ 5.0, 0.0 ]
9478
```
9579

9680
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][@stdlib/array/complex128] views.
9781

9882
```javascript
9983
var Complex128Array = require( '@stdlib/array/complex128' );
100-
var real = require( '@stdlib/complex/float64/real' );
101-
var imag = require( '@stdlib/complex/float64/imag' );
10284
var cceil = require( '@stdlib/math/base/special/cceil' );
10385

10486
// Initial arrays...
@@ -112,13 +94,7 @@ var y1 = new Complex128Array( y0.buffer, y0.BYTES_PER_ELEMENT*2 ); // start at 3
11294
zmap( 2, x1, -2, y1, 1, cceil );
11395

11496
var v = y0.get( 2 );
115-
// returns <Complex128>
116-
117-
var re = real( v );
118-
// returns -1.0
119-
120-
var im = imag( v );
121-
// returns 4.0
97+
// returns <Complex128>[ -1.0, 4.0 ]
12298
```
12399

124100
#### zmap.ndarray( N, x, strideX, offsetX, y, strideY, offsetY, fcn )
@@ -127,8 +103,6 @@ Applies a unary function to a double-precision complex floating-point strided in
127103

128104
```javascript
129105
var Complex128Array = require( '@stdlib/array/complex128' );
130-
var real = require( '@stdlib/complex/float64/real' );
131-
var imag = require( '@stdlib/complex/float64/imag' );
132106
var cceil = require( '@stdlib/math/base/special/cceil' );
133107

134108
var x = new Complex128Array( [ -2.3, 1.5, 3.1, -5.2, 4.8, 0.0, -1.6, 3.4 ] );
@@ -137,13 +111,7 @@ var y = new Complex128Array( x.length );
137111
zmap.ndarray( x.length, x, 1, 0, y, 1, 0, cceil );
138112

139113
var v = y.get( 0 );
140-
// returns <Complex128>
141-
142-
var re = real( v );
143-
// returns -2.0
144-
145-
var im = imag( v );
146-
// returns 2.0
114+
// returns <Complex128>[ -2.0, 2.0 ]
147115
```
148116

149117
The function accepts the following additional arguments:
@@ -155,8 +123,6 @@ While [`typed array`][@stdlib/array/complex128] views mandate a view offset base
155123

156124
```javascript
157125
var Complex128Array = require( '@stdlib/array/complex128' );
158-
var real = require( '@stdlib/complex/float64/real' );
159-
var imag = require( '@stdlib/complex/float64/imag' );
160126
var cceil = require( '@stdlib/math/base/special/cceil' );
161127

162128
var x = new Complex128Array( [ -2.3, 1.5, 3.1, -5.2, 4.8, 0.0, -1.6, 3.4 ] );
@@ -165,13 +131,7 @@ var y = new Complex128Array( x.length );
165131
zmap.ndarray( 2, x, 2, 1, y, -1, y.length-1, cceil );
166132

167133
var v = y.get( y.length-1 );
168-
// returns <Complex128>
169-
170-
var re = real( v );
171-
// returns 4.0
172-
173-
var im = imag( v );
174-
// returns -5.0
134+
// returns <Complex128>[ 4.0, -5.0 ]
175135
```
176136

177137
</section>

lib/node_modules/@stdlib/strided/base/zmap/docs/repl.txt

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,13 @@
4343
> var y = new {{alias:@stdlib/array/complex128}}( x.length );
4444
> {{alias}}( x.length, x, 1, y, 1, {{alias:@stdlib/complex/float64/base/identity}} );
4545
> var v = y.get( 0 )
46-
<Complex128>
47-
> var re = {{alias:@stdlib/complex/float64/real}}( v )
48-
1.0
49-
> var im = {{alias:@stdlib/complex/float64/imag}}( v )
50-
2.0
46+
<Complex128>[ 1.0, 2.0 ]
5147

5248
// Using `N` and stride parameters:
5349
> y = new {{alias:@stdlib/array/complex128}}( x.length );
5450
> {{alias}}( 2, x, 2, y, -1, {{alias:@stdlib/complex/float64/base/identity}} );
5551
> v = y.get( 0 )
56-
<Complex128>
57-
> re = {{alias:@stdlib/complex/float64/real}}( v )
58-
5.0
59-
> im = {{alias:@stdlib/complex/float64/imag}}( v )
60-
6.0
52+
<Complex128>[ 5.0, 6.0 ]
6153

6254
// Using view offsets:
6355
> var x0 = new {{alias:@stdlib/array/complex128}}( xbuf );
@@ -66,11 +58,7 @@
6658
> var y1 = new {{alias:@stdlib/array/complex128}}( y0.buffer, y0.BYTES_PER_ELEMENT*2 );
6759
> {{alias}}( 2, x1, -2, y1, 1, {{alias:@stdlib/complex/float64/base/identity}} );
6860
> v = y1.get( 0 )
69-
<Complex128>
70-
> re = {{alias:@stdlib/complex/float64/real}}( v )
71-
7.0
72-
> im = {{alias:@stdlib/complex/float64/imag}}( v )
73-
8.0
61+
<Complex128>[ 7.0, 8.0 ]
7462

7563

7664
{{alias}}.ndarray( N, x, strideX, offsetX, y, strideY, offsetY, fcn )
@@ -121,22 +109,14 @@
121109
> var y = new {{alias:@stdlib/array/complex128}}( x.length );
122110
> {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0, {{alias:@stdlib/complex/float64/base/identity}} );
123111
> var v = y.get( 0 )
124-
<Complex128>
125-
> var re = {{alias:@stdlib/complex/float64/real}}( v )
126-
1.0
127-
> var im = {{alias:@stdlib/complex/float64/imag}}( v )
128-
2.0
112+
<Complex128>[ 1.0, 2.0 ]
129113

130114
// Advanced indexing:
131115
> x = new {{alias:@stdlib/array/complex128}}( xbuf );
132116
> y = new {{alias:@stdlib/array/complex128}}( x.length );
133117
> {{alias}}.ndarray( 2, x, 2, 1, y, -1, y.length-1, {{alias:@stdlib/complex/float64/base/identity}} );
134118
> v = y.get( y.length-1 )
135-
<Complex128>
136-
> re = {{alias:@stdlib/complex/float64/real}}( v )
137-
3.0
138-
> im = {{alias:@stdlib/complex/float64/imag}}( v )
139-
4.0
119+
<Complex128>[ 3.0, 4.0 ]
140120

141121
See Also
142122
--------

lib/node_modules/@stdlib/strided/base/zmap/docs/types/index.d.ts

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,7 @@ interface Routine {
6464
* zmap( x.length, x, 1, y, 1, scale );
6565
*
6666
* var v = y.get( 0 );
67-
* // returns <Complex128>
68-
*
69-
* var re = real( v );
70-
* // returns 10.0
71-
*
72-
* var im = imag( v );
73-
* // returns 10.0
67+
* // returns <Complex128>[ 10.0, 10.0 ]
7468
*/
7569
( N: number, x: Complex128Array, strideX: number, y: Complex128Array, strideY: number, fcn: Unary ): Complex128Array;
7670

@@ -105,13 +99,7 @@ interface Routine {
10599
* zmap.ndarray( x.length, x, 1, 0, y, 1, 0, scale );
106100
*
107101
* var v = y.get( 0 );
108-
* // returns <Complex128>
109-
*
110-
* var re = real( v );
111-
* // returns 10.0
112-
*
113-
* var im = imag( v );
114-
* // returns 10.0
102+
* // returns <Complex128>[ 10.0, 10.0 ]
115103
*/
116104
ndarray( N: number, x: Complex128Array, strideX: number, offsetX: number, y: Complex128Array, strideY: number, offsetY: number, fcn: Unary ): Complex128Array;
117105
}
@@ -145,13 +133,7 @@ interface Routine {
145133
* zmap( x.length, x, 1, y, 1, scale );
146134
*
147135
* var v = y.get( 0 );
148-
* // returns <Complex128>
149-
*
150-
* var re = real( v );
151-
* // returns 10.0
152-
*
153-
* var im = imag( v );
154-
* // returns 10.0
136+
* // returns <Complex128>[ 10.0, 10.0 ]
155137
*
156138
* @example
157139
* var Complex128Array = require( '@stdlib/array/complex128' );
@@ -171,13 +153,7 @@ interface Routine {
171153
* zmap.ndarray( x.length, x, 1, 0, y, 1, 0, scale );
172154
*
173155
* var v = y.get( 0 );
174-
* // returns <Complex128>
175-
*
176-
* var re = real( v );
177-
* // returns 10.0
178-
*
179-
* var im = imag( v );
180-
* // returns 10.0
156+
* // returns <Complex128>[ 10.0, 10.0 ]
181157
*/
182158
declare var zmap: Routine;
183159

lib/node_modules/@stdlib/strided/base/zmap/lib/index.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,7 @@
4242
* zmap( x.length, x, 1, y, 1, scale );
4343
*
4444
* var v = y.get( 0 );
45-
* // returns <Complex128>
46-
*
47-
* var re = real( v );
48-
* // returns 10.0
49-
*
50-
* var im = imag( v );
51-
* // returns 10.0
45+
* // returns <Complex128>[ 10.0, 10.0 ]
5246
*
5347
* @example
5448
* var Complex128Array = require( '@stdlib/array/complex128' );
@@ -69,13 +63,7 @@
6963
* zmap.ndarray( x.length, x, 1, 0, y, 1, 0, scale );
7064
*
7165
* var v = y.get( 0 );
72-
* // returns <Complex128>
73-
*
74-
* var re = real( v );
75-
* // returns 10.0
76-
*
77-
* var im = imag( v );
78-
* // returns 10.0
66+
* // returns <Complex128>[ 10.0, 10.0 ]
7967
*/
8068

8169
// MODULES //

lib/node_modules/@stdlib/strided/base/zmap/lib/main.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,7 @@ var ndarray = require( './ndarray.js' );
5555
* zmap( x.length, x, 1, y, 1, scale );
5656
*
5757
* var v = y.get( 0 );
58-
* // returns <Complex128>
59-
*
60-
* var re = real( v );
61-
* // returns 10.0
62-
*
63-
* var im = imag( v );
64-
* // returns 10.0
58+
* // returns <Complex128>[ 10.0, 10.0 ]
6559
*/
6660
function zmap( N, x, strideX, y, strideY, fcn ) {
6761
return ndarray( N, x, strideX, stride2offset( N, strideX ), y, strideY, stride2offset( N, strideY ), fcn ); // eslint-disable-line max-len

lib/node_modules/@stdlib/strided/base/zmap/lib/ndarray.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,7 @@
5151
* zmap( x.length, x, 1, 0, y, 1, 0, scale );
5252
*
5353
* var v = y.get( 0 );
54-
* // returns <Complex128>
55-
*
56-
* var re = real( v );
57-
* // returns 10.0
58-
*
59-
* var im = imag( v );
60-
* // returns 10.0
54+
* // returns <Complex128>[ 10.0, 10.0 ]
6155
*/
6256
function zmap( N, x, strideX, offsetX, y, strideY, offsetY, fcn ) {
6357
var ix;

0 commit comments

Comments
 (0)