@stdlib/array-complex64 0.2.1 → 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 +443 -121
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/docs/types/index.d.ts +325 -53
- 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 +599 -68
- package/package.json +27 -26
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;
|
|
@@ -1652,9 +1686,9 @@ var count = context.count;
|
|
|
1652
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.
|
|
1653
1687
|
|
|
1654
1688
|
```javascript
|
|
1655
|
-
var realf = require( '@stdlib/complex-
|
|
1656
|
-
var imagf = require( '@stdlib/complex-
|
|
1657
|
-
var caddf = require( '@stdlib/
|
|
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' );
|
|
1658
1692
|
|
|
1659
1693
|
var arr = new Complex64Array( 3 );
|
|
1660
1694
|
|
|
@@ -1680,9 +1714,9 @@ The reducer function is provided four arguments:
|
|
|
1680
1714
|
- **arr**: the array on which this method was called.
|
|
1681
1715
|
|
|
1682
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.
|
|
1683
|
-
|
|
1717
|
+
|
|
1684
1718
|
```javascript
|
|
1685
|
-
var realf = require( '@stdlib/complex-
|
|
1719
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1686
1720
|
|
|
1687
1721
|
function reducer( acc, v ) {
|
|
1688
1722
|
acc += realf( v );
|
|
@@ -1699,6 +1733,60 @@ var z = arr.reduce( reducer, 0.0 );
|
|
|
1699
1733
|
// returns 6.0
|
|
1700
1734
|
```
|
|
1701
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
|
+
|
|
1702
1790
|
<a name="method-reverse"></a>
|
|
1703
1791
|
|
|
1704
1792
|
#### Complex64Array.prototype.reverse()
|
|
@@ -1706,8 +1794,8 @@ var z = arr.reduce( reducer, 0.0 );
|
|
|
1706
1794
|
Reverses an array in-place.
|
|
1707
1795
|
|
|
1708
1796
|
```javascript
|
|
1709
|
-
var realf = require( '@stdlib/complex-
|
|
1710
|
-
var imagf = require( '@stdlib/complex-
|
|
1797
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1798
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1711
1799
|
|
|
1712
1800
|
var arr = new Complex64Array( 3 );
|
|
1713
1801
|
|
|
@@ -1753,9 +1841,9 @@ im = imagf( z );
|
|
|
1753
1841
|
Sets one or more array elements.
|
|
1754
1842
|
|
|
1755
1843
|
```javascript
|
|
1756
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
1757
|
-
var realf = require( '@stdlib/complex-
|
|
1758
|
-
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' );
|
|
1759
1847
|
|
|
1760
1848
|
var arr = new Complex64Array( 10 );
|
|
1761
1849
|
|
|
@@ -1786,9 +1874,9 @@ im = imagf( z );
|
|
|
1786
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`.
|
|
1787
1875
|
|
|
1788
1876
|
```javascript
|
|
1789
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
1790
|
-
var realf = require( '@stdlib/complex-
|
|
1791
|
-
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' );
|
|
1792
1880
|
|
|
1793
1881
|
var arr = new Complex64Array( 10 );
|
|
1794
1882
|
|
|
@@ -1819,9 +1907,9 @@ im = imagf( z );
|
|
|
1819
1907
|
In addition to providing a complex number, to set one or more array elements, provide an array-like object containing either complex numbers
|
|
1820
1908
|
|
|
1821
1909
|
```javascript
|
|
1822
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
1823
|
-
var realf = require( '@stdlib/complex-
|
|
1824
|
-
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' );
|
|
1825
1913
|
|
|
1826
1914
|
var arr = new Complex64Array( 10 );
|
|
1827
1915
|
|
|
@@ -1850,8 +1938,8 @@ or interleaved real and imaginary components
|
|
|
1850
1938
|
|
|
1851
1939
|
```javascript
|
|
1852
1940
|
var Float32Array = require( '@stdlib/array-float32' );
|
|
1853
|
-
var realf = require( '@stdlib/complex-
|
|
1854
|
-
var imagf = require( '@stdlib/complex-
|
|
1941
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1942
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1855
1943
|
|
|
1856
1944
|
var arr = new Complex64Array( 10 );
|
|
1857
1945
|
|
|
@@ -1885,8 +1973,8 @@ A few notes:
|
|
|
1885
1973
|
Copies a portion of a typed array to a new typed array.
|
|
1886
1974
|
|
|
1887
1975
|
```javascript
|
|
1888
|
-
var realf = require( '@stdlib/complex-
|
|
1889
|
-
var imagf = require( '@stdlib/complex-
|
|
1976
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1977
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1890
1978
|
|
|
1891
1979
|
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
|
|
1892
1980
|
|
|
@@ -1918,8 +2006,8 @@ im = imagf( z );
|
|
|
1918
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).
|
|
1919
2007
|
|
|
1920
2008
|
```javascript
|
|
1921
|
-
var imagf = require( '@stdlib/complex-
|
|
1922
|
-
var realf = require( '@stdlib/complex-
|
|
2009
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
2010
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
1923
2011
|
|
|
1924
2012
|
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
|
|
1925
2013
|
|
|
@@ -1942,8 +2030,8 @@ var im = imagf( z );
|
|
|
1942
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).
|
|
1943
2031
|
|
|
1944
2032
|
```javascript
|
|
1945
|
-
var realf = require( '@stdlib/complex-
|
|
1946
|
-
var imagf = require( '@stdlib/complex-
|
|
2033
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2034
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1947
2035
|
|
|
1948
2036
|
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
|
|
1949
2037
|
|
|
@@ -1979,8 +2067,8 @@ im = imagf( z );
|
|
|
1979
2067
|
Returns a boolean indicating whether at least one element passes a test.
|
|
1980
2068
|
|
|
1981
2069
|
```javascript
|
|
1982
|
-
var realf = require( '@stdlib/complex-
|
|
1983
|
-
var imagf = require( '@stdlib/complex-
|
|
2070
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2071
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
1984
2072
|
|
|
1985
2073
|
function predicate( v ) {
|
|
1986
2074
|
return ( realf( v ) === imagf( v ) );
|
|
@@ -2007,8 +2095,8 @@ The `predicate` function is provided three arguments:
|
|
|
2007
2095
|
To set the function execution context, provide a `thisArg`.
|
|
2008
2096
|
|
|
2009
2097
|
```javascript
|
|
2010
|
-
var realf = require( '@stdlib/complex-
|
|
2011
|
-
var imagf = require( '@stdlib/complex-
|
|
2098
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2099
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
2012
2100
|
|
|
2013
2101
|
function predicate( v, i ) {
|
|
2014
2102
|
this.count += 1;
|
|
@@ -2033,6 +2121,90 @@ var count = context.count;
|
|
|
2033
2121
|
// returns 2
|
|
2034
2122
|
```
|
|
2035
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
|
+
|
|
2036
2208
|
<a name="method-subarray"></a>
|
|
2037
2209
|
|
|
2038
2210
|
#### Complex64Array.prototype.subarray( \[begin\[, end]] )
|
|
@@ -2040,8 +2212,8 @@ var count = context.count;
|
|
|
2040
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.
|
|
2041
2213
|
|
|
2042
2214
|
```javascript
|
|
2043
|
-
var realf = require( '@stdlib/complex-
|
|
2044
|
-
var imagf = require( '@stdlib/complex-
|
|
2215
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2216
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
2045
2217
|
|
|
2046
2218
|
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
|
|
2047
2219
|
|
|
@@ -2073,8 +2245,8 @@ im = imagf( z );
|
|
|
2073
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).
|
|
2074
2246
|
|
|
2075
2247
|
```javascript
|
|
2076
|
-
var imagf = require( '@stdlib/complex-
|
|
2077
|
-
var realf = require( '@stdlib/complex-
|
|
2248
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
2249
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2078
2250
|
|
|
2079
2251
|
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
|
|
2080
2252
|
|
|
@@ -2097,8 +2269,8 @@ var im = imagf( z );
|
|
|
2097
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).
|
|
2098
2270
|
|
|
2099
2271
|
```javascript
|
|
2100
|
-
var realf = require( '@stdlib/complex-
|
|
2101
|
-
var imagf = require( '@stdlib/complex-
|
|
2272
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2273
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
2102
2274
|
|
|
2103
2275
|
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
|
|
2104
2276
|
|
|
@@ -2127,6 +2299,27 @@ im = imagf( z );
|
|
|
2127
2299
|
// returns 6.0
|
|
2128
2300
|
```
|
|
2129
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
|
+
|
|
2130
2323
|
<a name="method-to-reversed"></a>
|
|
2131
2324
|
|
|
2132
2325
|
#### Complex64Array.prototype.toReversed()
|
|
@@ -2134,8 +2327,8 @@ im = imagf( z );
|
|
|
2134
2327
|
Returns a new typed array containing the elements in reversed order.
|
|
2135
2328
|
|
|
2136
2329
|
```javascript
|
|
2137
|
-
var realf = require( '@stdlib/complex-
|
|
2138
|
-
var imagf = require( '@stdlib/complex-
|
|
2330
|
+
var realf = require( '@stdlib/complex-float32-real' );
|
|
2331
|
+
var imagf = require( '@stdlib/complex-float32-imag' );
|
|
2139
2332
|
|
|
2140
2333
|
var arr = new Complex64Array( 3 );
|
|
2141
2334
|
|
|
@@ -2174,6 +2367,90 @@ im = imagf( z );
|
|
|
2174
2367
|
// returns 1.0
|
|
2175
2368
|
```
|
|
2176
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
|
+
|
|
2177
2454
|
<a name="method-to-string"></a>
|
|
2178
2455
|
|
|
2179
2456
|
#### Complex64Array.prototype.toString()
|
|
@@ -2191,16 +2468,59 @@ var str = arr.toString();
|
|
|
2191
2468
|
// returns '1 + 1i,2 - 2i,3 + 3i'
|
|
2192
2469
|
```
|
|
2193
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
|
+
|
|
2194
2514
|
<a name="method-with"></a>
|
|
2195
2515
|
|
|
2196
|
-
####
|
|
2516
|
+
#### Complex64Array.prototype.with( index, value )
|
|
2197
2517
|
|
|
2198
2518
|
Returns a new typed array with the element at a provided index replaced with a provided value.
|
|
2199
2519
|
|
|
2200
2520
|
```javascript
|
|
2201
|
-
var realf = require( '@stdlib/complex-
|
|
2202
|
-
var imagf = require( '@stdlib/complex-
|
|
2203
|
-
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' );
|
|
2204
2524
|
|
|
2205
2525
|
var arr = new Complex64Array( 3 );
|
|
2206
2526
|
|
|
@@ -2255,7 +2575,7 @@ var im = imagf( z );
|
|
|
2255
2575
|
<!-- eslint no-undef: "error" -->
|
|
2256
2576
|
|
|
2257
2577
|
```javascript
|
|
2258
|
-
var Complex64 = require( '@stdlib/complex-float32' );
|
|
2578
|
+
var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
2259
2579
|
var Float32Array = require( '@stdlib/array-float32' );
|
|
2260
2580
|
var logEach = require( '@stdlib/console-log-each' );
|
|
2261
2581
|
var Complex64Array = require( '@stdlib/array-complex64' );
|
|
@@ -2311,7 +2631,7 @@ logEach( '%s', out );
|
|
|
2311
2631
|
|
|
2312
2632
|
- <span class="package-name">[`@stdlib/array-complex128`][@stdlib/array/complex128]</span><span class="delimiter">: </span><span class="description">Complex128Array.</span>
|
|
2313
2633
|
- <span class="package-name">[`@stdlib/complex-cmplx`][@stdlib/complex/cmplx]</span><span class="delimiter">: </span><span class="description">create a complex number.</span>
|
|
2314
|
-
- <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>
|
|
2315
2635
|
|
|
2316
2636
|
</section>
|
|
2317
2637
|
|
|
@@ -2356,8 +2676,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
2356
2676
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/array-complex64.svg
|
|
2357
2677
|
[npm-url]: https://npmjs.org/package/@stdlib/array-complex64
|
|
2358
2678
|
|
|
2359
|
-
[test-image]: https://github.com/stdlib-js/array-complex64/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
2360
|
-
[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
|
|
2361
2681
|
|
|
2362
2682
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-complex64/main.svg
|
|
2363
2683
|
[coverage-url]: https://codecov.io/github/stdlib-js/array-complex64?branch=main
|
|
@@ -2389,11 +2709,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
2389
2709
|
|
|
2390
2710
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-complex64/main/LICENSE
|
|
2391
2711
|
|
|
2712
|
+
[mdn-iterator-protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol
|
|
2713
|
+
|
|
2392
2714
|
[@stdlib/array/typed]: https://www.npmjs.com/package/@stdlib/array-typed
|
|
2393
2715
|
|
|
2394
2716
|
[@stdlib/array/buffer]: https://www.npmjs.com/package/@stdlib/array-buffer
|
|
2395
2717
|
|
|
2396
|
-
[@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
|
|
2397
2719
|
|
|
2398
2720
|
<!-- <related-links> -->
|
|
2399
2721
|
|