@stdlib/array-complex64 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +492 -116
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/docs/types/index.d.ts +405 -50
- package/lib/from_array.js +2 -2
- package/lib/from_iterator.js +2 -2
- package/lib/from_iterator_map.js +2 -2
- package/lib/main.js +661 -65
- package/package.json +33 -63
package/README.md
CHANGED
|
@@ -123,7 +123,7 @@ var len = arr.length;
|
|
|
123
123
|
Creates a 64-bit complex number array from an array-like object or iterable.
|
|
124
124
|
|
|
125
125
|
```javascript
|
|
126
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
126
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
127
127
|
|
|
128
128
|
// From an array of interleaved real and imaginary components:
|
|
129
129
|
var arr1 = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] );
|
|
@@ -283,7 +283,7 @@ var len = arr.length;
|
|
|
283
283
|
Creates a new 64-bit complex number array from an array-like object or an iterable.
|
|
284
284
|
|
|
285
285
|
```javascript
|
|
286
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
286
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
287
287
|
|
|
288
288
|
// Create an array from interleaved real and imaginary components:
|
|
289
289
|
var arr = Complex64Array.from( [ 1.0, -1.0 ] );
|
|
@@ -305,8 +305,8 @@ The iterator returned by an iterable must return either a complex number or an a
|
|
|
305
305
|
```javascript
|
|
306
306
|
var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' );
|
|
307
307
|
var Float32Array = require( '@stdlib/array-float32' );
|
|
308
|
-
var realf = require( '@stdlib/complex-
|
|
309
|
-
var imagf = require( '@stdlib/complex-
|
|
308
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
309
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
310
310
|
|
|
311
311
|
var iter;
|
|
312
312
|
var arr;
|
|
@@ -367,9 +367,9 @@ if ( ITERATOR_SYMBOL === null ) {
|
|
|
367
367
|
To invoke a function for each `src` value, provide a callback function. If `src` is an iterable or an array-like object containing complex numbers, the callback must return either a complex number
|
|
368
368
|
|
|
369
369
|
```javascript
|
|
370
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
371
|
-
var realf = require( '@stdlib/complex-
|
|
372
|
-
var imagf = require( '@stdlib/complex-
|
|
370
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
371
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
372
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
373
373
|
|
|
374
374
|
function map( z ) {
|
|
375
375
|
return new Complex64( realf(z)*2.0, imagf(z)*2.0 );
|
|
@@ -399,9 +399,9 @@ or an array-like object containing real and imaginary components
|
|
|
399
399
|
|
|
400
400
|
```javascript
|
|
401
401
|
var Float32Array = require( '@stdlib/array-float32' );
|
|
402
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
403
|
-
var realf = require( '@stdlib/complex-
|
|
404
|
-
var imagf = require( '@stdlib/complex-
|
|
402
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
403
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
404
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
405
405
|
|
|
406
406
|
// Return a callback which reuses allocated memory...
|
|
407
407
|
function mapFcn() {
|
|
@@ -448,9 +448,9 @@ If `src` is an array-like object containing interleaved real and imaginary compo
|
|
|
448
448
|
|
|
449
449
|
```javascript
|
|
450
450
|
var Float32Array = require( '@stdlib/array-float32' );
|
|
451
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
452
|
-
var realf = require( '@stdlib/complex-
|
|
453
|
-
var imagf = require( '@stdlib/complex-
|
|
451
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
452
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
453
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
454
454
|
|
|
455
455
|
function map( v ) {
|
|
456
456
|
return v * 2.0;
|
|
@@ -484,9 +484,9 @@ A callback function is provided two arguments:
|
|
|
484
484
|
To set the callback execution context, provide a `thisArg`.
|
|
485
485
|
|
|
486
486
|
```javascript
|
|
487
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
488
|
-
var realf = require( '@stdlib/complex-
|
|
489
|
-
var imagf = require( '@stdlib/complex-
|
|
487
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
488
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
489
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
490
490
|
|
|
491
491
|
function map( z ) {
|
|
492
492
|
this.count += 1;
|
|
@@ -519,7 +519,7 @@ var n = ctx.count;
|
|
|
519
519
|
Creates a new 64-bit complex number array from a variable number of arguments.
|
|
520
520
|
|
|
521
521
|
```javascript
|
|
522
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
522
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
523
523
|
|
|
524
524
|
var arr = Complex64Array.of( 1.0, -1.0, 2.0, -2.0 );
|
|
525
525
|
// returns <Complex64Array>
|
|
@@ -544,8 +544,8 @@ len = arr.length;
|
|
|
544
544
|
Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer positions.
|
|
545
545
|
|
|
546
546
|
```javascript
|
|
547
|
-
var realf = require( '@stdlib/complex-
|
|
548
|
-
var imagf = require( '@stdlib/complex-
|
|
547
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
548
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
549
549
|
|
|
550
550
|
var arr = new Complex64Array( 10 );
|
|
551
551
|
|
|
@@ -594,9 +594,9 @@ z = arr.at( -100 );
|
|
|
594
594
|
Copies a sequence of elements within the array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`.
|
|
595
595
|
|
|
596
596
|
```javascript
|
|
597
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
598
|
-
var realf = require( '@stdlib/complex-
|
|
599
|
-
var imagf = require( '@stdlib/complex-
|
|
597
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
598
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
599
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
600
600
|
|
|
601
601
|
var arr = new Complex64Array( 4 );
|
|
602
602
|
|
|
@@ -653,9 +653,9 @@ im = imagf( z );
|
|
|
653
653
|
By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument.
|
|
654
654
|
|
|
655
655
|
```javascript
|
|
656
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
657
|
-
var realf = require( '@stdlib/complex-
|
|
658
|
-
var imagf = require( '@stdlib/complex-
|
|
656
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
657
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
658
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
659
659
|
|
|
660
660
|
var arr = new Complex64Array( 4 );
|
|
661
661
|
|
|
@@ -712,9 +712,9 @@ im = imagf( z );
|
|
|
712
712
|
When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example:
|
|
713
713
|
|
|
714
714
|
```javascript
|
|
715
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
716
|
-
var realf = require( '@stdlib/complex-
|
|
717
|
-
var imagf = require( '@stdlib/complex-
|
|
715
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
716
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
717
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
718
718
|
|
|
719
719
|
var arr = new Complex64Array( 4 );
|
|
720
720
|
|
|
@@ -775,9 +775,9 @@ im = imagf( z );
|
|
|
775
775
|
Returns an iterator for iterating over array key-value pairs.
|
|
776
776
|
|
|
777
777
|
```javascript
|
|
778
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
779
|
-
var realf = require( '@stdlib/complex-
|
|
780
|
-
var imagf = require( '@stdlib/complex-
|
|
778
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
779
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
780
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
781
781
|
|
|
782
782
|
var arr = [
|
|
783
783
|
new Complex64( 1.0, -1.0 ),
|
|
@@ -821,6 +821,11 @@ var bool = it.next().done;
|
|
|
821
821
|
// returns true
|
|
822
822
|
```
|
|
823
823
|
|
|
824
|
+
The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties:
|
|
825
|
+
|
|
826
|
+
- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished.
|
|
827
|
+
- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object.
|
|
828
|
+
|
|
824
829
|
<a name="method-every"></a>
|
|
825
830
|
|
|
826
831
|
#### Complex64Array.prototype.every( predicate\[, thisArg] )
|
|
@@ -828,8 +833,8 @@ var bool = it.next().done;
|
|
|
828
833
|
Returns a boolean indicating whether all elements pass a test.
|
|
829
834
|
|
|
830
835
|
```javascript
|
|
831
|
-
var realf = require( '@stdlib/complex-
|
|
832
|
-
var imagf = require( '@stdlib/complex-
|
|
836
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
837
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
833
838
|
|
|
834
839
|
function predicate( v ) {
|
|
835
840
|
return ( realf( v ) === imagf( v ) );
|
|
@@ -886,9 +891,9 @@ var count = context.count;
|
|
|
886
891
|
Returns a modified typed array filled with a fill value.
|
|
887
892
|
|
|
888
893
|
```javascript
|
|
889
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
890
|
-
var realf = require( '@stdlib/complex-
|
|
891
|
-
var imagf = require( '@stdlib/complex-
|
|
894
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
895
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
896
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
892
897
|
|
|
893
898
|
var arr = new Complex64Array( 3 );
|
|
894
899
|
|
|
@@ -959,9 +964,9 @@ im = imagf( z );
|
|
|
959
964
|
When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element.
|
|
960
965
|
|
|
961
966
|
```javascript
|
|
962
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
963
|
-
var realf = require( '@stdlib/complex-
|
|
964
|
-
var imagf = require( '@stdlib/complex-
|
|
967
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
968
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
969
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
965
970
|
|
|
966
971
|
var arr = new Complex64Array( 3 );
|
|
967
972
|
|
|
@@ -994,8 +999,8 @@ im = imagf( z );
|
|
|
994
999
|
Returns a new array containing the elements of an array which pass a test implemented by a predicate function.
|
|
995
1000
|
|
|
996
1001
|
```javascript
|
|
997
|
-
var realf = require( '@stdlib/complex-
|
|
998
|
-
var imagf = require( '@stdlib/complex-
|
|
1002
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1003
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
999
1004
|
|
|
1000
1005
|
function predicate( v ) {
|
|
1001
1006
|
return ( realf( v ) === imagf( v ) );
|
|
@@ -1033,8 +1038,8 @@ The `predicate` function is provided three arguments:
|
|
|
1033
1038
|
To set the function execution context, provide a `thisArg`.
|
|
1034
1039
|
|
|
1035
1040
|
```javascript
|
|
1036
|
-
var realf = require( '@stdlib/complex-
|
|
1037
|
-
var imagf = require( '@stdlib/complex-
|
|
1041
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1042
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1038
1043
|
|
|
1039
1044
|
function predicate( v, i ) {
|
|
1040
1045
|
this.count += 1;
|
|
@@ -1069,9 +1074,9 @@ var count = context.count;
|
|
|
1069
1074
|
Returns the first element in an array for which a predicate function returns a truthy value.
|
|
1070
1075
|
|
|
1071
1076
|
```javascript
|
|
1072
|
-
var realf = require( '@stdlib/complex-
|
|
1073
|
-
var imagf = require( '@stdlib/complex-
|
|
1074
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
1077
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1078
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1079
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
1075
1080
|
|
|
1076
1081
|
function predicate( v ) {
|
|
1077
1082
|
return ( realf( v ) === imagf( v ) );
|
|
@@ -1103,8 +1108,8 @@ The `predicate` function is provided three arguments:
|
|
|
1103
1108
|
To set the function execution context, provide a `thisArg`.
|
|
1104
1109
|
|
|
1105
1110
|
```javascript
|
|
1106
|
-
var realf = require( '@stdlib/complex-
|
|
1107
|
-
var imagf = require( '@stdlib/complex-
|
|
1111
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1112
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1108
1113
|
|
|
1109
1114
|
function predicate( v, i ) {
|
|
1110
1115
|
this.count += 1;
|
|
@@ -1142,8 +1147,8 @@ var count = context.count;
|
|
|
1142
1147
|
Returns the index of the first element in an array for which a predicate function returns a truthy value.
|
|
1143
1148
|
|
|
1144
1149
|
```javascript
|
|
1145
|
-
var realf = require( '@stdlib/complex-
|
|
1146
|
-
var imagf = require( '@stdlib/complex-
|
|
1150
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1151
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1147
1152
|
|
|
1148
1153
|
function predicate( v ) {
|
|
1149
1154
|
return ( realf( v ) === imagf( v ) );
|
|
@@ -1169,8 +1174,8 @@ The `predicate` function is provided three arguments:
|
|
|
1169
1174
|
To set the function execution context, provide a `thisArg`.
|
|
1170
1175
|
|
|
1171
1176
|
```javascript
|
|
1172
|
-
var realf = require( '@stdlib/complex-
|
|
1173
|
-
var imagf = require( '@stdlib/complex-
|
|
1177
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1178
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1174
1179
|
|
|
1175
1180
|
function predicate( v, i ) {
|
|
1176
1181
|
this.count += 1;
|
|
@@ -1202,9 +1207,9 @@ var count = context.count;
|
|
|
1202
1207
|
Returns the last element in an array for which a predicate function returns a truthy value.
|
|
1203
1208
|
|
|
1204
1209
|
```javascript
|
|
1205
|
-
var realf = require( '@stdlib/complex-
|
|
1206
|
-
var imagf = require( '@stdlib/complex-
|
|
1207
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
1210
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1211
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1212
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
1208
1213
|
|
|
1209
1214
|
function predicate( v ) {
|
|
1210
1215
|
return ( realf( v ) === imagf( v ) );
|
|
@@ -1236,8 +1241,8 @@ The `predicate` function is provided three arguments:
|
|
|
1236
1241
|
To set the function execution context, provide a `thisArg`.
|
|
1237
1242
|
|
|
1238
1243
|
```javascript
|
|
1239
|
-
var realf = require( '@stdlib/complex-
|
|
1240
|
-
var imagf = require( '@stdlib/complex-
|
|
1244
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1245
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1241
1246
|
|
|
1242
1247
|
function predicate( v, i ) {
|
|
1243
1248
|
this.count += 1;
|
|
@@ -1275,8 +1280,8 @@ var count = context.count;
|
|
|
1275
1280
|
Returns the index of the last element in an array for which a predicate function returns a truthy value.
|
|
1276
1281
|
|
|
1277
1282
|
```javascript
|
|
1278
|
-
var realf = require( '@stdlib/complex-
|
|
1279
|
-
var imagf = require( '@stdlib/complex-
|
|
1283
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1284
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1280
1285
|
|
|
1281
1286
|
function predicate( v ) {
|
|
1282
1287
|
return ( realf( v ) === imagf( v ) );
|
|
@@ -1302,8 +1307,8 @@ The `predicate` function is provided three arguments:
|
|
|
1302
1307
|
To set the function execution context, provide a `thisArg`.
|
|
1303
1308
|
|
|
1304
1309
|
```javascript
|
|
1305
|
-
var realf = require( '@stdlib/complex-
|
|
1306
|
-
var imagf = require( '@stdlib/complex-
|
|
1310
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1311
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1307
1312
|
|
|
1308
1313
|
function predicate( v, i ) {
|
|
1309
1314
|
this.count += 1;
|
|
@@ -1335,7 +1340,7 @@ var count = context.count;
|
|
|
1335
1340
|
Invokes a function once for each array element.
|
|
1336
1341
|
|
|
1337
1342
|
```javascript
|
|
1338
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
1343
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
1339
1344
|
|
|
1340
1345
|
function log( v, i ) {
|
|
1341
1346
|
console.log( '%s: %s', i, v.toString() );
|
|
@@ -1365,7 +1370,7 @@ The invoked function is provided three arguments:
|
|
|
1365
1370
|
To set the function execution context, provide a `thisArg`.
|
|
1366
1371
|
|
|
1367
1372
|
```javascript
|
|
1368
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
1373
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
1369
1374
|
|
|
1370
1375
|
function fcn( v, i ) {
|
|
1371
1376
|
this.count += 1;
|
|
@@ -1401,8 +1406,8 @@ var count = context.count;
|
|
|
1401
1406
|
Returns an array element located at a nonnegative integer position (index) `i`.
|
|
1402
1407
|
|
|
1403
1408
|
```javascript
|
|
1404
|
-
var realf = require( '@stdlib/complex-
|
|
1405
|
-
var imagf = require( '@stdlib/complex-
|
|
1409
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1410
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1406
1411
|
|
|
1407
1412
|
var arr = new Complex64Array( 10 );
|
|
1408
1413
|
|
|
@@ -1436,7 +1441,7 @@ var z = arr.get( 100 );
|
|
|
1436
1441
|
Returns a boolean indicating whether an array includes a provided value.
|
|
1437
1442
|
|
|
1438
1443
|
```javascript
|
|
1439
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
1444
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
1440
1445
|
|
|
1441
1446
|
var arr = new Complex64Array( 5 );
|
|
1442
1447
|
|
|
@@ -1463,7 +1468,7 @@ bool = arr.includes( new Complex64( 4.0, -4.0 ), -3 );
|
|
|
1463
1468
|
Returns the first index at which a given element can be found.
|
|
1464
1469
|
|
|
1465
1470
|
```javascript
|
|
1466
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
1471
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
1467
1472
|
|
|
1468
1473
|
var arr = new Complex64Array( 5 );
|
|
1469
1474
|
|
|
@@ -1486,7 +1491,7 @@ idx = arr.indexOf( new Complex64( 4.0, -4.0 ), -3 );
|
|
|
1486
1491
|
If `searchElement` is not present in the array, the method returns `-1`.
|
|
1487
1492
|
|
|
1488
1493
|
```javascript
|
|
1489
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
1494
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
1490
1495
|
|
|
1491
1496
|
var arr = new Complex64Array( 10 );
|
|
1492
1497
|
|
|
@@ -1530,6 +1535,35 @@ var str = arr.join( '/' );
|
|
|
1530
1535
|
// returns '1 + 1i/2 - 2i/3 + 3i'
|
|
1531
1536
|
```
|
|
1532
1537
|
|
|
1538
|
+
<a name="method-keys"></a>
|
|
1539
|
+
|
|
1540
|
+
#### Complex64Array.prototype.keys()
|
|
1541
|
+
|
|
1542
|
+
Returns an iterator for iterating over each index key in a typed array.
|
|
1543
|
+
|
|
1544
|
+
```javascript
|
|
1545
|
+
var arr = new Complex64Array( 2 );
|
|
1546
|
+
|
|
1547
|
+
arr.set( [ 1.0, -1.0 ], 0 );
|
|
1548
|
+
arr.set( [ 2.0, -2.0 ], 1 );
|
|
1549
|
+
|
|
1550
|
+
var iter = arr.keys();
|
|
1551
|
+
|
|
1552
|
+
var v = iter.next().value;
|
|
1553
|
+
// returns 0
|
|
1554
|
+
|
|
1555
|
+
v = iter.next().value;
|
|
1556
|
+
// returns 1
|
|
1557
|
+
|
|
1558
|
+
var bool = iter.next().done;
|
|
1559
|
+
// returns true
|
|
1560
|
+
```
|
|
1561
|
+
|
|
1562
|
+
The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties:
|
|
1563
|
+
|
|
1564
|
+
- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished.
|
|
1565
|
+
- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object.
|
|
1566
|
+
|
|
1533
1567
|
<a name="method-last-index-of"></a>
|
|
1534
1568
|
|
|
1535
1569
|
#### Complex64Array.prototype.lastIndexOf( searchElement\[, fromIndex] )
|
|
@@ -1537,7 +1571,7 @@ var str = arr.join( '/' );
|
|
|
1537
1571
|
Returns the last index at which a given element can be found.
|
|
1538
1572
|
|
|
1539
1573
|
```javascript
|
|
1540
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
1574
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
1541
1575
|
|
|
1542
1576
|
var arr = new Complex64Array( 5 );
|
|
1543
1577
|
|
|
@@ -1560,7 +1594,7 @@ idx = arr.lastIndexOf( new Complex64( 4.0, -4.0 ), -1 );
|
|
|
1560
1594
|
If `searchElement` is not present in the array, the method returns `-1`.
|
|
1561
1595
|
|
|
1562
1596
|
```javascript
|
|
1563
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
1597
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
1564
1598
|
|
|
1565
1599
|
var arr = new Complex64Array( 10 );
|
|
1566
1600
|
|
|
@@ -1581,9 +1615,9 @@ idx = arr.lastIndexOf( new Complex64( 2.0, -2.0 ), 0 );
|
|
|
1581
1615
|
Returns a new array with each element being the result of a provided callback function.
|
|
1582
1616
|
|
|
1583
1617
|
```javascript
|
|
1584
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
1585
|
-
var realf = require( '@stdlib/complex-
|
|
1586
|
-
var imagf = require( '@stdlib/complex-
|
|
1618
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
1619
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1620
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1587
1621
|
|
|
1588
1622
|
function scale( v ) {
|
|
1589
1623
|
return new Complex64( 2.0*realf( v ), 2.0*imagf( v ) );
|
|
@@ -1618,9 +1652,9 @@ The callback function is provided three arguments:
|
|
|
1618
1652
|
To set the function execution context, provide a `thisArg`.
|
|
1619
1653
|
|
|
1620
1654
|
```javascript
|
|
1621
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
1622
|
-
var realf = require( '@stdlib/complex-
|
|
1623
|
-
var imagf = require( '@stdlib/complex-
|
|
1655
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
1656
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1657
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1624
1658
|
|
|
1625
1659
|
function scale( v ) {
|
|
1626
1660
|
this.count += 1;
|
|
@@ -1645,6 +1679,114 @@ var count = context.count;
|
|
|
1645
1679
|
// returns 3
|
|
1646
1680
|
```
|
|
1647
1681
|
|
|
1682
|
+
<a name="method-reduce"></a>
|
|
1683
|
+
|
|
1684
|
+
#### Complex64Array.prototype.reduce( reducerFn\[, initialValue] )
|
|
1685
|
+
|
|
1686
|
+
Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.
|
|
1687
|
+
|
|
1688
|
+
```javascript
|
|
1689
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1690
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1691
|
+
var caddf = require( '@stdlib/complex-float32-base-add' );
|
|
1692
|
+
|
|
1693
|
+
var arr = new Complex64Array( 3 );
|
|
1694
|
+
|
|
1695
|
+
arr.set( [ 1.0, 1.0 ], 0 );
|
|
1696
|
+
arr.set( [ 2.0, 2.0 ], 1 );
|
|
1697
|
+
arr.set( [ 3.0, 3.0 ], 2 );
|
|
1698
|
+
|
|
1699
|
+
var z = arr.reduce( caddf );
|
|
1700
|
+
// returns <Complex64>
|
|
1701
|
+
|
|
1702
|
+
var re = realf( z );
|
|
1703
|
+
// returns 6.0
|
|
1704
|
+
|
|
1705
|
+
var im = imagf( z );
|
|
1706
|
+
// returns 6.0
|
|
1707
|
+
```
|
|
1708
|
+
|
|
1709
|
+
The reducer function is provided four arguments:
|
|
1710
|
+
|
|
1711
|
+
- **acc**: accumulated result.
|
|
1712
|
+
- **value**: current array element.
|
|
1713
|
+
- **index**: current array element index.
|
|
1714
|
+
- **arr**: the array on which this method was called.
|
|
1715
|
+
|
|
1716
|
+
By default, the function initializes the accumulated result to the first element in the array and passes the second array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the first array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument.
|
|
1717
|
+
|
|
1718
|
+
```javascript
|
|
1719
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1720
|
+
|
|
1721
|
+
function reducer( acc, v ) {
|
|
1722
|
+
acc += realf( v );
|
|
1723
|
+
return acc;
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
var arr = new Complex64Array( 3 );
|
|
1727
|
+
|
|
1728
|
+
arr.set( [ 1.0, 1.0 ], 0 );
|
|
1729
|
+
arr.set( [ 2.0, 2.0 ], 1 );
|
|
1730
|
+
arr.set( [ 3.0, 3.0 ], 2 );
|
|
1731
|
+
|
|
1732
|
+
var z = arr.reduce( reducer, 0.0 );
|
|
1733
|
+
// returns 6.0
|
|
1734
|
+
```
|
|
1735
|
+
|
|
1736
|
+
<a name="method-reduce-right"></a>
|
|
1737
|
+
|
|
1738
|
+
#### Complex64Array.prototype.reduceRight( reducerFn\[, initialValue] )
|
|
1739
|
+
|
|
1740
|
+
Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion.
|
|
1741
|
+
|
|
1742
|
+
```javascript
|
|
1743
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1744
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1745
|
+
var caddf = require( '@stdlib/complex-float32-base-add' );
|
|
1746
|
+
|
|
1747
|
+
var arr = new Complex64Array( 3 );
|
|
1748
|
+
|
|
1749
|
+
arr.set( [ 1.0, 1.0 ], 0 );
|
|
1750
|
+
arr.set( [ 2.0, 2.0 ], 1 );
|
|
1751
|
+
arr.set( [ 3.0, 3.0 ], 2 );
|
|
1752
|
+
|
|
1753
|
+
var z = arr.reduceRight( caddf );
|
|
1754
|
+
// returns <Complex64>
|
|
1755
|
+
|
|
1756
|
+
var re = realf( z );
|
|
1757
|
+
// returns 6.0
|
|
1758
|
+
|
|
1759
|
+
var im = imagf( z );
|
|
1760
|
+
// returns 6.0
|
|
1761
|
+
```
|
|
1762
|
+
|
|
1763
|
+
The reducer function is provided four arguments:
|
|
1764
|
+
|
|
1765
|
+
- **acc**: accumulated result.
|
|
1766
|
+
- **value**: current array element.
|
|
1767
|
+
- **index**: current array element index.
|
|
1768
|
+
- **arr**: the array on which this method was called.
|
|
1769
|
+
|
|
1770
|
+
By default, the function initializes the accumulated result to the last element in the array and passes the second-last array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the last array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument.
|
|
1771
|
+
|
|
1772
|
+
```javascript
|
|
1773
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1774
|
+
|
|
1775
|
+
function reducer( acc, v ) {
|
|
1776
|
+
acc += realf( v );
|
|
1777
|
+
return acc;
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
var arr = new Complex64Array( 3 );
|
|
1781
|
+
|
|
1782
|
+
arr.set( [ 1.0, 1.0 ], 0 );
|
|
1783
|
+
arr.set( [ 2.0, 2.0 ], 1 );
|
|
1784
|
+
arr.set( [ 3.0, 3.0 ], 2 );
|
|
1785
|
+
|
|
1786
|
+
var z = arr.reduceRight( reducer, 0.0 );
|
|
1787
|
+
// returns 6.0
|
|
1788
|
+
```
|
|
1789
|
+
|
|
1648
1790
|
<a name="method-reverse"></a>
|
|
1649
1791
|
|
|
1650
1792
|
#### Complex64Array.prototype.reverse()
|
|
@@ -1652,8 +1794,8 @@ var count = context.count;
|
|
|
1652
1794
|
Reverses an array in-place.
|
|
1653
1795
|
|
|
1654
1796
|
```javascript
|
|
1655
|
-
var realf = require( '@stdlib/complex-
|
|
1656
|
-
var imagf = require( '@stdlib/complex-
|
|
1797
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1798
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1657
1799
|
|
|
1658
1800
|
var arr = new Complex64Array( 3 );
|
|
1659
1801
|
|
|
@@ -1699,9 +1841,9 @@ im = imagf( z );
|
|
|
1699
1841
|
Sets one or more array elements.
|
|
1700
1842
|
|
|
1701
1843
|
```javascript
|
|
1702
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
1703
|
-
var realf = require( '@stdlib/complex-
|
|
1704
|
-
var imagf = require( '@stdlib/complex-
|
|
1844
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
1845
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1846
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1705
1847
|
|
|
1706
1848
|
var arr = new Complex64Array( 10 );
|
|
1707
1849
|
|
|
@@ -1732,9 +1874,9 @@ im = imagf( z );
|
|
|
1732
1874
|
By default, the method sets array elements starting at position (index) `i = 0`. To set elements starting elsewhere in the array, provide an index argument `i`.
|
|
1733
1875
|
|
|
1734
1876
|
```javascript
|
|
1735
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
1736
|
-
var realf = require( '@stdlib/complex-
|
|
1737
|
-
var imagf = require( '@stdlib/complex-
|
|
1877
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
1878
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1879
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1738
1880
|
|
|
1739
1881
|
var arr = new Complex64Array( 10 );
|
|
1740
1882
|
|
|
@@ -1765,9 +1907,9 @@ im = imagf( z );
|
|
|
1765
1907
|
In addition to providing a complex number, to set one or more array elements, provide an array-like object containing either complex numbers
|
|
1766
1908
|
|
|
1767
1909
|
```javascript
|
|
1768
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
1769
|
-
var realf = require( '@stdlib/complex-
|
|
1770
|
-
var imagf = require( '@stdlib/complex-
|
|
1910
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
1911
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1912
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1771
1913
|
|
|
1772
1914
|
var arr = new Complex64Array( 10 );
|
|
1773
1915
|
|
|
@@ -1796,8 +1938,8 @@ or interleaved real and imaginary components
|
|
|
1796
1938
|
|
|
1797
1939
|
```javascript
|
|
1798
1940
|
var Float32Array = require( '@stdlib/array-float32' );
|
|
1799
|
-
var realf = require( '@stdlib/complex-
|
|
1800
|
-
var imagf = require( '@stdlib/complex-
|
|
1941
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1942
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1801
1943
|
|
|
1802
1944
|
var arr = new Complex64Array( 10 );
|
|
1803
1945
|
|
|
@@ -1831,8 +1973,8 @@ A few notes:
|
|
|
1831
1973
|
Copies a portion of a typed array to a new typed array.
|
|
1832
1974
|
|
|
1833
1975
|
```javascript
|
|
1834
|
-
var realf = require( '@stdlib/complex-
|
|
1835
|
-
var imagf = require( '@stdlib/complex-
|
|
1976
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1977
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1836
1978
|
|
|
1837
1979
|
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
|
|
1838
1980
|
|
|
@@ -1864,8 +2006,8 @@ im = imagf( z );
|
|
|
1864
2006
|
By default, the method returns a typed array beginning with the first array element. To specify an alternative array index at which to begin, provide a `start` index (inclusive).
|
|
1865
2007
|
|
|
1866
2008
|
```javascript
|
|
1867
|
-
var imagf = require( '@stdlib/complex-
|
|
1868
|
-
var realf = require( '@stdlib/complex-
|
|
2009
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
2010
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1869
2011
|
|
|
1870
2012
|
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
|
|
1871
2013
|
|
|
@@ -1888,8 +2030,8 @@ var im = imagf( z );
|
|
|
1888
2030
|
By default, the method returns a typed array which includes all array elements after `start`. To limit the number of array elements after `start`, provide an `end` index (exclusive).
|
|
1889
2031
|
|
|
1890
2032
|
```javascript
|
|
1891
|
-
var realf = require( '@stdlib/complex-
|
|
1892
|
-
var imagf = require( '@stdlib/complex-
|
|
2033
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2034
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1893
2035
|
|
|
1894
2036
|
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
|
|
1895
2037
|
|
|
@@ -1925,8 +2067,8 @@ im = imagf( z );
|
|
|
1925
2067
|
Returns a boolean indicating whether at least one element passes a test.
|
|
1926
2068
|
|
|
1927
2069
|
```javascript
|
|
1928
|
-
var realf = require( '@stdlib/complex-
|
|
1929
|
-
var imagf = require( '@stdlib/complex-
|
|
2070
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2071
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1930
2072
|
|
|
1931
2073
|
function predicate( v ) {
|
|
1932
2074
|
return ( realf( v ) === imagf( v ) );
|
|
@@ -1953,8 +2095,8 @@ The `predicate` function is provided three arguments:
|
|
|
1953
2095
|
To set the function execution context, provide a `thisArg`.
|
|
1954
2096
|
|
|
1955
2097
|
```javascript
|
|
1956
|
-
var realf = require( '@stdlib/complex-
|
|
1957
|
-
var imagf = require( '@stdlib/complex-
|
|
2098
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2099
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1958
2100
|
|
|
1959
2101
|
function predicate( v, i ) {
|
|
1960
2102
|
this.count += 1;
|
|
@@ -1979,6 +2121,90 @@ var count = context.count;
|
|
|
1979
2121
|
// returns 2
|
|
1980
2122
|
```
|
|
1981
2123
|
|
|
2124
|
+
<a name="method-sort"></a>
|
|
2125
|
+
|
|
2126
|
+
#### Complex64Array.prototype.sort( compareFcn )
|
|
2127
|
+
|
|
2128
|
+
Sorts an array in-place.
|
|
2129
|
+
|
|
2130
|
+
```javascript
|
|
2131
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2132
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
2133
|
+
|
|
2134
|
+
function compare( a, b ) {
|
|
2135
|
+
var re1;
|
|
2136
|
+
var re2;
|
|
2137
|
+
var im1;
|
|
2138
|
+
var im2;
|
|
2139
|
+
re1 = realf( a );
|
|
2140
|
+
re2 = realf( b );
|
|
2141
|
+
if ( re1 < re2 ) {
|
|
2142
|
+
return -1;
|
|
2143
|
+
}
|
|
2144
|
+
if ( re1 > re2 ) {
|
|
2145
|
+
return 1;
|
|
2146
|
+
}
|
|
2147
|
+
im1 = imagf( a );
|
|
2148
|
+
im2 = imagf( b );
|
|
2149
|
+
if ( im1 < im2 ) {
|
|
2150
|
+
return -1;
|
|
2151
|
+
}
|
|
2152
|
+
if ( im1 > im2 ) {
|
|
2153
|
+
return 1;
|
|
2154
|
+
}
|
|
2155
|
+
return 0;
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
var arr = new Complex64Array( 3 );
|
|
2159
|
+
|
|
2160
|
+
arr.set( [ 3.0, -3.0 ], 0 );
|
|
2161
|
+
arr.set( [ 1.0, -1.0 ], 1 );
|
|
2162
|
+
arr.set( [ 2.0, -2.0 ], 2 );
|
|
2163
|
+
|
|
2164
|
+
var out = arr.sort( compare );
|
|
2165
|
+
// returns <Complex64Array>
|
|
2166
|
+
|
|
2167
|
+
var z = out.get( 0 );
|
|
2168
|
+
// returns <Complex64>
|
|
2169
|
+
|
|
2170
|
+
var re = realf( z );
|
|
2171
|
+
// returns 1.0
|
|
2172
|
+
|
|
2173
|
+
var im = imagf( z );
|
|
2174
|
+
// returns -1.0
|
|
2175
|
+
|
|
2176
|
+
z = out.get( 1 );
|
|
2177
|
+
// returns <Complex64>
|
|
2178
|
+
|
|
2179
|
+
re = realf( z );
|
|
2180
|
+
// returns 2.0
|
|
2181
|
+
|
|
2182
|
+
im = imagf( z );
|
|
2183
|
+
// returns -2.0
|
|
2184
|
+
|
|
2185
|
+
z = out.get( 2 );
|
|
2186
|
+
// returns <Complex64>
|
|
2187
|
+
|
|
2188
|
+
re = realf( z );
|
|
2189
|
+
// returns 3.0
|
|
2190
|
+
|
|
2191
|
+
im = imagf( z );
|
|
2192
|
+
// returns -3.0
|
|
2193
|
+
```
|
|
2194
|
+
|
|
2195
|
+
The `compareFcn` determines the order of the elements. The function is called with the following arguments:
|
|
2196
|
+
|
|
2197
|
+
- **a**: the first element for comparison.
|
|
2198
|
+
- **b**: the second element for comparison.
|
|
2199
|
+
|
|
2200
|
+
The function should return a number where:
|
|
2201
|
+
|
|
2202
|
+
- a negative value indicates that `a` should come before `b`.
|
|
2203
|
+
- a positive value indicates that `a` should come after `b`.
|
|
2204
|
+
- zero or `NaN` indicates that `a` and `b` are considered equal.
|
|
2205
|
+
|
|
2206
|
+
In contrast to real numbers, one cannot define a default order relation which is compatible with multiplication. Accordingly, users **must** explicitly provide a `compareFcn` argument and are thus responsible for specifying a complex number ordering.
|
|
2207
|
+
|
|
1982
2208
|
<a name="method-subarray"></a>
|
|
1983
2209
|
|
|
1984
2210
|
#### Complex64Array.prototype.subarray( \[begin\[, end]] )
|
|
@@ -1986,8 +2212,8 @@ var count = context.count;
|
|
|
1986
2212
|
Creates a new typed array view over the same underlying [`ArrayBuffer`][@stdlib/array/buffer] and with the same underlying data type as the host array.
|
|
1987
2213
|
|
|
1988
2214
|
```javascript
|
|
1989
|
-
var realf = require( '@stdlib/complex-
|
|
1990
|
-
var imagf = require( '@stdlib/complex-
|
|
2215
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2216
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1991
2217
|
|
|
1992
2218
|
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
|
|
1993
2219
|
|
|
@@ -2019,8 +2245,8 @@ im = imagf( z );
|
|
|
2019
2245
|
By default, the method creates a typed array view beginning with the first array element. To specify an alternative array index at which to begin, provide a `begin` index (inclusive).
|
|
2020
2246
|
|
|
2021
2247
|
```javascript
|
|
2022
|
-
var imagf = require( '@stdlib/complex-
|
|
2023
|
-
var realf = require( '@stdlib/complex-
|
|
2248
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
2249
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2024
2250
|
|
|
2025
2251
|
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
|
|
2026
2252
|
|
|
@@ -2043,8 +2269,8 @@ var im = imagf( z );
|
|
|
2043
2269
|
By default, the method creates a typed array view which includes all array elements after `begin`. To limit the number of array elements after `begin`, provide an `end` index (exclusive).
|
|
2044
2270
|
|
|
2045
2271
|
```javascript
|
|
2046
|
-
var realf = require( '@stdlib/complex-
|
|
2047
|
-
var imagf = require( '@stdlib/complex-
|
|
2272
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2273
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
2048
2274
|
|
|
2049
2275
|
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
|
|
2050
2276
|
|
|
@@ -2073,6 +2299,27 @@ im = imagf( z );
|
|
|
2073
2299
|
// returns 6.0
|
|
2074
2300
|
```
|
|
2075
2301
|
|
|
2302
|
+
<a name="method-to-locale-string"></a>
|
|
2303
|
+
|
|
2304
|
+
#### Complex64Array.prototype.toLocaleString( \[locales\[, options]] )
|
|
2305
|
+
|
|
2306
|
+
Serializes an array as a locale-specific string.
|
|
2307
|
+
|
|
2308
|
+
```javascript
|
|
2309
|
+
var arr = new Complex64Array( 2 );
|
|
2310
|
+
|
|
2311
|
+
arr.set( [ 1.0, 1.0 ], 0 );
|
|
2312
|
+
arr.set( [ 2.0, 2.0 ], 1 );
|
|
2313
|
+
|
|
2314
|
+
var str = arr.toLocaleString();
|
|
2315
|
+
// returns '1 + 1i,2 + 2i'
|
|
2316
|
+
```
|
|
2317
|
+
|
|
2318
|
+
The method supports the following arguments:
|
|
2319
|
+
|
|
2320
|
+
- **locales**: a string with a BCP 47 language tag or an array of such strings.
|
|
2321
|
+
- **options**: configuration properties.
|
|
2322
|
+
|
|
2076
2323
|
<a name="method-to-reversed"></a>
|
|
2077
2324
|
|
|
2078
2325
|
#### Complex64Array.prototype.toReversed()
|
|
@@ -2080,8 +2327,8 @@ im = imagf( z );
|
|
|
2080
2327
|
Returns a new typed array containing the elements in reversed order.
|
|
2081
2328
|
|
|
2082
2329
|
```javascript
|
|
2083
|
-
var realf = require( '@stdlib/complex-
|
|
2084
|
-
var imagf = require( '@stdlib/complex-
|
|
2330
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2331
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
2085
2332
|
|
|
2086
2333
|
var arr = new Complex64Array( 3 );
|
|
2087
2334
|
|
|
@@ -2120,6 +2367,90 @@ im = imagf( z );
|
|
|
2120
2367
|
// returns 1.0
|
|
2121
2368
|
```
|
|
2122
2369
|
|
|
2370
|
+
<a name="method-to-sorted"></a>
|
|
2371
|
+
|
|
2372
|
+
#### Complex64Array.prototype.toSorted( compareFcn )
|
|
2373
|
+
|
|
2374
|
+
Returns a new typed array containing the elements in sorted order.
|
|
2375
|
+
|
|
2376
|
+
```javascript
|
|
2377
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2378
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
2379
|
+
|
|
2380
|
+
function compare( a, b ) {
|
|
2381
|
+
var re1;
|
|
2382
|
+
var re2;
|
|
2383
|
+
var im1;
|
|
2384
|
+
var im2;
|
|
2385
|
+
re1 = realf( a );
|
|
2386
|
+
re2 = realf( b );
|
|
2387
|
+
if ( re1 < re2 ) {
|
|
2388
|
+
return -1;
|
|
2389
|
+
}
|
|
2390
|
+
if ( re1 > re2 ) {
|
|
2391
|
+
return 1;
|
|
2392
|
+
}
|
|
2393
|
+
im1 = imagf( a );
|
|
2394
|
+
im2 = imagf( b );
|
|
2395
|
+
if ( im1 < im2 ) {
|
|
2396
|
+
return -1;
|
|
2397
|
+
}
|
|
2398
|
+
if ( im1 > im2 ) {
|
|
2399
|
+
return 1;
|
|
2400
|
+
}
|
|
2401
|
+
return 0;
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
var arr = new Complex64Array( 3 );
|
|
2405
|
+
|
|
2406
|
+
arr.set( [ 3.0, -3.0 ], 0 );
|
|
2407
|
+
arr.set( [ 1.0, -1.0 ], 1 );
|
|
2408
|
+
arr.set( [ 2.0, -2.0 ], 2 );
|
|
2409
|
+
|
|
2410
|
+
var out = arr.toSorted( compare );
|
|
2411
|
+
// returns <Complex64Array>
|
|
2412
|
+
|
|
2413
|
+
var z = out.get( 0 );
|
|
2414
|
+
// returns <Complex64>
|
|
2415
|
+
|
|
2416
|
+
var re = realf( z );
|
|
2417
|
+
// returns 1.0
|
|
2418
|
+
|
|
2419
|
+
var im = imagf( z );
|
|
2420
|
+
// returns -1.0
|
|
2421
|
+
|
|
2422
|
+
z = out.get( 1 );
|
|
2423
|
+
// returns <Complex64>
|
|
2424
|
+
|
|
2425
|
+
re = realf( z );
|
|
2426
|
+
// returns 2.0
|
|
2427
|
+
|
|
2428
|
+
im = imagf( z );
|
|
2429
|
+
// returns -2.0
|
|
2430
|
+
|
|
2431
|
+
z = out.get( 2 );
|
|
2432
|
+
// returns <Complex64>
|
|
2433
|
+
|
|
2434
|
+
re = realf( z );
|
|
2435
|
+
// returns 3.0
|
|
2436
|
+
|
|
2437
|
+
im = imagf( z );
|
|
2438
|
+
// returns -3.0
|
|
2439
|
+
```
|
|
2440
|
+
|
|
2441
|
+
The `compareFcn` determines the order of the elements. The function is called with the following arguments:
|
|
2442
|
+
|
|
2443
|
+
- **a**: the first element for comparison.
|
|
2444
|
+
- **b**: the second element for comparison.
|
|
2445
|
+
|
|
2446
|
+
The function should return a number where:
|
|
2447
|
+
|
|
2448
|
+
- a negative value indicates that `a` should come before `b`.
|
|
2449
|
+
- a positive value indicates that `a` should come after `b`.
|
|
2450
|
+
- zero or `NaN` indicates that `a` and `b` are considered equal.
|
|
2451
|
+
|
|
2452
|
+
In contrast to real numbers, one cannot define a default order relation which is compatible with multiplication. Accordingly, users **must** explicitly provide a `compareFcn` argument and are thus responsible for specifying a complex number ordering.
|
|
2453
|
+
|
|
2123
2454
|
<a name="method-to-string"></a>
|
|
2124
2455
|
|
|
2125
2456
|
#### Complex64Array.prototype.toString()
|
|
@@ -2137,16 +2468,59 @@ var str = arr.toString();
|
|
|
2137
2468
|
// returns '1 + 1i,2 - 2i,3 + 3i'
|
|
2138
2469
|
```
|
|
2139
2470
|
|
|
2471
|
+
<a name="method-values"></a>
|
|
2472
|
+
|
|
2473
|
+
#### Complex64Array.prototype.values()
|
|
2474
|
+
|
|
2475
|
+
Returns an iterator for iterating over each value in a typed array.
|
|
2476
|
+
|
|
2477
|
+
```javascript
|
|
2478
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2479
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
2480
|
+
var arr = new Complex64Array( 2 );
|
|
2481
|
+
|
|
2482
|
+
arr.set( [ 1.0, -1.0 ], 0 );
|
|
2483
|
+
arr.set( [ 2.0, -2.0 ], 1 );
|
|
2484
|
+
|
|
2485
|
+
var iter = arr.values();
|
|
2486
|
+
|
|
2487
|
+
var v = iter.next().value;
|
|
2488
|
+
// returns <Complex64>
|
|
2489
|
+
|
|
2490
|
+
var re = realf( v );
|
|
2491
|
+
// returns 1.0
|
|
2492
|
+
|
|
2493
|
+
var im = imagf( v );
|
|
2494
|
+
// returns -1.0
|
|
2495
|
+
|
|
2496
|
+
v = iter.next().value;
|
|
2497
|
+
// returns <Complex64>
|
|
2498
|
+
|
|
2499
|
+
re = realf( v );
|
|
2500
|
+
// returns 2.0
|
|
2501
|
+
|
|
2502
|
+
im = imagf( v );
|
|
2503
|
+
// returns -2.0
|
|
2504
|
+
|
|
2505
|
+
var bool = iter.next().done;
|
|
2506
|
+
// returns true
|
|
2507
|
+
```
|
|
2508
|
+
|
|
2509
|
+
The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties:
|
|
2510
|
+
|
|
2511
|
+
- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished.
|
|
2512
|
+
- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object.
|
|
2513
|
+
|
|
2140
2514
|
<a name="method-with"></a>
|
|
2141
2515
|
|
|
2142
|
-
####
|
|
2516
|
+
#### Complex64Array.prototype.with( index, value )
|
|
2143
2517
|
|
|
2144
2518
|
Returns a new typed array with the element at a provided index replaced with a provided value.
|
|
2145
2519
|
|
|
2146
2520
|
```javascript
|
|
2147
|
-
var realf = require( '@stdlib/complex-
|
|
2148
|
-
var imagf = require( '@stdlib/complex-
|
|
2149
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
2521
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2522
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
2523
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
2150
2524
|
|
|
2151
2525
|
var arr = new Complex64Array( 3 );
|
|
2152
2526
|
|
|
@@ -2201,7 +2575,7 @@ var im = imagf( z );
|
|
|
2201
2575
|
<!-- eslint no-undef: "error" -->
|
|
2202
2576
|
|
|
2203
2577
|
```javascript
|
|
2204
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
2578
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
2205
2579
|
var Float32Array = require( '@stdlib/array-float32' );
|
|
2206
2580
|
var logEach = require( '@stdlib/console-log-each' );
|
|
2207
2581
|
var Complex64Array = require( '@stdlib/array-complex64' );
|
|
@@ -2257,7 +2631,7 @@ logEach( '%s', out );
|
|
|
2257
2631
|
|
|
2258
2632
|
- <span class="package-name">[`@stdlib/array-complex128`][@stdlib/array/complex128]</span><span class="delimiter">: </span><span class="description">Complex128Array.</span>
|
|
2259
2633
|
- <span class="package-name">[`@stdlib/complex-cmplx`][@stdlib/complex/cmplx]</span><span class="delimiter">: </span><span class="description">create a complex number.</span>
|
|
2260
|
-
- <span class="package-name">[`@stdlib/complex-float32`][@stdlib/complex/float32]</span><span class="delimiter">: </span><span class="description">64-bit complex number.</span>
|
|
2634
|
+
- <span class="package-name">[`@stdlib/complex-float32/ctor`][@stdlib/complex/float32/ctor]</span><span class="delimiter">: </span><span class="description">64-bit complex number.</span>
|
|
2261
2635
|
|
|
2262
2636
|
</section>
|
|
2263
2637
|
|
|
@@ -2302,8 +2676,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
2302
2676
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/array-complex64.svg
|
|
2303
2677
|
[npm-url]: https://npmjs.org/package/@stdlib/array-complex64
|
|
2304
2678
|
|
|
2305
|
-
[test-image]: https://github.com/stdlib-js/array-complex64/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
2306
|
-
[test-url]: https://github.com/stdlib-js/array-complex64/actions/workflows/test.yml?query=branch:v0.
|
|
2679
|
+
[test-image]: https://github.com/stdlib-js/array-complex64/actions/workflows/test.yml/badge.svg?branch=v0.3.0
|
|
2680
|
+
[test-url]: https://github.com/stdlib-js/array-complex64/actions/workflows/test.yml?query=branch:v0.3.0
|
|
2307
2681
|
|
|
2308
2682
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-complex64/main.svg
|
|
2309
2683
|
[coverage-url]: https://codecov.io/github/stdlib-js/array-complex64?branch=main
|
|
@@ -2335,11 +2709,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
2335
2709
|
|
|
2336
2710
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-complex64/main/LICENSE
|
|
2337
2711
|
|
|
2712
|
+
[mdn-iterator-protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol
|
|
2713
|
+
|
|
2338
2714
|
[@stdlib/array/typed]: https://www.npmjs.com/package/@stdlib/array-typed
|
|
2339
2715
|
|
|
2340
2716
|
[@stdlib/array/buffer]: https://www.npmjs.com/package/@stdlib/array-buffer
|
|
2341
2717
|
|
|
2342
|
-
[@stdlib/complex/float32]: https://www.npmjs.com/package/@stdlib/complex-float32
|
|
2718
|
+
[@stdlib/complex/float32/ctor]: https://www.npmjs.com/package/@stdlib/complex-float32-ctor
|
|
2343
2719
|
|
|
2344
2720
|
<!-- <related-links> -->
|
|
2345
2721
|
|