@stdlib/array-complex64 0.0.6 → 0.2.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 CHANGED
@@ -18,6 +18,17 @@ limitations under the License.
18
18
 
19
19
  -->
20
20
 
21
+
22
+ <details>
23
+ <summary>
24
+ About stdlib...
25
+ </summary>
26
+ <p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
27
+ <p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
28
+ <p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
29
+ <p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
30
+ </details>
31
+
21
32
  # Complex64Array
22
33
 
23
34
  [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
@@ -526,6 +537,56 @@ len = arr.length;
526
537
  // returns 2
527
538
  ```
528
539
 
540
+ <a name="method-at"></a>
541
+
542
+ #### Complex64Array.prototype.at( i )
543
+
544
+ Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer positions.
545
+
546
+ ```javascript
547
+ var realf = require( '@stdlib/complex-realf' );
548
+ var imagf = require( '@stdlib/complex-imagf' );
549
+
550
+ var arr = new Complex64Array( 10 );
551
+
552
+ // Set the first, second, and last elements:
553
+ arr.set( [ 1.0, -1.0 ], 0 );
554
+ arr.set( [ 2.0, -2.0 ], 1 );
555
+ arr.set( [ 9.0, -9.0 ], 9 );
556
+
557
+ // Get the first element:
558
+ var z = arr.at( 0 );
559
+ // returns <Complex64>
560
+
561
+ var re = realf( z );
562
+ // returns 1.0
563
+
564
+ var im = imagf( z );
565
+ // returns -1.0
566
+
567
+ // Get the last element:
568
+ z = arr.at( -1 );
569
+ // returns <Complex64>
570
+
571
+ re = realf( z );
572
+ // returns 9.0
573
+
574
+ im = imagf( z );
575
+ // returns -9.0
576
+ ```
577
+
578
+ If provided an out-of-bounds index, the method returns `undefined`.
579
+
580
+ ```javascript
581
+ var arr = new Complex64Array( 10 );
582
+
583
+ var z = arr.at( 100 );
584
+ // returns undefined
585
+
586
+ z = arr.at( -100 );
587
+ // returns undefined
588
+ ```
589
+
529
590
  <a name="method-copy-within"></a>
530
591
 
531
592
  #### Complex64Array.prototype.copyWithin( target, start\[, end] )
@@ -760,263 +821,1443 @@ var bool = it.next().done;
760
821
  // returns true
761
822
  ```
762
823
 
763
- <a name="method-get"></a>
824
+ <a name="method-every"></a>
764
825
 
765
- #### Complex64Array.prototype.get( i )
826
+ #### Complex64Array.prototype.every( predicate\[, thisArg] )
766
827
 
767
- Returns an array element located at position (index) `i`.
828
+ Returns a boolean indicating whether all elements pass a test.
768
829
 
769
830
  ```javascript
770
831
  var realf = require( '@stdlib/complex-realf' );
771
832
  var imagf = require( '@stdlib/complex-imagf' );
772
833
 
773
- var arr = new Complex64Array( 10 );
774
-
775
- // Set the first element:
776
- arr.set( [ 1.0, -1.0 ], 0 );
834
+ function predicate( v ) {
835
+ return ( realf( v ) === imagf( v ) );
836
+ }
777
837
 
778
- // Get the first element:
779
- var z = arr.get( 0 );
780
- // returns <Complex64>
838
+ var arr = new Complex64Array( 3 );
781
839
 
782
- var re = realf( z );
783
- // returns 1.0
840
+ // Set the first three elements:
841
+ arr.set( [ 1.0, 1.0 ], 0 );
842
+ arr.set( [ 2.0, 2.0 ], 1 );
843
+ arr.set( [ 3.0, 3.0 ], 2 );
784
844
 
785
- var im = imagf( z );
786
- // returns -1.0
845
+ // Check whether all elements pass a test:
846
+ var z = arr.every( predicate );
847
+ // returns true
787
848
  ```
788
849
 
789
- If provided an out-of-bounds index, the method returns `undefined`.
850
+ The `predicate` function is provided three arguments:
851
+
852
+ - **value**: current array element.
853
+ - **index**: current array element index.
854
+ - **arr**: the array on which this method was called.
855
+
856
+ To set the function execution context, provide a `thisArg`.
790
857
 
791
858
  ```javascript
792
- var arr = new Complex64Array( 10 );
859
+ function predicate( v, i ) {
860
+ this.count += 1;
861
+ return ( i >= 0 );
862
+ }
793
863
 
794
- var z = arr.get( 100 );
795
- // returns undefined
864
+ var arr = new Complex64Array( 3 );
865
+
866
+ var context = {
867
+ 'count': 0
868
+ };
869
+
870
+ // Set the first three elements:
871
+ arr.set( [ 1.0, 1.0 ], 0 );
872
+ arr.set( [ 2.0, 2.0 ], 1 );
873
+ arr.set( [ 3.0, 3.0 ], 2 );
874
+
875
+ var z = arr.every( predicate, context );
876
+ // returns true
877
+
878
+ var count = context.count;
879
+ // returns 3
796
880
  ```
797
881
 
798
- <a name="method-set"></a>
882
+ <a name="method-fill"></a>
799
883
 
800
- #### Complex64Array.prototype.set( z\[, i] )
884
+ #### Complex64Array.prototype.fill( value\[, start\[, end]] )
801
885
 
802
- Sets one or more array elements.
886
+ Returns a modified typed array filled with a fill value.
803
887
 
804
888
  ```javascript
805
889
  var Complex64 = require( '@stdlib/complex-float32' );
806
890
  var realf = require( '@stdlib/complex-realf' );
807
891
  var imagf = require( '@stdlib/complex-imagf' );
808
892
 
809
- var arr = new Complex64Array( 10 );
893
+ var arr = new Complex64Array( 3 );
894
+
895
+ // Set all elements to the same value:
896
+ arr.fill( new Complex64( 1.0, 1.0 ) );
810
897
 
811
- // Get the first element:
812
898
  var z = arr.get( 0 );
813
899
  // returns <Complex64>
814
900
 
815
901
  var re = realf( z );
816
- // returns 0.0
902
+ // returns 1.0
817
903
 
818
904
  var im = imagf( z );
819
- // returns 0.0
820
-
821
- // Set the first element:
822
- arr.set( new Complex64( 1.0, -1.0 ) );
905
+ // returns 1.0
823
906
 
824
- // Get the first element:
825
- z = arr.get( 0 );
907
+ z = arr.get( 2 );
826
908
  // returns <Complex64>
827
909
 
828
910
  re = realf( z );
829
911
  // returns 1.0
830
912
 
831
913
  im = imagf( z );
832
- // returns -1.0
833
- ```
914
+ // returns 1.0
834
915
 
835
- 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`.
916
+ // Fill all elements starting from the second element:
917
+ arr.fill( new Complex64( 2.0, 2.0 ), 1 );
836
918
 
837
- ```javascript
838
- var Complex64 = require( '@stdlib/complex-float32' );
839
- var realf = require( '@stdlib/complex-realf' );
840
- var imagf = require( '@stdlib/complex-imagf' );
919
+ z = arr.get( 1 );
920
+ // returns <Complex64>
841
921
 
842
- var arr = new Complex64Array( 10 );
922
+ re = realf( z );
923
+ // returns 2.0
843
924
 
844
- // Get the fifth element:
845
- var z = arr.get( 4 );
925
+ im = imagf( z );
926
+ // returns 2.0
927
+
928
+ z = arr.get( 2 );
846
929
  // returns <Complex64>
847
930
 
848
- var re = realf( z );
849
- // returns 0.0
931
+ re = realf( z );
932
+ // returns 2.0
850
933
 
851
- var im = imagf( z );
852
- // returns 0.0
934
+ im = imagf( z );
935
+ // returns 2.0
853
936
 
854
- // Set the fifth element:
855
- arr.set( new Complex64( 1.0, -1.0 ), 4 );
937
+ // Fill all elements from first element until the second-to-last element:
938
+ arr.fill( new Complex64( 3.0, 3.0 ), 0, 2 );
856
939
 
857
- // Get the fifth element:
858
- z = arr.get( 4 );
940
+ z = arr.get( 0 );
859
941
  // returns <Complex64>
860
942
 
861
943
  re = realf( z );
862
- // returns 1.0
944
+ // returns 3.0
863
945
 
864
946
  im = imagf( z );
865
- // returns -1.0
947
+ // returns 3.0
948
+
949
+ z = arr.get( 1 );
950
+ // returns <Complex64>
951
+
952
+ re = realf( z );
953
+ // returns 3.0
954
+
955
+ im = imagf( z );
956
+ // returns 3.0
866
957
  ```
867
958
 
868
- In addition to providing a complex number, to set one or more array elements, provide an array-like object containing either complex numbers
959
+ When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element.
869
960
 
870
961
  ```javascript
871
962
  var Complex64 = require( '@stdlib/complex-float32' );
872
963
  var realf = require( '@stdlib/complex-realf' );
873
964
  var imagf = require( '@stdlib/complex-imagf' );
874
965
 
875
- var arr = new Complex64Array( 10 );
876
-
877
- // Define an array of complex numbers:
878
- var buf = [
879
- new Complex64( 1.0, -1.0 ),
880
- new Complex64( 2.0, -2.0 ),
881
- new Complex64( 3.0, -3.0 )
882
- ];
966
+ var arr = new Complex64Array( 3 );
883
967
 
884
- // Set the fifth, sixth, and seventh elements:
885
- arr.set( buf, 4 );
968
+ // Set all array elements, except the last element, to the same value:
969
+ arr.fill( new Complex64( 1.0, 1.0 ), 0, -1 );
886
970
 
887
- // Get the sixth element:
888
- var z = arr.get( 5 );
971
+ var z = arr.get( 0 );
889
972
  // returns <Complex64>
890
973
 
891
974
  var re = realf( z );
892
- // returns 2.0
975
+ // returns 1.0
893
976
 
894
977
  var im = imagf( z );
895
- // returns -2.0
978
+ // returns 1.0
979
+
980
+ z = arr.get( arr.length - 1 );
981
+ // returns <Complex64>
982
+
983
+ re = realf( z );
984
+ // returns 0.0
985
+
986
+ im = imagf( z );
987
+ // returns 0.0
896
988
  ```
897
989
 
898
- or interleaved real and imaginary components
990
+ <a name="method-filter"></a>
991
+
992
+ #### Complex64Array.prototype.filter( predicate\[, thisArg] )
993
+
994
+ Returns a new array containing the elements of an array which pass a test implemented by a predicate function.
899
995
 
900
996
  ```javascript
901
- var Float32Array = require( '@stdlib/array-float32' );
902
997
  var realf = require( '@stdlib/complex-realf' );
903
998
  var imagf = require( '@stdlib/complex-imagf' );
904
999
 
905
- var arr = new Complex64Array( 10 );
1000
+ function predicate( v ) {
1001
+ return ( realf( v ) === imagf( v ) );
1002
+ }
906
1003
 
907
- // Define an interleaved array of real and imaginary components:
908
- var buf = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] );
1004
+ var arr = new Complex64Array( 3 );
909
1005
 
910
- // Set the fifth, sixth, and seventh elements:
911
- arr.set( buf, 4 );
1006
+ // Set the first three elements:
1007
+ arr.set( [ 1.0, -1.0 ], 0 );
1008
+ arr.set( [ 2.0, 2.0 ], 1 );
1009
+ arr.set( [ 3.0, -3.0 ], 2 );
912
1010
 
913
- // Get the sixth element:
914
- var z = arr.get( 5 );
1011
+ var out = arr.filter( predicate );
1012
+ // returns <Complex64Array>
1013
+
1014
+ var len = out.length;
1015
+ // returns 1
1016
+
1017
+ var z = out.get( 0 );
915
1018
  // returns <Complex64>
916
1019
 
917
1020
  var re = realf( z );
918
1021
  // returns 2.0
919
1022
 
920
1023
  var im = imagf( z );
921
- // returns -2.0
1024
+ // returns 2.0
922
1025
  ```
923
1026
 
924
- A few notes:
925
-
926
- - If `i` is out-of-bounds, the method throws an error.
927
- - If a target array cannot accommodate all values (i.e., the length of source array plus `i` exceeds the target array length), the method throws an error.
928
- - If provided a [typed array][@stdlib/array/typed] which shares an [`ArrayBuffer`][@stdlib/array/buffer] with the target array, the method will intelligently copy the source range to the destination range.
929
-
930
- </section>
931
-
932
- <!-- /.usage -->
1027
+ The `predicate` function is provided three arguments:
933
1028
 
934
- <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
1029
+ - **value**: current array element.
1030
+ - **index**: current array element index.
1031
+ - **arr**: the array on which this method was called.
935
1032
 
936
- <section class="notes">
1033
+ To set the function execution context, provide a `thisArg`.
937
1034
 
938
- * * *
1035
+ ```javascript
1036
+ var realf = require( '@stdlib/complex-realf' );
1037
+ var imagf = require( '@stdlib/complex-imagf' );
939
1038
 
940
- ## Notes
1039
+ function predicate( v, i ) {
1040
+ this.count += 1;
1041
+ return ( i >= 0 && realf( v ) === imagf( v ) );
1042
+ }
941
1043
 
942
- - While a `Complex64Array` _strives_ to maintain (but does not **guarantee**) consistency with [typed arrays][@stdlib/array/typed], significant deviations from ECMAScript-defined [typed array][@stdlib/array/typed] behavior are as follows:
1044
+ var arr = new Complex64Array( 3 );
943
1045
 
944
- - The constructor does **not** require the `new` operator.
945
- - The constructor and associated methods support a broader variety of input argument types in order to better accommodate complex number input.
946
- - Accessing array elements using bracket syntax (e.g., `Z[i]`) is **not** supported. Instead, one **must** use the `.get()` method which returns a value compatible with complex number output.
947
- - The `set` method has extended behavior in order to support complex numbers.
1046
+ var context = {
1047
+ 'count': 0
1048
+ };
948
1049
 
949
- </section>
1050
+ // Set the first three elements:
1051
+ arr.set( [ 1.0, -1.0 ], 0 );
1052
+ arr.set( [ 2.0, 2.0 ], 1 );
1053
+ arr.set( [ 3.0, 3.0 ], 2 );
950
1054
 
951
- <!-- /.notes -->
1055
+ var out = arr.filter( predicate, context );
1056
+ // returns <Complex64Array>
952
1057
 
953
- <!-- Package usage examples. -->
1058
+ var len = out.length;
1059
+ // returns 2
954
1060
 
955
- <section class="examples">
1061
+ var count = context.count;
1062
+ // returns 3
1063
+ ```
956
1064
 
957
- * * *
1065
+ <a name="method-find"></a>
958
1066
 
959
- ## Examples
1067
+ #### Complex64Array.prototype.find( predicate\[, thisArg] )
960
1068
 
961
- <!-- eslint no-undef: "error" -->
1069
+ Returns the first element in an array for which a predicate function returns a truthy value.
962
1070
 
963
1071
  ```javascript
1072
+ var realf = require( '@stdlib/complex-realf' );
1073
+ var imagf = require( '@stdlib/complex-imagf' );
964
1074
  var Complex64 = require( '@stdlib/complex-float32' );
965
- var Float32Array = require( '@stdlib/array-float32' );
966
- var Complex64Array = require( '@stdlib/array-complex64' );
967
1075
 
968
- // Create a complex array by specifying a length:
969
- var out = new Complex64Array( 3 );
970
- console.log( out );
1076
+ function predicate( v ) {
1077
+ return ( realf( v ) === imagf( v ) );
1078
+ }
971
1079
 
972
- // Create a complex array from an array of complex numbers:
973
- var arr = [
974
- new Complex64( 1.0, -1.0 ),
975
- new Complex64( -3.14, 3.14 ),
976
- new Complex64( 0.5, 0.5 )
977
- ];
978
- out = new Complex64Array( arr );
979
- console.log( out );
1080
+ var arr = new Complex64Array( 3 );
980
1081
 
981
- // Create a complex array from an interleaved typed array:
982
- arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] );
983
- out = new Complex64Array( arr );
984
- console.log( out );
1082
+ // Set the first three elements:
1083
+ arr.set( [ 1.0, 1.0 ], 0 );
1084
+ arr.set( [ 2.0, 2.0 ], 1 );
1085
+ arr.set( [ 3.0, 3.0 ], 2 );
985
1086
 
986
- // Create a complex array from an array buffer:
987
- arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] );
988
- out = new Complex64Array( arr.buffer );
989
- console.log( out );
1087
+ var z = arr.find( predicate );
1088
+ // returns <Complex64>
990
1089
 
991
- // Create a complex array from an array buffer view:
992
- arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] );
993
- out = new Complex64Array( arr.buffer, 8, 2 );
994
- console.log( out );
1090
+ var re = realf( z );
1091
+ // returns 1.0
1092
+
1093
+ var im = imagf( z );
1094
+ // returns 1.0
995
1095
  ```
996
1096
 
997
- </section>
1097
+ The `predicate` function is provided three arguments:
998
1098
 
999
- <!-- /.examples -->
1099
+ - **value**: current array element.
1100
+ - **index**: current array element index.
1101
+ - **arr**: the array on which this method was called.
1000
1102
 
1001
- <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
1103
+ To set the function execution context, provide a `thisArg`.
1002
1104
 
1003
- <section class="references">
1105
+ ```javascript
1106
+ var realf = require( '@stdlib/complex-realf' );
1107
+ var imagf = require( '@stdlib/complex-imagf' );
1004
1108
 
1005
- </section>
1109
+ function predicate( v, i ) {
1110
+ this.count += 1;
1111
+ return ( i >= 0 && realf( v ) === imagf( v ) );
1112
+ }
1006
1113
 
1007
- <!-- /.references -->
1114
+ var arr = new Complex64Array( 3 );
1008
1115
 
1009
- <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
1116
+ var context = {
1117
+ 'count': 0
1118
+ };
1010
1119
 
1011
- <section class="related">
1120
+ // Set the first three elements:
1121
+ arr.set( [ 1.0, -1.0 ], 0 );
1122
+ arr.set( [ 2.0, 2.0 ], 1 );
1123
+ arr.set( [ 3.0, 3.0 ], 2 );
1124
+
1125
+ var z = arr.find( predicate, context );
1126
+ // returns <Complex64>
1127
+
1128
+ var re = realf( z );
1129
+ // returns 2.0
1130
+
1131
+ var im = imagf( z );
1132
+ // returns 2.0
1133
+
1134
+ var count = context.count;
1135
+ // returns 2
1136
+ ```
1137
+
1138
+ <a name="method-find-index"></a>
1139
+
1140
+ #### Complex64Array.prototype.findIndex( predicate\[, thisArg] )
1141
+
1142
+ Returns the index of the first element in an array for which a predicate function returns a truthy value.
1143
+
1144
+ ```javascript
1145
+ var realf = require( '@stdlib/complex-realf' );
1146
+ var imagf = require( '@stdlib/complex-imagf' );
1147
+
1148
+ function predicate( v ) {
1149
+ return ( realf( v ) === imagf( v ) );
1150
+ }
1151
+
1152
+ var arr = new Complex64Array( 3 );
1153
+
1154
+ // Set the first three elements:
1155
+ arr.set( [ 1.0, -1.0 ], 0 );
1156
+ arr.set( [ 2.0, -2.0 ], 1 );
1157
+ arr.set( [ 3.0, 3.0 ], 2 );
1158
+
1159
+ var idx = arr.findIndex( predicate );
1160
+ // returns 2
1161
+ ```
1162
+
1163
+ The `predicate` function is provided three arguments:
1164
+
1165
+ - **value**: current array element.
1166
+ - **index**: current array element index.
1167
+ - **arr**: the array on which this method was called.
1168
+
1169
+ To set the function execution context, provide a `thisArg`.
1170
+
1171
+ ```javascript
1172
+ var realf = require( '@stdlib/complex-realf' );
1173
+ var imagf = require( '@stdlib/complex-imagf' );
1174
+
1175
+ function predicate( v, i ) {
1176
+ this.count += 1;
1177
+ return ( i >= 0 && realf( v ) === imagf( v ) );
1178
+ }
1179
+
1180
+ var arr = new Complex64Array( 3 );
1181
+
1182
+ var context = {
1183
+ 'count': 0
1184
+ };
1185
+
1186
+ // Set the first three elements:
1187
+ arr.set( [ 1.0, -1.0 ], 0 );
1188
+ arr.set( [ 2.0, -2.0 ], 1 );
1189
+ arr.set( [ 3.0, -3.0 ], 2 );
1190
+
1191
+ var idx = arr.findIndex( predicate, context );
1192
+ // returns -1
1193
+
1194
+ var count = context.count;
1195
+ // returns 3
1196
+ ```
1197
+
1198
+ <a name="method-find-last"></a>
1199
+
1200
+ #### Complex64Array.prototype.findLast( predicate\[, thisArg] )
1201
+
1202
+ Returns the last element in an array for which a predicate function returns a truthy value.
1203
+
1204
+ ```javascript
1205
+ var realf = require( '@stdlib/complex-realf' );
1206
+ var imagf = require( '@stdlib/complex-imagf' );
1207
+ var Complex64 = require( '@stdlib/complex-float32' );
1208
+
1209
+ function predicate( v ) {
1210
+ return ( realf( v ) === imagf( v ) );
1211
+ }
1212
+
1213
+ var arr = new Complex64Array( 3 );
1214
+
1215
+ // Set the first three elements:
1216
+ arr.set( [ 1.0, 1.0 ], 0 );
1217
+ arr.set( [ 2.0, 2.0 ], 1 );
1218
+ arr.set( [ 3.0, 3.0 ], 2 );
1219
+
1220
+ var z = arr.findLast( predicate );
1221
+ // returns <Complex64>
1222
+
1223
+ var re = realf( z );
1224
+ // returns 3.0
1225
+
1226
+ var im = imagf( z );
1227
+ // returns 3.0
1228
+ ```
1229
+
1230
+ The `predicate` function is provided three arguments:
1231
+
1232
+ - **value**: current array element.
1233
+ - **index**: current array element index.
1234
+ - **arr**: the array on which this method was called.
1235
+
1236
+ To set the function execution context, provide a `thisArg`.
1237
+
1238
+ ```javascript
1239
+ var realf = require( '@stdlib/complex-realf' );
1240
+ var imagf = require( '@stdlib/complex-imagf' );
1241
+
1242
+ function predicate( v, i ) {
1243
+ this.count += 1;
1244
+ return ( i >= 0 && realf( v ) === imagf( v ) );
1245
+ }
1246
+
1247
+ var arr = new Complex64Array( 3 );
1248
+
1249
+ var context = {
1250
+ 'count': 0
1251
+ };
1252
+
1253
+ // Set the first three elements:
1254
+ arr.set( [ 1.0, -1.0 ], 0 );
1255
+ arr.set( [ 2.0, 2.0 ], 1 );
1256
+ arr.set( [ 3.0, -3.0 ], 2 );
1257
+
1258
+ var z = arr.findLast( predicate, context );
1259
+ // returns <Complex64>
1260
+
1261
+ var re = realf( z );
1262
+ // returns 2.0
1263
+
1264
+ var im = imagf( z );
1265
+ // returns 2.0
1266
+
1267
+ var count = context.count;
1268
+ // returns 2
1269
+ ```
1270
+
1271
+ <a name="method-find-last-index"></a>
1272
+
1273
+ #### Complex64Array.prototype.findLastIndex( predicate\[, thisArg] )
1274
+
1275
+ Returns the index of the last element in an array for which a predicate function returns a truthy value.
1276
+
1277
+ ```javascript
1278
+ var realf = require( '@stdlib/complex-realf' );
1279
+ var imagf = require( '@stdlib/complex-imagf' );
1280
+
1281
+ function predicate( v ) {
1282
+ return ( realf( v ) === imagf( v ) );
1283
+ }
1284
+
1285
+ var arr = new Complex64Array( 3 );
1286
+
1287
+ // Set the first three elements:
1288
+ arr.set( [ 1.0, 1.0 ], 0 );
1289
+ arr.set( [ 2.0, 2.0 ], 1 );
1290
+ arr.set( [ 3.0, -3.0 ], 2 );
1291
+
1292
+ var idx = arr.findLastIndex( predicate );
1293
+ // returns 1
1294
+ ```
1295
+
1296
+ The `predicate` function is provided three arguments:
1297
+
1298
+ - **value**: current array element.
1299
+ - **index**: current array element index.
1300
+ - **arr**: the array on which this method was called.
1301
+
1302
+ To set the function execution context, provide a `thisArg`.
1303
+
1304
+ ```javascript
1305
+ var realf = require( '@stdlib/complex-realf' );
1306
+ var imagf = require( '@stdlib/complex-imagf' );
1307
+
1308
+ function predicate( v, i ) {
1309
+ this.count += 1;
1310
+ return ( i >= 0 && realf( v ) === imagf( v ) );
1311
+ }
1312
+
1313
+ var arr = new Complex64Array( 3 );
1314
+
1315
+ var context = {
1316
+ 'count': 0
1317
+ };
1318
+
1319
+ // Set the first three elements:
1320
+ arr.set( [ 1.0, -1.0 ], 0 );
1321
+ arr.set( [ 2.0, -2.0 ], 1 );
1322
+ arr.set( [ 3.0, -3.0 ], 2 );
1323
+
1324
+ var idx = arr.findLastIndex( predicate, context );
1325
+ // returns -1
1326
+
1327
+ var count = context.count;
1328
+ // returns 3
1329
+ ```
1330
+
1331
+ <a name="method-for-each"></a>
1332
+
1333
+ #### Complex64Array.prototype.forEach( callbackFn\[, thisArg] )
1334
+
1335
+ Invokes a function once for each array element.
1336
+
1337
+ ```javascript
1338
+ var Complex64 = require( '@stdlib/complex-float32' );
1339
+
1340
+ function log( v, i ) {
1341
+ console.log( '%s: %s', i, v.toString() );
1342
+ }
1343
+
1344
+ var arr = new Complex64Array( 3 );
1345
+
1346
+ // Set the first three elements:
1347
+ arr.set( [ 1.0, 1.0 ], 0 );
1348
+ arr.set( [ 2.0, 2.0 ], 1 );
1349
+ arr.set( [ 3.0, 3.0 ], 2 );
1350
+
1351
+ arr.forEach( log );
1352
+ /* =>
1353
+ 0: 1 + 1i
1354
+ 1: 2 + 2i
1355
+ 2: 3 + 3i
1356
+ */
1357
+ ```
1358
+
1359
+ The invoked function is provided three arguments:
1360
+
1361
+ - **value**: current array element.
1362
+ - **index**: current array element index.
1363
+ - **arr**: the array on which this method was called.
1364
+
1365
+ To set the function execution context, provide a `thisArg`.
1366
+
1367
+ ```javascript
1368
+ var Complex64 = require( '@stdlib/complex-float32' );
1369
+
1370
+ function fcn( v, i ) {
1371
+ this.count += 1;
1372
+ console.log( '%s: %s', i, v.toString() );
1373
+ }
1374
+
1375
+ var arr = new Complex64Array( 3 );
1376
+
1377
+ var context = {
1378
+ 'count': 0
1379
+ };
1380
+
1381
+ // Set the first three elements:
1382
+ arr.set( [ 1.0, -1.0 ], 0 );
1383
+ arr.set( [ 2.0, -2.0 ], 1 );
1384
+ arr.set( [ 3.0, -3.0 ], 2 );
1385
+
1386
+ arr.forEach( fcn, context );
1387
+ /* =>
1388
+ 0: 1 + 1i
1389
+ 1: 2 + 2i
1390
+ 2: 3 + 3i
1391
+ */
1392
+
1393
+ var count = context.count;
1394
+ // returns 3
1395
+ ```
1396
+
1397
+ <a name="method-get"></a>
1398
+
1399
+ #### Complex64Array.prototype.get( i )
1400
+
1401
+ Returns an array element located at a nonnegative integer position (index) `i`.
1402
+
1403
+ ```javascript
1404
+ var realf = require( '@stdlib/complex-realf' );
1405
+ var imagf = require( '@stdlib/complex-imagf' );
1406
+
1407
+ var arr = new Complex64Array( 10 );
1408
+
1409
+ // Set the first element:
1410
+ arr.set( [ 1.0, -1.0 ], 0 );
1411
+
1412
+ // Get the first element:
1413
+ var z = arr.get( 0 );
1414
+ // returns <Complex64>
1415
+
1416
+ var re = realf( z );
1417
+ // returns 1.0
1418
+
1419
+ var im = imagf( z );
1420
+ // returns -1.0
1421
+ ```
1422
+
1423
+ If provided an out-of-bounds index, the method returns `undefined`.
1424
+
1425
+ ```javascript
1426
+ var arr = new Complex64Array( 10 );
1427
+
1428
+ var z = arr.get( 100 );
1429
+ // returns undefined
1430
+ ```
1431
+
1432
+ <a name="method-includes"></a>
1433
+
1434
+ #### Complex64Array.prototype.includes( searchElement\[, fromIndex] )
1435
+
1436
+ Returns a boolean indicating whether an array includes a provided value.
1437
+
1438
+ ```javascript
1439
+ var Complex64 = require( '@stdlib/complex-float32' );
1440
+
1441
+ var arr = new Complex64Array( 5 );
1442
+
1443
+ arr.set( [ 1.0, -1.0 ], 0 );
1444
+ arr.set( [ 2.0, -2.0 ], 1 );
1445
+ arr.set( [ 3.0, -3.0 ], 2 );
1446
+ arr.set( [ 4.0, -4.0 ], 3 );
1447
+ arr.set( [ 5.0, -5.0 ], 4 );
1448
+
1449
+ var bool = arr.includes( new Complex64( 3.0, -3.0 ) );
1450
+ // returns true
1451
+
1452
+ bool = arr.includes( new Complex64( 3.0, -3.0 ), 3 );
1453
+ // returns false
1454
+
1455
+ bool = arr.includes( new Complex64( 4.0, -4.0 ), -3 );
1456
+ // returns true
1457
+ ```
1458
+
1459
+ <a name="method-index-of"></a>
1460
+
1461
+ #### Complex64Array.prototype.indexOf( searchElement\[, fromIndex] )
1462
+
1463
+ Returns the first index at which a given element can be found.
1464
+
1465
+ ```javascript
1466
+ var Complex64 = require( '@stdlib/complex-float32' );
1467
+
1468
+ var arr = new Complex64Array( 5 );
1469
+
1470
+ arr.set( [ 1.0, -1.0 ], 0 );
1471
+ arr.set( [ 2.0, -2.0 ], 1 );
1472
+ arr.set( [ 3.0, -3.0 ], 2 );
1473
+ arr.set( [ 4.0, -4.0 ], 3 );
1474
+ arr.set( [ 2.0, -2.0 ], 4 );
1475
+
1476
+ var idx = arr.indexOf( new Complex64( 3.0, -3.0 ) );
1477
+ // returns 2
1478
+
1479
+ idx = arr.indexOf( new Complex64( 2.0, -2.0 ), 2 );
1480
+ // returns 4
1481
+
1482
+ idx = arr.indexOf( new Complex64( 4.0, -4.0 ), -3 );
1483
+ // returns 3
1484
+ ```
1485
+
1486
+ If `searchElement` is not present in the array, the method returns `-1`.
1487
+
1488
+ ```javascript
1489
+ var Complex64 = require( '@stdlib/complex-float32' );
1490
+
1491
+ var arr = new Complex64Array( 10 );
1492
+
1493
+ arr.set( [ 1.0, -1.0 ], 0 );
1494
+ arr.set( [ 2.0, -2.0 ], 1 );
1495
+
1496
+ var idx = arr.indexOf( new Complex64( 3.0, -3.0 ) );
1497
+ // returns -1
1498
+
1499
+ idx = arr.indexOf( new Complex64( 1.0, -1.0 ), 1 );
1500
+ // returns -1
1501
+ ```
1502
+
1503
+ <a name="method-join"></a>
1504
+
1505
+ #### Complex64Array.prototype.join( \[separator] )
1506
+
1507
+ Returns a new string by concatenating all array elements.
1508
+
1509
+ ```javascript
1510
+ var arr = new Complex64Array( 3 );
1511
+
1512
+ arr.set( [ 1.0, 1.0 ], 0 );
1513
+ arr.set( [ 2.0, -2.0 ], 1 );
1514
+ arr.set( [ 3.0, 3.0 ], 2 );
1515
+
1516
+ var str = arr.join();
1517
+ // returns '1 + 1i,2 - 2i,3 + 3i'
1518
+ ```
1519
+
1520
+ By default, the method separates serialized array elements with a comma. To use an alternative separator, provide a `separator` string.
1521
+
1522
+ ```javascript
1523
+ var arr = new Complex64Array( 3 );
1524
+
1525
+ arr.set( [ 1.0, 1.0 ], 0 );
1526
+ arr.set( [ 2.0, -2.0 ], 1 );
1527
+ arr.set( [ 3.0, 3.0 ], 2 );
1528
+
1529
+ var str = arr.join( '/' );
1530
+ // returns '1 + 1i/2 - 2i/3 + 3i'
1531
+ ```
1532
+
1533
+ <a name="method-last-index-of"></a>
1534
+
1535
+ #### Complex64Array.prototype.lastIndexOf( searchElement\[, fromIndex] )
1536
+
1537
+ Returns the last index at which a given element can be found.
1538
+
1539
+ ```javascript
1540
+ var Complex64 = require( '@stdlib/complex-float32' );
1541
+
1542
+ var arr = new Complex64Array( 5 );
1543
+
1544
+ arr.set( [ 1.0, -1.0 ], 0 );
1545
+ arr.set( [ 2.0, -2.0 ], 1 );
1546
+ arr.set( [ 3.0, -3.0 ], 2 );
1547
+ arr.set( [ 4.0, -4.0 ], 3 );
1548
+ arr.set( [ 2.0, -2.0 ], 4 );
1549
+
1550
+ var idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ) );
1551
+ // returns 2
1552
+
1553
+ idx = arr.lastIndexOf( new Complex64( 2.0, -2.0 ), 2 );
1554
+ // returns 1
1555
+
1556
+ idx = arr.lastIndexOf( new Complex64( 4.0, -4.0 ), -1 );
1557
+ // returns 3
1558
+ ```
1559
+
1560
+ If `searchElement` is not present in the array, the method returns `-1`.
1561
+
1562
+ ```javascript
1563
+ var Complex64 = require( '@stdlib/complex-float32' );
1564
+
1565
+ var arr = new Complex64Array( 10 );
1566
+
1567
+ arr.set( [ 1.0, -1.0 ], 0 );
1568
+ arr.set( [ 2.0, -2.0 ], 1 );
1569
+
1570
+ var idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ) );
1571
+ // returns -1
1572
+
1573
+ idx = arr.lastIndexOf( new Complex64( 2.0, -2.0 ), 0 );
1574
+ // returns -1
1575
+ ```
1576
+
1577
+ <a name="method-map"></a>
1578
+
1579
+ #### Complex64Array.prototype.map( callbackFn\[, thisArg] )
1580
+
1581
+ Returns a new array with each element being the result of a provided callback function.
1582
+
1583
+ ```javascript
1584
+ var Complex64 = require( '@stdlib/complex-float32' );
1585
+ var realf = require( '@stdlib/complex-realf' );
1586
+ var imagf = require( '@stdlib/complex-imagf' );
1587
+
1588
+ function scale( v ) {
1589
+ return new Complex64( 2.0*realf( v ), 2.0*imagf( v ) );
1590
+ }
1591
+
1592
+ var arr = new Complex64Array( 3 );
1593
+
1594
+ // Set the first three elements:
1595
+ arr.set( [ 1.0, -1.0 ], 0 );
1596
+ arr.set( [ 2.0, -2.0 ], 1 );
1597
+ arr.set( [ 3.0, -3.0 ], 2 );
1598
+
1599
+ var out = arr.map( scale );
1600
+ // returns <Complex64Array>
1601
+
1602
+ var z = out.get( 0 );
1603
+ // returns <complex64>
1604
+
1605
+ var re = realf( z );
1606
+ // returns 2.0
1607
+
1608
+ var im = imagf( z );
1609
+ // returns -2.0
1610
+ ```
1611
+
1612
+ The callback function is provided three arguments:
1613
+
1614
+ - **value**: current array element.
1615
+ - **index**: current array element index.
1616
+ - **arr**: the array on which this method was called.
1617
+
1618
+ To set the function execution context, provide a `thisArg`.
1619
+
1620
+ ```javascript
1621
+ var Complex64 = require( '@stdlib/complex-float32' );
1622
+ var realf = require( '@stdlib/complex-realf' );
1623
+ var imagf = require( '@stdlib/complex-imagf' );
1624
+
1625
+ function scale( v ) {
1626
+ this.count += 1;
1627
+ return new Complex64( 2.0*realf( v ), 2.0*imagf( v ) );
1628
+ }
1629
+
1630
+ var arr = new Complex64Array( 3 );
1631
+
1632
+ var context = {
1633
+ 'count': 0
1634
+ };
1635
+
1636
+ // Set the first three elements:
1637
+ arr.set( [ 1.0, 1.0 ], 0 );
1638
+ arr.set( [ 2.0, 2.0 ], 1 );
1639
+ arr.set( [ 3.0, 3.0 ], 2 );
1640
+
1641
+ var out = arr.map( scale, context );
1642
+ // returns <Complex64Array>
1643
+
1644
+ var count = context.count;
1645
+ // returns 3
1646
+ ```
1647
+
1648
+ <a name="method-reverse"></a>
1649
+
1650
+ #### Complex64Array.prototype.reverse()
1651
+
1652
+ Reverses an array in-place.
1653
+
1654
+ ```javascript
1655
+ var realf = require( '@stdlib/complex-realf' );
1656
+ var imagf = require( '@stdlib/complex-imagf' );
1657
+
1658
+ var arr = new Complex64Array( 3 );
1659
+
1660
+ arr.set( [ 1.0, 1.0 ], 0 );
1661
+ arr.set( [ 2.0, 2.0 ], 1 );
1662
+ arr.set( [ 3.0, 3.0 ], 2 );
1663
+
1664
+ var out = arr.reverse();
1665
+ // returns <Complex64Array>
1666
+
1667
+ var z = out.get( 0 );
1668
+ // returns <Complex64>
1669
+
1670
+ var re = realf( z );
1671
+ // returns 3.0
1672
+
1673
+ var im = imagf( z );
1674
+ // returns 3.0
1675
+
1676
+ z = out.get( 1 );
1677
+ // returns <Complex64>
1678
+
1679
+ re = realf( z );
1680
+ // returns 2.0
1681
+
1682
+ im = imagf( z );
1683
+ // returns 2.0
1684
+
1685
+ z = out.get( 2 );
1686
+ // returns <Complex64>
1687
+
1688
+ re = realf( z );
1689
+ // returns 1.0
1690
+
1691
+ im = imagf( z );
1692
+ // returns 1.0
1693
+ ```
1694
+
1695
+ <a name="method-set"></a>
1696
+
1697
+ #### Complex64Array.prototype.set( z\[, i] )
1698
+
1699
+ Sets one or more array elements.
1700
+
1701
+ ```javascript
1702
+ var Complex64 = require( '@stdlib/complex-float32' );
1703
+ var realf = require( '@stdlib/complex-realf' );
1704
+ var imagf = require( '@stdlib/complex-imagf' );
1705
+
1706
+ var arr = new Complex64Array( 10 );
1707
+
1708
+ // Get the first element:
1709
+ var z = arr.get( 0 );
1710
+ // returns <Complex64>
1711
+
1712
+ var re = realf( z );
1713
+ // returns 0.0
1714
+
1715
+ var im = imagf( z );
1716
+ // returns 0.0
1717
+
1718
+ // Set the first element:
1719
+ arr.set( new Complex64( 1.0, -1.0 ) );
1720
+
1721
+ // Get the first element:
1722
+ z = arr.get( 0 );
1723
+ // returns <Complex64>
1724
+
1725
+ re = realf( z );
1726
+ // returns 1.0
1727
+
1728
+ im = imagf( z );
1729
+ // returns -1.0
1730
+ ```
1731
+
1732
+ 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
+
1734
+ ```javascript
1735
+ var Complex64 = require( '@stdlib/complex-float32' );
1736
+ var realf = require( '@stdlib/complex-realf' );
1737
+ var imagf = require( '@stdlib/complex-imagf' );
1738
+
1739
+ var arr = new Complex64Array( 10 );
1740
+
1741
+ // Get the fifth element:
1742
+ var z = arr.get( 4 );
1743
+ // returns <Complex64>
1744
+
1745
+ var re = realf( z );
1746
+ // returns 0.0
1747
+
1748
+ var im = imagf( z );
1749
+ // returns 0.0
1750
+
1751
+ // Set the fifth element:
1752
+ arr.set( new Complex64( 1.0, -1.0 ), 4 );
1753
+
1754
+ // Get the fifth element:
1755
+ z = arr.get( 4 );
1756
+ // returns <Complex64>
1757
+
1758
+ re = realf( z );
1759
+ // returns 1.0
1760
+
1761
+ im = imagf( z );
1762
+ // returns -1.0
1763
+ ```
1764
+
1765
+ In addition to providing a complex number, to set one or more array elements, provide an array-like object containing either complex numbers
1766
+
1767
+ ```javascript
1768
+ var Complex64 = require( '@stdlib/complex-float32' );
1769
+ var realf = require( '@stdlib/complex-realf' );
1770
+ var imagf = require( '@stdlib/complex-imagf' );
1771
+
1772
+ var arr = new Complex64Array( 10 );
1773
+
1774
+ // Define an array of complex numbers:
1775
+ var buf = [
1776
+ new Complex64( 1.0, -1.0 ),
1777
+ new Complex64( 2.0, -2.0 ),
1778
+ new Complex64( 3.0, -3.0 )
1779
+ ];
1780
+
1781
+ // Set the fifth, sixth, and seventh elements:
1782
+ arr.set( buf, 4 );
1783
+
1784
+ // Get the sixth element:
1785
+ var z = arr.get( 5 );
1786
+ // returns <Complex64>
1787
+
1788
+ var re = realf( z );
1789
+ // returns 2.0
1790
+
1791
+ var im = imagf( z );
1792
+ // returns -2.0
1793
+ ```
1794
+
1795
+ or interleaved real and imaginary components
1796
+
1797
+ ```javascript
1798
+ var Float32Array = require( '@stdlib/array-float32' );
1799
+ var realf = require( '@stdlib/complex-realf' );
1800
+ var imagf = require( '@stdlib/complex-imagf' );
1801
+
1802
+ var arr = new Complex64Array( 10 );
1803
+
1804
+ // Define an interleaved array of real and imaginary components:
1805
+ var buf = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] );
1806
+
1807
+ // Set the fifth, sixth, and seventh elements:
1808
+ arr.set( buf, 4 );
1809
+
1810
+ // Get the sixth element:
1811
+ var z = arr.get( 5 );
1812
+ // returns <Complex64>
1813
+
1814
+ var re = realf( z );
1815
+ // returns 2.0
1816
+
1817
+ var im = imagf( z );
1818
+ // returns -2.0
1819
+ ```
1820
+
1821
+ A few notes:
1822
+
1823
+ - If `i` is out-of-bounds, the method throws an error.
1824
+ - If a target array cannot accommodate all values (i.e., the length of source array plus `i` exceeds the target array length), the method throws an error.
1825
+ - If provided a [typed array][@stdlib/array/typed] which shares an [`ArrayBuffer`][@stdlib/array/buffer] with the target array, the method will intelligently copy the source range to the destination range.
1826
+
1827
+ <a name="method-slice"></a>
1828
+
1829
+ #### Complex64Array.prototype.slice( \[start\[, end]] )
1830
+
1831
+ Copies a portion of a typed array to a new typed array.
1832
+
1833
+ ```javascript
1834
+ var realf = require( '@stdlib/complex-realf' );
1835
+ var imagf = require( '@stdlib/complex-imagf' );
1836
+
1837
+ var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
1838
+
1839
+ var out = arr.slice();
1840
+ // returns <Complex64Array>
1841
+
1842
+ var len = out.length;
1843
+ // returns 4
1844
+
1845
+ var z = out.get( 0 );
1846
+ // returns <Complex64>
1847
+
1848
+ var re = realf( z );
1849
+ // returns 1.0
1850
+
1851
+ var im = imagf( z );
1852
+ // returns 2.0
1853
+
1854
+ z = out.get( len-1 );
1855
+ // returns <Complex64>
1856
+
1857
+ re = realf( z );
1858
+ // returns 7.0
1859
+
1860
+ im = imagf( z );
1861
+ // returns 8.0
1862
+ ```
1863
+
1864
+ 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
+
1866
+ ```javascript
1867
+ var imagf = require( '@stdlib/complex-imagf' );
1868
+ var realf = require( '@stdlib/complex-realf' );
1869
+
1870
+ var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
1871
+
1872
+ var out = arr.slice( 1 );
1873
+ // returns <Complex64Array>
1874
+
1875
+ var len = out.length;
1876
+ // returns 3
1877
+
1878
+ var z = out.get( 0 );
1879
+ // returns <Complex64>
1880
+
1881
+ var re = realf( z );
1882
+ // returns 3.0
1883
+
1884
+ var im = imagf( z );
1885
+ // returns 4.0
1886
+ ```
1887
+
1888
+ 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
+
1890
+ ```javascript
1891
+ var realf = require( '@stdlib/complex-realf' );
1892
+ var imagf = require( '@stdlib/complex-imagf' );
1893
+
1894
+ var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
1895
+
1896
+ var out = arr.slice( 1, -1 );
1897
+ // returns <Complex64Array>
1898
+
1899
+ var len = out.length;
1900
+ // returns 2
1901
+
1902
+ var z = out.get( 0 );
1903
+ // returns <Complex64>
1904
+
1905
+ var re = realf( z );
1906
+ // returns 3.0
1907
+
1908
+ var im = imagf( z );
1909
+ // returns 4.0
1910
+
1911
+ z = out.get( len-1 );
1912
+ // returns <Complex64>
1913
+
1914
+ re = realf( z );
1915
+ // returns 5.0
1916
+
1917
+ im = imagf( z );
1918
+ // returns 6.0
1919
+ ```
1920
+
1921
+ <a name="method-some"></a>
1922
+
1923
+ #### Complex64Array.prototype.some( predicate\[, thisArg] )
1924
+
1925
+ Returns a boolean indicating whether at least one element passes a test.
1926
+
1927
+ ```javascript
1928
+ var realf = require( '@stdlib/complex-realf' );
1929
+ var imagf = require( '@stdlib/complex-imagf' );
1930
+
1931
+ function predicate( v ) {
1932
+ return ( realf( v ) === imagf( v ) );
1933
+ }
1934
+
1935
+ var arr = new Complex64Array( 3 );
1936
+
1937
+ // Set the first three elements:
1938
+ arr.set( [ 1.0, -1.0 ], 0 );
1939
+ arr.set( [ 2.0, 2.0 ], 1 );
1940
+ arr.set( [ 3.0, -3.0 ], 2 );
1941
+
1942
+ // Check whether at least one element passes a test:
1943
+ var z = arr.some( predicate );
1944
+ // returns true
1945
+ ```
1946
+
1947
+ The `predicate` function is provided three arguments:
1948
+
1949
+ - **value**: current array element.
1950
+ - **index**: current array element index.
1951
+ - **arr**: the array on which this method was called.
1952
+
1953
+ To set the function execution context, provide a `thisArg`.
1954
+
1955
+ ```javascript
1956
+ var realf = require( '@stdlib/complex-realf' );
1957
+ var imagf = require( '@stdlib/complex-imagf' );
1958
+
1959
+ function predicate( v, i ) {
1960
+ this.count += 1;
1961
+ return ( imagf( v ) === realf( v ) );
1962
+ }
1963
+
1964
+ var arr = new Complex64Array( 3 );
1965
+
1966
+ var context = {
1967
+ 'count': 0
1968
+ };
1969
+
1970
+ // Set the first three elements:
1971
+ arr.set( [ 1.0, -1.0 ], 0 );
1972
+ arr.set( [ 2.0, 2.0 ], 1 );
1973
+ arr.set( [ 3.0, -3.0 ], 2 );
1974
+
1975
+ var z = arr.some( predicate, context );
1976
+ // returns true
1977
+
1978
+ var count = context.count;
1979
+ // returns 2
1980
+ ```
1981
+
1982
+ <a name="method-subarray"></a>
1983
+
1984
+ #### Complex64Array.prototype.subarray( \[begin\[, end]] )
1985
+
1986
+ 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
+
1988
+ ```javascript
1989
+ var realf = require( '@stdlib/complex-realf' );
1990
+ var imagf = require( '@stdlib/complex-imagf' );
1991
+
1992
+ var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
1993
+
1994
+ var subarr = arr.subarray();
1995
+ // returns <Complex64Array>
1996
+
1997
+ var len = subarr.length;
1998
+ // returns 4
1999
+
2000
+ var z = subarr.get( 0 );
2001
+ // returns <Complex64>
2002
+
2003
+ var re = realf( z );
2004
+ // returns 1.0
2005
+
2006
+ var im = imagf( z );
2007
+ // returns 2.0
2008
+
2009
+ z = subarr.get( len-1 );
2010
+ // returns <Complex64>
2011
+
2012
+ re = realf( z );
2013
+ // returns 7.0
2014
+
2015
+ im = imagf( z );
2016
+ // returns 8.0
2017
+ ```
2018
+
2019
+ 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
+
2021
+ ```javascript
2022
+ var imagf = require( '@stdlib/complex-imagf' );
2023
+ var realf = require( '@stdlib/complex-realf' );
2024
+
2025
+ var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
2026
+
2027
+ var subarr = arr.subarray( 1 );
2028
+ // returns <Complex64Array>
2029
+
2030
+ var len = subarr.length;
2031
+ // returns 3
2032
+
2033
+ var z = subarr.get( 0 );
2034
+ // returns <Complex64>
2035
+
2036
+ var re = realf( z );
2037
+ // returns 3.0
2038
+
2039
+ var im = imagf( z );
2040
+ // returns 4.0
2041
+ ```
2042
+
2043
+ 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
+
2045
+ ```javascript
2046
+ var realf = require( '@stdlib/complex-realf' );
2047
+ var imagf = require( '@stdlib/complex-imagf' );
2048
+
2049
+ var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
2050
+
2051
+ var subarr = arr.subarray( 1, -1 );
2052
+ // returns <Complex64Array>
2053
+
2054
+ var len = subarr.length;
2055
+ // returns 2
2056
+
2057
+ var z = subarr.get( 0 );
2058
+ // returns <Complex64>
2059
+
2060
+ var re = realf( z );
2061
+ // returns 3.0
2062
+
2063
+ var im = imagf( z );
2064
+ // returns 4.0
2065
+
2066
+ z = subarr.get( len-1 );
2067
+ // returns <Complex64>
2068
+
2069
+ re = realf( z );
2070
+ // returns 5.0
2071
+
2072
+ im = imagf( z );
2073
+ // returns 6.0
2074
+ ```
2075
+
2076
+ <a name="method-to-reversed"></a>
2077
+
2078
+ #### Complex64Array.prototype.toReversed()
2079
+
2080
+ Returns a new typed array containing the elements in reversed order.
2081
+
2082
+ ```javascript
2083
+ var realf = require( '@stdlib/complex-realf' );
2084
+ var imagf = require( '@stdlib/complex-imagf' );
2085
+
2086
+ var arr = new Complex64Array( 3 );
2087
+
2088
+ arr.set( [ 1.0, 1.0 ], 0 );
2089
+ arr.set( [ 2.0, 2.0 ], 1 );
2090
+ arr.set( [ 3.0, 3.0 ], 2 );
2091
+
2092
+ var out = arr.toReversed();
2093
+ // returns <Complex64Array>
2094
+
2095
+ var z = out.get( 0 );
2096
+ // returns <Complex64>
2097
+
2098
+ var re = realf( z );
2099
+ // returns 3.0
2100
+
2101
+ var im = imagf( z );
2102
+ // returns 3.0
2103
+
2104
+ z = out.get( 1 );
2105
+ // returns <Complex64>
2106
+
2107
+ re = realf( z );
2108
+ // returns 2.0
2109
+
2110
+ im = imagf( z );
2111
+ // returns 2.0
2112
+
2113
+ z = out.get( 2 );
2114
+ // returns <Complex64>
2115
+
2116
+ re = realf( z );
2117
+ // returns 1.0
2118
+
2119
+ im = imagf( z );
2120
+ // returns 1.0
2121
+ ```
2122
+
2123
+ <a name="method-to-string"></a>
2124
+
2125
+ #### Complex64Array.prototype.toString()
2126
+
2127
+ Serializes an array as a string.
2128
+
2129
+ ```javascript
2130
+ var arr = new Complex64Array( 3 );
2131
+
2132
+ arr.set( [ 1.0, 1.0 ], 0 );
2133
+ arr.set( [ 2.0, -2.0 ], 1 );
2134
+ arr.set( [ 3.0, 3.0 ], 2 );
2135
+
2136
+ var str = arr.toString();
2137
+ // returns '1 + 1i,2 - 2i,3 + 3i'
2138
+ ```
2139
+
2140
+ <a name="method-with"></a>
2141
+
2142
+ #### Complex128Array.prototype.with( index, value )
2143
+
2144
+ Returns a new typed array with the element at a provided index replaced with a provided value.
2145
+
2146
+ ```javascript
2147
+ var realf = require( '@stdlib/complex-realf' );
2148
+ var imagf = require( '@stdlib/complex-imagf' );
2149
+ var Complex64 = require( '@stdlib/complex-float32' );
2150
+
2151
+ var arr = new Complex64Array( 3 );
2152
+
2153
+ arr.set( [ 1.0, 1.0 ], 0 );
2154
+ arr.set( [ 2.0, 2.0 ], 1 );
2155
+ arr.set( [ 3.0, 3.0 ], 1 );
2156
+
2157
+ var out = arr.with( 0, new Complex64( 4.0, 4.0 ) );
2158
+ // returns <Complex64Array>
2159
+
2160
+ var z = out.get( 0 );
2161
+ // returns <Complex64>
2162
+
2163
+ var re = realf( z );
2164
+ // returns 4.0
2165
+
2166
+ var im = imagf( z );
2167
+ // returns 4.0
2168
+ ```
2169
+
2170
+ </section>
2171
+
2172
+ <!-- /.usage -->
2173
+
2174
+ <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
2175
+
2176
+ <section class="notes">
2177
+
2178
+ * * *
2179
+
2180
+ ## Notes
2181
+
2182
+ - While a `Complex64Array` _strives_ to maintain (but does not **guarantee**) consistency with [typed arrays][@stdlib/array/typed], significant deviations from ECMAScript-defined [typed array][@stdlib/array/typed] behavior are as follows:
2183
+
2184
+ - The constructor does **not** require the `new` operator.
2185
+ - The constructor and associated methods support a broader variety of input argument types in order to better accommodate complex number input.
2186
+ - Accessing array elements using bracket syntax (e.g., `Z[i]`) is **not** supported. Instead, one **must** use the `.get()` method which returns a value compatible with complex number output.
2187
+ - The `set` method has extended behavior in order to support complex numbers.
2188
+
2189
+ </section>
2190
+
2191
+ <!-- /.notes -->
2192
+
2193
+ <!-- Package usage examples. -->
2194
+
2195
+ <section class="examples">
2196
+
2197
+ * * *
2198
+
2199
+ ## Examples
2200
+
2201
+ <!-- eslint no-undef: "error" -->
2202
+
2203
+ ```javascript
2204
+ var Complex64 = require( '@stdlib/complex-float32' );
2205
+ var Float32Array = require( '@stdlib/array-float32' );
2206
+ var logEach = require( '@stdlib/console-log-each' );
2207
+ var Complex64Array = require( '@stdlib/array-complex64' );
2208
+
2209
+ // Create a complex array by specifying a length:
2210
+ var out = new Complex64Array( 3 );
2211
+ logEach( '%s', out );
2212
+
2213
+ // Create a complex array from an array of complex numbers:
2214
+ var arr = [
2215
+ new Complex64( 1.0, -1.0 ),
2216
+ new Complex64( -3.14, 3.14 ),
2217
+ new Complex64( 0.5, 0.5 )
2218
+ ];
2219
+ out = new Complex64Array( arr );
2220
+ logEach( '%s', out );
2221
+
2222
+ // Create a complex array from an interleaved typed array:
2223
+ arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] );
2224
+ out = new Complex64Array( arr );
2225
+ logEach( '%s', out );
2226
+
2227
+ // Create a complex array from an array buffer:
2228
+ arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] );
2229
+ out = new Complex64Array( arr.buffer );
2230
+ logEach( '%s', out );
2231
+
2232
+ // Create a complex array from an array buffer view:
2233
+ arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] );
2234
+ out = new Complex64Array( arr.buffer, 8, 2 );
2235
+ logEach( '%s', out );
2236
+ ```
2237
+
2238
+ </section>
2239
+
2240
+ <!-- /.examples -->
2241
+
2242
+ <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
2243
+
2244
+ <section class="references">
2245
+
2246
+ </section>
2247
+
2248
+ <!-- /.references -->
2249
+
2250
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
2251
+
2252
+ <section class="related">
1012
2253
 
1013
2254
  * * *
1014
2255
 
1015
2256
  ## See Also
1016
2257
 
1017
- - <span class="package-name">[`@stdlib/array/complex128`][@stdlib/array/complex128]</span><span class="delimiter">: </span><span class="description">Complex128Array.</span>
1018
- - <span class="package-name">[`@stdlib/complex/cmplx`][@stdlib/complex/cmplx]</span><span class="delimiter">: </span><span class="description">create a complex number.</span>
1019
- - <span class="package-name">[`@stdlib/complex/float32`][@stdlib/complex/float32]</span><span class="delimiter">: </span><span class="description">64-bit complex number.</span>
2258
+ - <span class="package-name">[`@stdlib/array-complex128`][@stdlib/array/complex128]</span><span class="delimiter">: </span><span class="description">Complex128Array.</span>
2259
+ - <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>
1020
2261
 
1021
2262
  </section>
1022
2263
 
@@ -1048,7 +2289,7 @@ See [LICENSE][stdlib-license].
1048
2289
 
1049
2290
  ## Copyright
1050
2291
 
1051
- Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
2292
+ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
1052
2293
 
1053
2294
  </section>
1054
2295
 
@@ -1061,8 +2302,8 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
1061
2302
  [npm-image]: http://img.shields.io/npm/v/@stdlib/array-complex64.svg
1062
2303
  [npm-url]: https://npmjs.org/package/@stdlib/array-complex64
1063
2304
 
1064
- [test-image]: https://github.com/stdlib-js/array-complex64/actions/workflows/test.yml/badge.svg
1065
- [test-url]: https://github.com/stdlib-js/array-complex64/actions/workflows/test.yml
2305
+ [test-image]: https://github.com/stdlib-js/array-complex64/actions/workflows/test.yml/badge.svg?branch=v0.2.0
2306
+ [test-url]: https://github.com/stdlib-js/array-complex64/actions/workflows/test.yml?query=branch:v0.2.0
1066
2307
 
1067
2308
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-complex64/main.svg
1068
2309
  [coverage-url]: https://codecov.io/github/stdlib-js/array-complex64?branch=main
@@ -1074,19 +2315,23 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
1074
2315
 
1075
2316
  -->
1076
2317
 
2318
+ [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
2319
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
2320
+
2321
+ [stdlib]: https://github.com/stdlib-js/stdlib
2322
+
2323
+ [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
2324
+
1077
2325
  [umd]: https://github.com/umdjs/umd
1078
2326
  [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
1079
2327
 
1080
2328
  [deno-url]: https://github.com/stdlib-js/array-complex64/tree/deno
2329
+ [deno-readme]: https://github.com/stdlib-js/array-complex64/blob/deno/README.md
1081
2330
  [umd-url]: https://github.com/stdlib-js/array-complex64/tree/umd
2331
+ [umd-readme]: https://github.com/stdlib-js/array-complex64/blob/umd/README.md
1082
2332
  [esm-url]: https://github.com/stdlib-js/array-complex64/tree/esm
1083
-
1084
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
1085
- [chat-url]: https://gitter.im/stdlib-js/stdlib/
1086
-
1087
- [stdlib]: https://github.com/stdlib-js/stdlib
1088
-
1089
- [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
2333
+ [esm-readme]: https://github.com/stdlib-js/array-complex64/blob/esm/README.md
2334
+ [branches-url]: https://github.com/stdlib-js/array-complex64/blob/main/branches.md
1090
2335
 
1091
2336
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-complex64/main/LICENSE
1092
2337