-
-
Notifications
You must be signed in to change notification settings - Fork 400
/
index.d.ts
582 lines (550 loc) · 14.3 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
/*
* @license Apache-2.0
*
* Copyright (c) 2021 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// TypeScript Version: 2.0
/* tslint:disable:max-line-length */
/* tslint:disable:max-file-line-count */
import isEvenInt32 = require( '@stdlib/math/base/assert/int32-is-even' );
import isOddInt32 = require( '@stdlib/math/base/assert/int32-is-odd' );
import isComposite = require( '@stdlib/math/base/assert/is-composite' );
import isCoprime = require( '@stdlib/math/base/assert/is-coprime' );
import isEven = require( '@stdlib/math/base/assert/is-even' );
import isFinite = require( '@stdlib/math/base/assert/is-finite' );
import isFinitef = require( '@stdlib/math/base/assert/is-finitef' );
import isInfinite = require( '@stdlib/math/base/assert/is-infinite' );
import isInfinitef = require( '@stdlib/math/base/assert/is-infinitef' );
import isInteger = require( '@stdlib/math/base/assert/is-integer' );
import isnan = require( '@stdlib/math/base/assert/is-nan' );
import isnanf = require( '@stdlib/math/base/assert/is-nanf' );
import isNegativeInteger = require( '@stdlib/math/base/assert/is-negative-integer' );
import isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' );
import isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' );
import isNonNegativeInteger = require( '@stdlib/math/base/assert/is-nonnegative-integer' );
import isNonPositiveInteger = require( '@stdlib/math/base/assert/is-nonpositive-integer' );
import isOdd = require( '@stdlib/math/base/assert/is-odd' );
import isPositiveInteger = require( '@stdlib/math/base/assert/is-positive-integer' );
import isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
import isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-zerof' );
import isPrime = require( '@stdlib/math/base/assert/is-prime' );
import isProbability = require( '@stdlib/math/base/assert/is-probability' );
import isSafeInteger = require( '@stdlib/math/base/assert/is-safe-integer' );
import isPow2Uint32 = require( '@stdlib/math/base/assert/uint32-is-pow2' );
/**
* Interface describing the `assert` namespace.
*/
interface Namespace {
/**
* Tests if a 32-bit integer is even.
*
* @param x - value to test
* @returns boolean indicating whether the value is even
*
* @example
* var bool = ns.isEvenInt32( 5 );
* // returns false
*
* @example
* var bool = ns.isEvenInt32( -2 );
* // returns true
*
* @example
* var bool = ns.isEvenInt32( 0 );
* // returns true
*/
isEvenInt32: typeof isEvenInt32;
/**
* Tests if a 32-bit integer is odd.
*
* @param x - value to test
* @returns boolean indicating whether the value is odd
*
* @example
* var bool = ns.isOddInt32( 5 );
* // returns true
*
* @example
* var bool = ns.isOddInt32( -2 );
* // returns false
*
* @example
* var bool = ns.isOddInt32( 0 );
* // returns false
*/
isOddInt32: typeof isOddInt32;
/**
* Tests if a number is composite.
*
* @param x - value to test
* @returns boolean indicating whether the value is a composite number
*
* @example
* var bool = ns.isComposite( 10.0 );
* // returns true
*
* @example
* var bool = ns.isComposite( 11.0 );
* // returns false
*/
isComposite: typeof isComposite;
/**
* Tests if two numbers are coprime.
*
* @param a - first value
* @param b - second value
* @returns boolean indicating whether the two values are coprime
*
* @example
* var bool = ns.isCoprime( 14.0, 15.0 );
* // returns true
*
* @example
* var bool = ns.isCoprime( 14.0, 21.0 );
* // returns false
*/
isCoprime: typeof isCoprime;
/**
* Tests if a finite numeric value is an even number.
*
* ## Notes
*
* - The function assumes a finite number. If provided positive or negative infinity, the function will return `true`, when, in fact, the result is undefined.
*
* @param x - value to test
* @returns boolean indicating whether the value is an even number
*
* @example
* var bool = ns.isEven( 5.0 );
* // returns false
*
* @example
* var bool = ns.isEven( -2.0 );
* // returns true
*
* @example
* var bool = ns.isEven( 0.0 );
* // returns true
*
* @example
* var bool = ns.isEven( NaN );
* // returns false
*/
isEven: typeof isEven;
/**
* Tests if a double-precision floating-point numeric value is finite.
*
* @param x - value to test
* @returns boolean indicating whether the value is finite
*
* @example
* var bool = ns.isFinite( 5.0 );
* // returns true
*
* @example
* var bool = ns.isFinite( -2.0e64 );
* // returns true
*
* @example
* var bool = ns.isFinite( Infinity );
* // returns false
*
* @example
* var bool = ns.isFinite( -Infinity );
* // returns false
*/
isFinite: typeof isFinite;
/**
* Tests if a single-precision floating-point numeric value is finite.
*
* @param x - value to test
* @returns boolean indicating whether the value is finite
*
* @example
* var bool = ns.isFinitef( 5.0 );
* // returns true
*
* @example
* var bool = ns.isFinitef( -2.0e64 );
* // returns true
*
* @example
* var bool = ns.isFinitef( Infinity );
* // returns false
*
* @example
* var bool = ns.isFinitef( -Infinity );
* // returns false
*/
isFinitef: typeof isFinitef;
/**
* Tests if a double-precision floating-point numeric value is infinite.
*
* @param x - value to test
* @returns boolean indicating whether the value is infinite
*
* @example
* var bool = ns.isInfinite( Infinity );
* // returns true
*
* @example
* var bool = ns.isInfinite( -Infinity );
* // returns true
*
* @example
* var bool = ns.isInfinite( 5.0 );
* // returns false
*
* @example
* var bool = ns.isInfinite( NaN );
* // returns false
*/
isInfinite: typeof isInfinite;
/**
* Tests if a single-precision floating-point numeric value is infinite.
*
* @param x - value to test
* @returns boolean indicating whether the value is infinite
*
* @example
* var bool = ns.isInfinitef( Infinity );
* // returns true
*
* @example
* var bool = ns.isInfinitef( -Infinity );
* // returns true
*
* @example
* var bool = ns.isInfinitef( 5.0 );
* // returns false
*
* @example
* var bool = ns.isInfinitef( NaN );
* // returns false
*/
isInfinitef: typeof isInfinitef;
/**
* Tests if a finite double-precision floating-point number is an integer.
*
* ## Notes
*
* - The function assumes a finite number. If provided positive or negative infinity, the function will return `true`, when, in fact, the result is undefined.
*
* @param x - value to test
* @returns boolean indicating whether the value is an integer
*
* @example
* var bool = ns.isInteger( 1.0 );
* // returns true
*
* @example
* var bool = ns.isInteger( 3.14 );
* // returns false
*/
isInteger: typeof isInteger;
/**
* Tests if a double-precision floating-point numeric value is `NaN`.
*
* @param x - value to test
* @returns boolean indicating whether the value is `NaN`
*
* @example
* var bool = ns.isnan( NaN );
* // returns true
*
* @example
* var bool = ns.isnan( 7.0 );
* // returns false
*/
isnan: typeof isnan;
/**
* Tests if a single-precision floating-point numeric value is `NaN`.
*
* @param x - value to test
* @returns boolean indicating whether the value is `NaN`
*
* @example
* var bool = ns.isnanf( NaN );
* // returns true
*
* @example
* var bool = ns.isnanf( 7.0 );
* // returns false
*/
isnanf: typeof isnanf;
/**
* Tests if a finite double-precision floating-point number is a negative integer.
*
* ## Notes
*
* - The function assumes a finite number. If provided negative infinity, the function will return `true`, when, in fact, the result is undefined.
*
* @param x - value to test
* @returns boolean indicating whether the value is a negative integer
*
* @example
* var bool = ns.isNegativeInteger( -1.0 );
* // returns true
*
* @example
* var bool = ns.isNegativeInteger( 0.0 );
* // returns false
*
* @example
* var bool = ns.isNegativeInteger( 10.0 );
* // returns false
*/
isNegativeInteger: typeof isNegativeInteger;
/**
* Tests if a double-precision floating-point numeric value is negative zero.
*
* @param x - value to test
* @returns boolean indicating whether the value is negative zero
*
* @example
* var bool = ns.isNegativeZero( -0.0 );
* // returns true
*
* @example
* var bool = ns.isNegativeZero( 0.0 );
* // returns false
*/
isNegativeZero: typeof isNegativeZero;
/**
* Tests if a single-precision floating-point numeric value is negative zero.
*
* @param x - value to test
* @returns boolean indicating whether the value is negative zero
*
* @example
* var bool = ns.isNegativeZerof( -0.0 );
* // returns true
*
* @example
* var bool = ns.isNegativeZerof( 0.0 );
* // returns false
*/
isNegativeZerof: typeof isNegativeZerof;
/**
* Tests if a finite double-precision floating-point number is a nonnegative integer.
*
* ## Notes
*
* - The function assumes a finite number. If provided positive infinity, the function will return `true`, when, in fact, the result is undefined.
* - The function does not distinguish between positive and negative zero.
*
* @param x - value to test
* @returns boolean indicating whether the value is a nonnegative integer
*
* @example
* var bool = ns.isNonNegativeInteger( 1.0 );
* // returns true
*
* @example
* var bool = ns.isNonNegativeInteger( 0.0 );
* // returns true
*
* @example
* var bool = ns.isNonNegativeInteger( -10.0 );
* // returns false
*/
isNonNegativeInteger: typeof isNonNegativeInteger;
/**
* Tests if a finite double-precision floating-point number is a nonpositive integer.
*
* ## Notes
*
* - The function assumes a finite number. If provided negative infinity, the function will return `true`, when, in fact, the result is undefined.
* - The function does not distinguish between positive and negative zero.
*
* @param x - value to test
* @returns boolean indicating whether the value is a nonpositive integer
*
* @example
* var bool = ns.isNonPositiveInteger( -1.0 );
* // returns true
*
* @example
* var bool = ns.isNonPositiveInteger( 0.0 );
* // returns true
*
* @example
* var bool = ns.isNonPositiveInteger( 10.0 );
* // returns false
*/
isNonPositiveInteger: typeof isNonPositiveInteger;
/**
* Tests if a finite numeric value is an odd number.
*
* ## Notes
*
* - The function assumes a finite number. If provided positive or negative infinity, the function will return `true`, when, in fact, the result is undefined.
*
* @param x - value to test
* @returns boolean indicating whether the value is an odd number
*
* @example
* var bool = ns.isOdd( 5.0 );
* // returns true
*
* @example
* var bool = ns.isOdd( -2.0 );
* // returns false
*
* @example
* var bool = ns.isOdd( 0.0 );
* // returns false
*
* @example
* var bool = ns.isOdd( NaN );
* // returns false
*/
isOdd: typeof isOdd;
/**
* Tests if a finite double-precision floating-point number is a positive integer.
*
* ## Notes
*
* - The function assumes a finite number. If provided positive infinity, the function will return `true`, when, in fact, the result is undefined.
*
* @param x - value to test
* @returns boolean indicating whether the value is a positive integer
*
* @example
* var bool = ns.isPositiveInteger( 1.0 );
* // returns true
*
* @example
* var bool = ns.isPositiveInteger( 0.0 );
* // returns false
*
* @example
* var bool = ns.isPositiveInteger( -10.0 );
* // returns false
*/
isPositiveInteger: typeof isPositiveInteger;
/**
* Tests if a double-precision floating-point numeric value is positive zero.
*
* @param x - value to test
* @returns boolean indicating whether the value is positive zero
*
* @example
* var bool = ns.isPositiveZero( 0.0 );
* // returns true
*
* @example
* var bool = ns.isPositiveZero( -0.0 );
* // returns false
*/
isPositiveZero: typeof isPositiveZero;
/**
* Tests if a single-precision floating-point numeric value is positive zero.
*
* @param x - value to test
* @returns boolean indicating whether the value is positive zero
*
* @example
* var bool = ns.isPositiveZerof( 0.0 );
* // returns true
*
* @example
* var bool = ns.isPositiveZerof( -0.0 );
* // returns false
*/
isPositiveZerof: typeof isPositiveZerof;
/**
* Tests if a number is prime.
*
* @param x - value to test
* @returns boolean indicating whether the value is a prime number
*
* @example
* var bool = ns.isPrime( 11.0 );
* // returns true
*
* @example
* var bool = ns.isPrime( 3.14 );
* // returns false
*/
isPrime: typeof isPrime;
/**
* Tests if a numeric value is a probability.
*
* ## Notes
*
* - A probability is defined as a numeric value on the closed interval `[0,1]`.
*
* @param x - value to test
* @returns boolean indicating whether the value is a probability
*
* @example
* var bool = ns.isProbability( 0.5 );
* // returns true
*
* @example
* var bool = ns.isProbability( 3.14 );
* // returns false
*
* @example
* var bool = ns.isProbability( NaN );
* // returns false
*/
isProbability: typeof isProbability;
/**
* Tests if a finite double-precision floating-point number is a safe integer.
*
* ## Notes
*
* - An integer valued number is "safe" when the number can be exactly represented as a double-precision floating-point number.
*
* @param x - value to test
* @returns boolean indicating whether the value is a safe integer
*
* @example
* var bool = ns.isSafeInteger( 1.0 );
* // returns true
*
* @example
* var bool = ns.isSafeInteger( 2.0e200 );
* // returns false
*
* @example
* var bool = ns.isSafeInteger( 3.14 );
* // returns false
*/
isSafeInteger: typeof isSafeInteger;
/**
* Tests whether an unsigned integer is a power of 2.
*
* @param x - value to test
* @returns boolean indicating whether a value is a power of 2
*
* @example
* var bool = ns.isPow2Uint32( 2 );
* // returns true
*
* @example
* var bool = ns.isPow2Uint32( 5 );
* // returns false
*/
isPow2Uint32: typeof isPow2Uint32;
}
/**
* Base mathematical assertion utilities.
*/
declare var ns: Namespace;
// EXPORTS //
export = ns;