@@ -1181,6 +1181,76 @@ setReadOnly( Complex64Array.prototype, 'get', function get( idx ) {
1181
1181
return getComplex64 ( this . _buffer , idx ) ;
1182
1182
} ) ;
1183
1183
1184
+ /**
1185
+ * Returns a boolean indicating whether an array includes a provided value.
1186
+ *
1187
+ * @name includes
1188
+ * @memberof Complex64Array.prototype
1189
+ * @type {Function }
1190
+ * @param {Complex64 } searchElement - search element
1191
+ * @param {integer } [fromIndex=0] - starting index (inclusive)
1192
+ * @throws {TypeError } `this` must be a complex number array
1193
+ * @throws {TypeError } first argument must be a complex number
1194
+ * @throws {TypeError } second argument must be an integer
1195
+ * @returns {boolean } boolean indicating whether an array includes a provided value
1196
+ *
1197
+ * @example
1198
+ * var Complex64 = require( '@stdlib/complex/float32' );
1199
+ *
1200
+ * var arr = new Complex64Array( 5 );
1201
+ *
1202
+ * arr.set( [ 1.0, -1.0 ], 0 );
1203
+ * arr.set( [ 2.0, -2.0 ], 1 );
1204
+ * arr.set( [ 3.0, -3.0 ], 2 );
1205
+ * arr.set( [ 4.0, -4.0 ], 3 );
1206
+ * arr.set( [ 5.0, -5.0 ], 4 );
1207
+ *
1208
+ * var bool = arr.includes( new Complex64( 3.0, -3.0 ) );
1209
+ * // returns true
1210
+ *
1211
+ * bool = arr.includes( new Complex64( 3.0, -3.0 ), 3 );
1212
+ * // returns false
1213
+ *
1214
+ * bool = arr.includes( new Complex64( 4.0, -4.0 ), -3 );
1215
+ * // returns true
1216
+ */
1217
+ setReadOnly ( Complex64Array . prototype , 'includes' , function includes ( searchElement , fromIndex ) {
1218
+ var buf ;
1219
+ var idx ;
1220
+ var re ;
1221
+ var im ;
1222
+ var i ;
1223
+ if ( ! isComplexArray ( this ) ) {
1224
+ throw new TypeError ( 'invalid invocation. `this` is not a complex number array.' ) ;
1225
+ }
1226
+ if ( ! isComplexLike ( searchElement ) ) {
1227
+ throw new TypeError ( format ( 'invalid argument. First argument must be a complex number. Value: `%s`.' , searchElement ) ) ;
1228
+ }
1229
+ if ( arguments . length > 1 ) {
1230
+ if ( ! isInteger ( fromIndex ) ) {
1231
+ throw new TypeError ( format ( 'invalid argument. Second argument must be an integer. Value: `%s`.' , fromIndex ) ) ;
1232
+ }
1233
+ if ( fromIndex < 0 ) {
1234
+ fromIndex += this . _length ;
1235
+ if ( fromIndex < 0 ) {
1236
+ fromIndex = 0 ;
1237
+ }
1238
+ }
1239
+ } else {
1240
+ fromIndex = 0 ;
1241
+ }
1242
+ re = realf ( searchElement ) ;
1243
+ im = imagf ( searchElement ) ;
1244
+ buf = this . _buffer ;
1245
+ for ( i = fromIndex ; i < this . _length ; i ++ ) {
1246
+ idx = 2 * i ;
1247
+ if ( re === buf [ idx ] && im === buf [ idx + 1 ] ) {
1248
+ return true ;
1249
+ }
1250
+ }
1251
+ return false ;
1252
+ } ) ;
1253
+
1184
1254
/**
1185
1255
* Returns the first index at which a given element can be found.
1186
1256
*
0 commit comments