index.d.ts (58829B)
1 /* tslint:disable:max-file-line-count */ 2 3 /* 4 * @license Apache-2.0 5 * 6 * Copyright (c) 2019 The Stdlib Authors. 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 21 // TypeScript Version: 2.0 22 23 /** 24 * Module containing array definitions. 25 * 26 * @example 27 * import * as array from `@stdlib/types/array`; 28 * 29 * const x: array.ArrayLike<number> = [ 1, 2, 3 ]; 30 * 31 * @example 32 * import { ArrayLike } from `@stdlib/types/array`; 33 * 34 * const x: ArrayLike<number> = [ 1, 2, 3 ]; 35 */ 36 declare module '@stdlib/types/array' { 37 import { ComplexLike, Complex64, Complex128 } from '@stdlib/types/object'; 38 39 /** 40 * Data type. 41 */ 42 type DataType = RealOrComplexDataType | 'generic'; 43 44 /** 45 * Data type for real-valued typed arrays. 46 */ 47 type RealDataType = FloatDataType | IntegerDataType; 48 49 /** 50 * Data type for floating-point typed arrays. 51 */ 52 type FloatDataType = 'float64' | 'float32'; 53 54 /** 55 * Data type for integer typed arrays. 56 */ 57 type IntegerDataType = SignedIntegerDataType | UnsignedIntegerDataType; 58 59 /** 60 * Data type for signed integer typed arrays. 61 */ 62 type SignedIntegerDataType = 'int32' | 'int16' | 'int8'; 63 64 /** 65 * Data type for unsigned integer typed arrays. 66 */ 67 type UnsignedIntegerDataType = 'uint32' | 'uint16' | 'uint8' | 'uint8c'; 68 69 /** 70 * Data type for complex number typed arrays. 71 */ 72 type ComplexDataType = 'complex64' | 'complex128'; 73 74 /** 75 * Data type for floating-point real or complex typed arrays. 76 */ 77 type FloatOrComplexDataType = FloatDataType | ComplexDataType; 78 79 /** 80 * Data type for real-valued or complex number typed arrays. 81 */ 82 type RealOrComplexDataType = RealDataType | ComplexDataType; 83 84 /** 85 * An array-like value. 86 * 87 * @example 88 * const x: ArrayLike<number> = [ 1, 2, 3 ]; 89 * const y: ArrayLike<number> = new Float64Array( 10 ); 90 * const z: ArrayLike<string> = 'beep'; 91 */ 92 interface ArrayLike<T> { 93 /** 94 * Numeric properties. 95 */ 96 [key: number]: T; 97 98 /** 99 * Number of elements. 100 */ 101 length: number; 102 } 103 104 /** 105 * An array-like value which exposes accessors for getting and setting array elements. 106 * 107 * @example 108 * const xbuf: Array = [ 1, 2, 3 ]; 109 * const x: AccessorArrayLike<number> = { 110 * 'length': 3, 111 * 'data': xbuf, 112 * 'get': ( i: number ): number => xbuf[ i ], 113 * 'set': ( value: number, i?: number ): void => { 114 * xbuf[ i || 0 ] = value; 115 * return; 116 * } 117 * }; 118 */ 119 interface AccessorArrayLike<T> { 120 /** 121 * Properties. 122 */ 123 [key: string]: any; 124 125 /** 126 * Number of elements. 127 */ 128 length: number; 129 130 /** 131 * Returns an array element. 132 * 133 * @param i - element index 134 * @returns array element 135 */ 136 get( i: number ): T | void; 137 138 /** 139 * Sets an array element. 140 * 141 * @param value - value(s) 142 * @param i - element index at which to start writing values (default: 0) 143 */ 144 set( value: T, i?: number ): void; 145 } 146 147 /** 148 * A numeric array. 149 * 150 * @example 151 * const x: NumericArray = [ 1, 2, 3 ]; 152 * const y: NumericArray = new Float64Array( 10 ); 153 */ 154 type NumericArray = Array<number> | TypedArray; 155 156 /** 157 * Any array. 158 * 159 * @example 160 * const x: AnyArray = [ 1, 2, 3 ]; 161 * const y: AnyArray = new Float64Array( 10 ); 162 */ 163 type AnyArray = Array<any> | RealOrComplexTypedArray; 164 165 /** 166 * An array or typed array. 167 * 168 * @example 169 * const x: ArrayOrTypedArray = [ 1, 2, 3 ]; 170 * const y: ArrayOrTypedArray = new Float64Array( 10 ); 171 */ 172 type ArrayOrTypedArray = Array<any> | TypedArray; 173 174 /** 175 * A typed array. 176 * 177 * ## Notes 178 * 179 * - This is a strict definition of a typed array. Namely, the type is limited to only built-in typed arrays. 180 * 181 * @example 182 * const x: TypedArray = new Float64Array( 10 ); 183 * const y: TypedArray = new Uint32Array( 10 ); 184 */ 185 type TypedArray = FloatTypedArray | IntegerTypedArray; 186 187 /** 188 * A real-valued typed array. 189 * 190 * @example 191 * const x: RealTypedArray = new Float64Array( 10 ); 192 * const y: RealTypedArray = new Uint32Array( 10 ); 193 */ 194 type RealTypedArray = TypedArray; 195 196 /** 197 * An integer typed array. 198 * 199 * @example 200 * const x: IntegerTypedArray = new Uint32Array( 10 ); 201 * const y: IntegerTypedArray = new Int32Array( 10 ); 202 */ 203 type IntegerTypedArray = SignedIntegerTypedArray | UnsignedIntegerTypedArray; // tslint:disable-line:max-line-length 204 205 /** 206 * A signed integer typed array. 207 * 208 * @example 209 * const x: SignedIntegerTypedArray = new Int32Array( 10 ); 210 */ 211 type SignedIntegerTypedArray = Int8Array | Int16Array | Int32Array; 212 213 /** 214 * An unsigned integer typed array. 215 * 216 * @example 217 * const x: UnsignedIntegerTypedArray = new Uint32Array( 10 ); 218 */ 219 type UnsignedIntegerTypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array; // tslint:disable-line:max-line-length 220 221 /** 222 * A floating-point typed array. 223 * 224 * @example 225 * const x: FloatTypedArray = new Float64Array( 10 ); 226 * const y: FloatTypedArray = new Float32Array( 10 ); 227 */ 228 type FloatTypedArray = Float32Array | Float64Array; 229 230 /** 231 * A complex number typed array. 232 * 233 * @example 234 * const x: ComplexTypedArray = new Complex64Array( 10 ); 235 */ 236 type ComplexTypedArray = Complex64Array | Complex128Array; 237 238 /** 239 * A real or complex array. 240 * 241 * @example 242 * const x: RealOrComplexArray = new Float64Array( 10 ); 243 * const y: RealOrComplexArray = [ 1, 2, 3 ]; 244 */ 245 type RealOrComplexArray = NumericArray | ComplexTypedArray; 246 247 /** 248 * A floating-point real or complex typed array. 249 * 250 * @example 251 * const x: FloatOrComplexTypedArray = new Float64Array( 10 ); 252 */ 253 type FloatOrComplexTypedArray = FloatTypedArray | ComplexTypedArray; 254 255 /** 256 * A real or complex typed array. 257 * 258 * @example 259 * const x: RealOrComplexTypedArray = new Float64Array( 10 ); 260 */ 261 type RealOrComplexTypedArray = RealTypedArray | ComplexTypedArray; 262 263 /** 264 * A complex number array-like value. 265 * 266 * @example 267 * const buf = new Float64Array( 8 ); 268 * 269 * const z: ComplexArrayLike = { 270 * 'byteLength': 64, 271 * 'byteOffset': 0, 272 * 'BYTES_PER_ELEMENT': 8, 273 * 'length': 8 274 * 'get': ( i: number ): obj.ComplexLike => { 275 * return { 276 * 're': i * 10, 277 * 'im': i * 10 278 * }; 279 * }, 280 * 'set': ( value: obj.ComplexLike, i?: number ) => { 281 * i = ( i ) ? i : 0; 282 * buf[ i ] = value.re; 283 * buf[ i + 1 ] = value.im; 284 * } 285 * }; 286 */ 287 interface ComplexArrayLike extends AccessorArrayLike<ComplexLike> { 288 /** 289 * Length (in bytes) of the array. 290 */ 291 byteLength: number; 292 293 /** 294 * Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. 295 */ 296 byteOffset: number; 297 298 /** 299 * Size (in bytes) of each array element. 300 */ 301 BYTES_PER_ELEMENT: number; 302 303 /** 304 * Number of array elements. 305 */ 306 length: number; 307 308 /** 309 * Returns an array element. 310 * 311 * @param i - element index 312 * @returns array element 313 */ 314 get( i: number ): ComplexLike | void; 315 316 /** 317 * Sets an array element. 318 * 319 * @param value - value(s) 320 * @param i - element index at which to start writing values (default: 0) 321 */ 322 set( value: ArrayLike<number | ComplexLike> | ComplexArrayLike | ComplexLike, i?: number ): void; // tslint:disable-line:max-line-length 323 } 324 325 /** 326 * 64-bit complex number array. 327 * 328 * @example 329 * const buf = new Float32Array( 8 ); 330 * 331 * const z: Complex64Array = { 332 * 'byteLength': 32, 333 * 'byteOffset': 0, 334 * 'BYTES_PER_ELEMENT': 4, 335 * 'length': 8 336 * 'get': ( i: number ): obj.Complex64 => { 337 * return { 338 * 're': i * 10, 339 * 'im': i * 10, 340 * 'byteLength': 8, 341 * 'BYTES_PER_ELEMENT': 4 342 * }; 343 * }, 344 * 'set': ( value: obj.ComplexLike, i?: number ) => { 345 * i = ( i ) ? i : 0; 346 * buf[ i ] = value.re; 347 * buf[ i + 1 ] = value.im; 348 * } 349 * }; 350 */ 351 interface Complex64Array extends ComplexArrayLike { 352 /** 353 * Returns an array element. 354 * 355 * @param i - element index 356 * @returns array element 357 */ 358 get( i: number ): Complex64 | void; 359 360 /** 361 * Sets an array element. 362 * 363 * @param value - value(s) 364 * @param i - element index at which to start writing values (default: 0) 365 */ 366 set( value: ArrayLike<number | ComplexLike> | Complex64Array | ComplexLike, i?: number ): void; // tslint:disable-line:max-line-length 367 } 368 369 /** 370 * 128-bit complex number array. 371 * 372 * @example 373 * const buf = new Float64Array( 8 ); 374 * 375 * const z: Complex128Array = { 376 * 'byteLength': 64, 377 * 'byteOffset': 0, 378 * 'BYTES_PER_ELEMENT': 8, 379 * 'length': 8 380 * 'get': ( i: number ): obj.Complex128 => { 381 * return { 382 * 're': i * 10, 383 * 'im': i * 10, 384 * 'byteLength': 16, 385 * 'BYTES_PER_ELEMENT': 8 386 * }; 387 * }, 388 * 'set': ( value: obj.ComplexLike, i?: number ) => { 389 * i = ( i ) ? i : 0; 390 * buf[ i ] = value.re; 391 * buf[ i + 1 ] = value.im; 392 * } 393 * }; 394 */ 395 interface Complex128Array extends ComplexArrayLike { 396 /** 397 * Returns an array element. 398 * 399 * @param i - element index 400 * @returns array element 401 */ 402 get( i: number ): Complex128 | void; 403 404 /** 405 * Sets an array element. 406 * 407 * @param value - value(s) 408 * @param i - element index at which to start writing values (default: 0) 409 */ 410 set( value: ArrayLike<number | ComplexLike> | Complex128Array | ComplexLike, i?: number ): void; // tslint:disable-line:max-line-length 411 } 412 } 413 414 /** 415 * Module containing iterator definitions. 416 * 417 * @example 418 * import * as iter from `@stdlib/types/iter`; 419 * 420 * const it: iter.Iterator = { 421 * 'next': () => { return { 'value': 0, 'done': false }; } 422 * }; 423 * 424 * @example 425 * import { Iterator } from `@stdlib/types/iter`; 426 * 427 * const it: Iterator = { 428 * 'next': () => { return { 'value': 0, 'done': false }; } 429 * }; 430 */ 431 declare module '@stdlib/types/iter' { 432 /** 433 * Interface describing an iterator protocol-compliant object. 434 * 435 * @example 436 * const it: Iterator = { 437 * 'next': () => { return { 'value': 0, 'done': false }; } 438 * }; 439 */ 440 interface Iterator { 441 /** 442 * Returns an iterator protocol-compliant object containing the next iterated value (if one exists) and a boolean flag indicating whether the iterator is finished. 443 * 444 * @returns iterator protocol-compliant object 445 */ 446 next(): IteratorResult; 447 448 /** 449 * Finishes an iterator. 450 * 451 * @param value - value to return 452 * @returns iterator protocol-compliant object 453 */ 454 return?( value?: any ): IteratorResult; 455 } 456 457 /** 458 * Interface describing an iterable iterator protocol-compliant object. 459 * 460 * @example 461 * const it: IterableIterator = { 462 * 'next': () => { return { 'value': 0, 'done': false }; }, 463 * [Symbol.iterator]: () => { return this; } 464 * }; 465 */ 466 interface IterableIterator extends Iterator { 467 /** 468 * Returns a new iterable iterator. 469 * 470 * @returns iterable iterator 471 */ 472 [Symbol.iterator](): IterableIterator; 473 } 474 475 /** 476 * Interface describing an iterator protocol-compliant results object. 477 * 478 * @example 479 * const o: IteratorResult = { 480 * 'value': 3.14, 481 * 'done': false 482 * }; 483 */ 484 interface IteratorResult { 485 /** 486 * Iterated value (if one exists). 487 */ 488 value?: any; 489 490 /** 491 * Boolean flag indicating whether an iterator is finished. 492 */ 493 done: boolean; 494 } 495 496 /** 497 * Interface describing an iterator protocol-compliant object. 498 * 499 * @example 500 * const it: TypedIterator<number> = { 501 * 'next': () => { return { 'value': 0, 'done': false }; } 502 * }; 503 */ 504 interface TypedIterator<T> { 505 /** 506 * Returns an iterator protocol-compliant object containing the next iterated value (if one exists) and a boolean flag indicating whether the iterator is finished. 507 * 508 * @returns iterator protocol-compliant object 509 */ 510 next(): TypedIteratorResult<T>; 511 512 /** 513 * Finishes an iterator. 514 * 515 * @param value - value to return 516 * @returns iterator protocol-compliant object 517 */ 518 return?( value?: T ): TypedIteratorResult<T>; 519 } 520 521 /** 522 * Interface describing an iterable iterator protocol-compliant object. 523 * 524 * @example 525 * const it: IterableIterator = { 526 * 'next': () => { return { 'value': 0, 'done': false }; }, 527 * [Symbol.iterator]: () => { return this; } 528 * }; 529 */ 530 interface TypedIterableIterator<T> extends TypedIterator<T> { 531 /** 532 * Returns a new iterable iterator. 533 * 534 * @returns iterable iterator 535 */ 536 [Symbol.iterator](): TypedIterableIterator<T>; 537 } 538 539 /** 540 * Interface describing an iterator protocol-compliant results object. 541 * 542 * @example 543 * const o: TypedIteratorResult<number> = { 544 * 'value': 3.14, 545 * 'done': false 546 * }; 547 */ 548 interface TypedIteratorResult<T> { 549 /** 550 * Iterated value (if one exists). 551 */ 552 value?: T; 553 554 /** 555 * Boolean flag indicating whether an iterator is finished. 556 */ 557 done: boolean; 558 } 559 } 560 561 /** 562 * Module containing ndarray definitions. 563 * 564 * @example 565 * import * as ndarray from `@stdlib/types/ndarray`; 566 * 567 * const arr: ndarray.ndarray = { 568 * 'byteLength': null, 569 * 'BYTES_PER_ELEMENT': null, 570 * 'data': [ 1, 2, 3 ], 571 * 'dtype': 'generic', 572 * 'flags': { 573 * 'ROW_MAJOR_CONTIGUOUS': true, 574 * 'COLUMN_MAJOR_CONTIGUOUS': false 575 * }, 576 * 'length': 3, 577 * 'ndims': 1, 578 * 'offset': 0, 579 * 'order': 'row-major', 580 * 'shape': [ 3 ], 581 * 'strides': [ 1 ], 582 * 'get': function get( i ) { 583 * return this.data[ i ]; 584 * }, 585 * 'set': function set( i, v ) { 586 * this.data[ i ] = v; 587 * return this; 588 * } 589 * }; 590 * 591 * @example 592 * import { ndarray } from `@stdlib/types/ndarray`; 593 * 594 * const arr: ndarray = { 595 * 'byteLength': null, 596 * 'BYTES_PER_ELEMENT': null, 597 * 'data': [ 1, 2, 3 ], 598 * 'dtype': 'generic', 599 * 'flags': { 600 * 'ROW_MAJOR_CONTIGUOUS': true, 601 * 'COLUMN_MAJOR_CONTIGUOUS': false 602 * }, 603 * 'length': 3, 604 * 'ndims': 1, 605 * 'offset': 0, 606 * 'order': 'row-major', 607 * 'shape': [ 3 ], 608 * 'strides': [ 1 ], 609 * 'get': function get( i ) { 610 * return this.data[ i ]; 611 * }, 612 * 'set': function set( i, v ) { 613 * this.data[ i ] = v; 614 * return this; 615 * } 616 * }; 617 */ 618 declare module '@stdlib/types/ndarray' { 619 import { ArrayLike, AccessorArrayLike, Complex128Array, Complex64Array, RealOrComplexTypedArray, FloatOrComplexTypedArray, RealTypedArray, ComplexTypedArray, IntegerTypedArray, FloatTypedArray, SignedIntegerTypedArray, UnsignedIntegerTypedArray } from '@stdlib/types/array'; // tslint:disable-line:max-line-length 620 import { ComplexLike, Complex128, Complex64 } from '@stdlib/types/object'; 621 622 /** 623 * Data type. 624 */ 625 type DataType = RealOrComplexDataType | 'binary' | 'generic'; 626 627 /** 628 * Data type for real-valued ndarrays. 629 */ 630 type RealDataType = FloatDataType | IntegerDataType; 631 632 /** 633 * Data type for floating-point ndarrays. 634 */ 635 type FloatDataType = 'float64' | 'float32'; 636 637 /** 638 * Data type for integer ndarrays. 639 */ 640 type IntegerDataType = SignedIntegerDataType | UnsignedIntegerDataType; 641 642 /** 643 * Data type for signed integer ndarrays. 644 */ 645 type SignedIntegerDataType = 'int32' | 'int16' | 'int8'; 646 647 /** 648 * Data type for unsigned integer ndarrays. 649 */ 650 type UnsignedIntegerDataType = 'uint32' | 'uint16' | 'uint8' | 'uint8c'; 651 652 /** 653 * Data type for complex number ndarrays. 654 */ 655 type ComplexDataType = 'complex64' | 'complex128'; 656 657 /** 658 * Data type for floating-point real or complex ndarrays. 659 */ 660 type FloatOrComplexDataType = FloatDataType | ComplexDataType; 661 662 /** 663 * Data type for real-valued or complex number ndarrays. 664 */ 665 type RealOrComplexDataType = RealDataType | ComplexDataType; 666 667 /** 668 * Array order. 669 * 670 * ## Notes 671 * 672 * - The array order is either row-major (C-style) or column-major (Fortran-style). 673 */ 674 type Order = 'row-major' | 'column-major'; 675 676 /** 677 * Array index mode. 678 * 679 * ## Notes 680 * 681 * - The following index modes are supported: 682 * 683 * - `throw`: specifies that a function should throw an error when an index is outside a restricted interval. 684 * - `wrap`: specifies that a function should wrap around an index using modulo arithmetic. 685 * - `clamp`: specifies that a function should set an index less than zero to zero (minimum index) and set an index greater than a maximum index value to the maximum possible index. 686 */ 687 type Mode = 'throw' | 'clamp' | 'wrap'; 688 689 /** 690 * Array shape. 691 * 692 * ## Notes 693 * 694 * - Each element of the array shape (i.e., dimension size) should be a nonnegative integer. 695 */ 696 type Shape = ArrayLike<number>; 697 698 /** 699 * Array strides. 700 * 701 * ## Notes 702 * 703 * - Each stride (i.e., index increment along a respective dimension) should be an integer. 704 */ 705 type Strides = ArrayLike<number>; 706 707 /** 708 * Interface describing an ndarray. 709 * 710 * @example 711 * const arr: ndarray = { 712 * 'byteLength': null, 713 * 'BYTES_PER_ELEMENT': null, 714 * 'data': [ 1, 2, 3 ], 715 * 'dtype': 'generic', 716 * 'flags': { 717 * 'ROW_MAJOR_CONTIGUOUS': true, 718 * 'COLUMN_MAJOR_CONTIGUOUS': false 719 * }, 720 * 'length': 3, 721 * 'ndims': 1, 722 * 'offset': 0, 723 * 'order': 'row-major', 724 * 'shape': [ 3 ], 725 * 'strides': [ 1 ], 726 * 'get': function get( i ) { 727 * return this.data[ i ]; 728 * }, 729 * 'set': function set( i, v ) { 730 * this.data[ i ] = v; 731 * return this; 732 * } 733 * }; 734 */ 735 interface ndarray { // tslint:disable-line:class-name 736 /** 737 * Size (in bytes) of the array (if known). 738 */ 739 byteLength: number | null; 740 741 /** 742 * Size (in bytes) of each array element (if known). 743 */ 744 BYTES_PER_ELEMENT: number | null; 745 746 /** 747 * A reference to the underlying data buffer. 748 */ 749 data: ArrayLike<any> | AccessorArrayLike<any>; 750 751 /** 752 * Underlying data type. 753 */ 754 dtype: string; 755 756 /** 757 * Flags and other meta information (e.g., memory layout of the array). 758 */ 759 flags: { 760 /** 761 * Boolean indicating if an array is row-major contiguous. 762 */ 763 ROW_MAJOR_CONTIGUOUS: boolean; 764 765 /** 766 * Boolean indicating if an array is column-major contiguous. 767 */ 768 COLUMN_MAJOR_CONTIGUOUS: boolean; 769 770 /** 771 * Boolean indicating if an array is read-only. 772 */ 773 READONLY?: boolean; 774 }; 775 776 /** 777 * Number of array elements. 778 */ 779 length: number; 780 781 /** 782 * Number of dimensions. 783 */ 784 ndims: number; 785 786 /** 787 * Index offset which specifies the `buffer` index at which to start iterating over array elements. 788 */ 789 offset: number; 790 791 /** 792 * Array order. 793 * 794 * ## Notes 795 * 796 * - The array order is either row-major (C-style) or column-major (Fortran-style). 797 */ 798 order: Order; 799 800 /** 801 * Array shape. 802 */ 803 shape: Shape; 804 805 /** 806 * Array strides. 807 */ 808 strides: Strides; 809 810 /** 811 * Returns an array element specified according to provided subscripts. 812 * 813 * ## Notes 814 * 815 * - The number of provided subscripts should equal the number of dimensions. 816 * 817 * @param args - subscripts 818 * @returns array element 819 */ 820 get( ...args: Array<number> ): any; 821 822 /** 823 * Sets an array element specified according to provided subscripts. 824 * 825 * ## Notes 826 * 827 * - The number of provided subscripts should equal the number of dimensions. 828 * 829 * @param args - subscripts and value to set 830 * @returns ndarray instance 831 */ 832 set( ...args: Array<any> ): ndarray; 833 } 834 835 /** 836 * Interface describing an ndarray having a generic data type. 837 * 838 * @example 839 * const arr: genericndarray = { 840 * 'byteLength': null, 841 * 'BYTES_PER_ELEMENT': null, 842 * 'data': [ 1, 2, 3 ], 843 * 'dtype': 'generic', 844 * 'flags': { 845 * 'ROW_MAJOR_CONTIGUOUS': true, 846 * 'COLUMN_MAJOR_CONTIGUOUS': false 847 * }, 848 * 'length': 3, 849 * 'ndims': 1, 850 * 'offset': 0, 851 * 'order': 'row-major', 852 * 'shape': [ 3 ], 853 * 'strides': [ 1 ], 854 * 'get': function get( i ) { 855 * return this.data[ i ]; 856 * }, 857 * 'set': function set( i, v ) { 858 * this.data[ i ] = v; 859 * return this; 860 * } 861 * }; 862 */ 863 interface genericndarray extends ndarray { // tslint:disable-line:class-name 864 /** 865 * Size (in bytes) of the array. 866 */ 867 byteLength: null; 868 869 /** 870 * Size (in bytes) of each array element. 871 */ 872 BYTES_PER_ELEMENT: null; 873 874 /** 875 * Underlying data type. 876 */ 877 dtype: 'generic'; 878 879 /** 880 * A reference to the underlying data buffer. 881 */ 882 data: ArrayLike<any>; 883 884 /** 885 * Returns an array element specified according to provided subscripts. 886 * 887 * ## Notes 888 * 889 * - The number of provided subscripts should equal the number of dimensions. 890 * 891 * @param args - subscripts 892 * @returns array element 893 */ 894 get( ...args: Array<number> ): any; 895 896 /** 897 * Sets an array element specified according to provided subscripts. 898 * 899 * ## Notes 900 * 901 * - The number of provided subscripts should equal the number of dimensions. 902 * 903 * @param args - subscripts and value to set 904 * @returns ndarray instance 905 */ 906 set( ...args: Array<any> ): genericndarray; 907 } 908 909 /** 910 * Interface describing an ndarray having a homogeneous data type. 911 * 912 * @example 913 * const arr: typedndarray<number> = { 914 * 'byteLength': null, 915 * 'BYTES_PER_ELEMENT': null, 916 * 'data': [ 1, 2, 3 ], 917 * 'dtype': 'generic', 918 * 'flags': { 919 * 'ROW_MAJOR_CONTIGUOUS': true, 920 * 'COLUMN_MAJOR_CONTIGUOUS': false 921 * }, 922 * 'length': 3, 923 * 'ndims': 1, 924 * 'offset': 0, 925 * 'order': 'row-major', 926 * 'shape': [ 3 ], 927 * 'strides': [ 1 ], 928 * 'get': function get( i ) { 929 * return this.data[ i ]; 930 * }, 931 * 'set': function set( i, v ) { 932 * this.data[ i ] = v; 933 * return this; 934 * } 935 * }; 936 */ 937 interface typedndarray<T> extends ndarray { // tslint:disable-line:class-name 938 /** 939 * A reference to the underlying data buffer. 940 */ 941 data: ArrayLike<T>; 942 943 /** 944 * Returns an array element specified according to provided subscripts. 945 * 946 * ## Notes 947 * 948 * - The number of provided subscripts should equal the number of dimensions. 949 * 950 * @param args - subscripts 951 * @returns array element 952 */ 953 get( ...args: Array<number> ): T; 954 955 /** 956 * Sets an array element specified according to provided subscripts. 957 * 958 * ## Notes 959 * 960 * - The number of provided subscripts should equal the number of dimensions. 961 * 962 * @param args - subscripts and value to set 963 * @returns ndarray instance 964 */ 965 set( ...args: Array<number | T> ): typedndarray<T>; 966 } 967 968 /** 969 * Interface describing an ndarray having a floating-point data type. 970 * 971 * @example 972 * const arr: floatndarray = { 973 * 'byteLength': 24, 974 * 'BYTES_PER_ELEMENT': 8, 975 * 'data': new Float64Array( [ 1, 2, 3 ] ), 976 * 'dtype': 'float64', 977 * 'flags': { 978 * 'ROW_MAJOR_CONTIGUOUS': true, 979 * 'COLUMN_MAJOR_CONTIGUOUS': false 980 * }, 981 * 'length': 3, 982 * 'ndims': 1, 983 * 'offset': 0, 984 * 'order': 'row-major', 985 * 'shape': [ 3 ], 986 * 'strides': [ 1 ], 987 * 'get': function get( i ) { 988 * return this.data[ i ]; 989 * }, 990 * 'set': function set( i, v ) { 991 * this.data[ i ] = v; 992 * return this; 993 * } 994 * }; 995 */ 996 interface floatndarray extends typedndarray<number> { // tslint:disable-line:class-name 997 /** 998 * Size (in bytes) of the array. 999 */ 1000 byteLength: number; 1001 1002 /** 1003 * Size (in bytes) of each array element. 1004 */ 1005 BYTES_PER_ELEMENT: number; 1006 1007 /** 1008 * A reference to the underlying data buffer. 1009 */ 1010 data: FloatTypedArray; 1011 1012 /** 1013 * Underlying data type. 1014 */ 1015 dtype: FloatDataType; 1016 1017 /** 1018 * Sets an array element specified according to provided subscripts. 1019 * 1020 * ## Notes 1021 * 1022 * - The number of provided subscripts should equal the number of dimensions. 1023 * 1024 * @param args - subscripts and value to set 1025 * @returns ndarray instance 1026 */ 1027 set( ...args: Array<number> ): floatndarray; 1028 } 1029 1030 /** 1031 * Interface describing an ndarray having a double-precision floating-point data type. 1032 * 1033 * @example 1034 * const arr: float64ndarray = { 1035 * 'byteLength': 24, 1036 * 'BYTES_PER_ELEMENT': 8, 1037 * 'data': new Float64Array( [ 1, 2, 3 ] ), 1038 * 'dtype': 'float64', 1039 * 'flags': { 1040 * 'ROW_MAJOR_CONTIGUOUS': true, 1041 * 'COLUMN_MAJOR_CONTIGUOUS': false 1042 * }, 1043 * 'length': 3, 1044 * 'ndims': 1, 1045 * 'offset': 0, 1046 * 'order': 'row-major', 1047 * 'shape': [ 3 ], 1048 * 'strides': [ 1 ], 1049 * 'get': function get( i ) { 1050 * return this.data[ i ]; 1051 * }, 1052 * 'set': function set( i, v ) { 1053 * this.data[ i ] = v; 1054 * return this; 1055 * } 1056 * }; 1057 */ 1058 interface float64ndarray extends floatndarray { // tslint:disable-line:class-name 1059 /** 1060 * Size (in bytes) of each array element. 1061 */ 1062 BYTES_PER_ELEMENT: 8; 1063 1064 /** 1065 * A reference to the underlying data buffer. 1066 */ 1067 data: Float64Array; 1068 1069 /** 1070 * Underlying data type. 1071 */ 1072 dtype: 'float64'; 1073 1074 /** 1075 * Sets an array element specified according to provided subscripts. 1076 * 1077 * ## Notes 1078 * 1079 * - The number of provided subscripts should equal the number of dimensions. 1080 * 1081 * @param args - subscripts and value to set 1082 * @returns ndarray instance 1083 */ 1084 set( ...args: Array<number> ): float64ndarray; 1085 } 1086 1087 /** 1088 * Interface describing an ndarray having a single-precision floating-point data type. 1089 * 1090 * @example 1091 * const arr: float32ndarray = { 1092 * 'byteLength': 12, 1093 * 'BYTES_PER_ELEMENT': 4, 1094 * 'data': new Float32Array( [ 1, 2, 3 ] ), 1095 * 'dtype': 'float32', 1096 * 'flags': { 1097 * 'ROW_MAJOR_CONTIGUOUS': true, 1098 * 'COLUMN_MAJOR_CONTIGUOUS': false 1099 * }, 1100 * 'length': 3, 1101 * 'ndims': 1, 1102 * 'offset': 0, 1103 * 'order': 'row-major', 1104 * 'shape': [ 3 ], 1105 * 'strides': [ 1 ], 1106 * 'get': function get( i ) { 1107 * return this.data[ i ]; 1108 * }, 1109 * 'set': function set( i, v ) { 1110 * this.data[ i ] = v; 1111 * return this; 1112 * } 1113 * }; 1114 */ 1115 interface float32ndarray extends floatndarray { // tslint:disable-line:class-name 1116 /** 1117 * Size (in bytes) of each array element. 1118 */ 1119 BYTES_PER_ELEMENT: 4; 1120 1121 /** 1122 * A reference to the underlying data buffer. 1123 */ 1124 data: Float32Array; 1125 1126 /** 1127 * Underlying data type. 1128 */ 1129 dtype: 'float32'; 1130 1131 /** 1132 * Sets an array element specified according to provided subscripts. 1133 * 1134 * ## Notes 1135 * 1136 * - The number of provided subscripts should equal the number of dimensions. 1137 * 1138 * @param args - subscripts and value to set 1139 * @returns ndarray instance 1140 */ 1141 set( ...args: Array<number> ): float32ndarray; 1142 } 1143 1144 /** 1145 * Interface describing an ndarray having an integer data type. 1146 * 1147 * @example 1148 * const arr: integerndarray = { 1149 * 'byteLength': 12, 1150 * 'BYTES_PER_ELEMENT': 4, 1151 * 'data': new Int32Array( [ 1, 2, 3 ] ), 1152 * 'dtype': 'int32', 1153 * 'flags': { 1154 * 'ROW_MAJOR_CONTIGUOUS': true, 1155 * 'COLUMN_MAJOR_CONTIGUOUS': false 1156 * }, 1157 * 'length': 3, 1158 * 'ndims': 1, 1159 * 'offset': 0, 1160 * 'order': 'row-major', 1161 * 'shape': [ 3 ], 1162 * 'strides': [ 1 ], 1163 * 'get': function get( i ) { 1164 * return this.data[ i ]; 1165 * }, 1166 * 'set': function set( i, v ) { 1167 * this.data[ i ] = v; 1168 * return this; 1169 * } 1170 * }; 1171 */ 1172 interface integerndarray extends typedndarray<number> { // tslint:disable-line:class-name 1173 /** 1174 * Size (in bytes) of the array. 1175 */ 1176 byteLength: number; 1177 1178 /** 1179 * Size (in bytes) of each array element. 1180 */ 1181 BYTES_PER_ELEMENT: number; 1182 1183 /** 1184 * A reference to the underlying data buffer. 1185 */ 1186 data: IntegerTypedArray; 1187 1188 /** 1189 * Underlying data type. 1190 */ 1191 dtype: IntegerDataType; 1192 1193 /** 1194 * Sets an array element specified according to provided subscripts. 1195 * 1196 * ## Notes 1197 * 1198 * - The number of provided subscripts should equal the number of dimensions. 1199 * 1200 * @param args - subscripts and value to set 1201 * @returns ndarray instance 1202 */ 1203 set( ...args: Array<number> ): integerndarray; 1204 } 1205 1206 /** 1207 * Interface describing an ndarray having a signed integer data type. 1208 * 1209 * @example 1210 * const arr: signedintegerndarray = { 1211 * 'byteLength': 12, 1212 * 'BYTES_PER_ELEMENT': 4, 1213 * 'data': new Int32Array( [ 1, 2, 3 ] ), 1214 * 'dtype': 'int32', 1215 * 'flags': { 1216 * 'ROW_MAJOR_CONTIGUOUS': true, 1217 * 'COLUMN_MAJOR_CONTIGUOUS': false 1218 * }, 1219 * 'length': 3, 1220 * 'ndims': 1, 1221 * 'offset': 0, 1222 * 'order': 'row-major', 1223 * 'shape': [ 3 ], 1224 * 'strides': [ 1 ], 1225 * 'get': function get( i ) { 1226 * return this.data[ i ]; 1227 * }, 1228 * 'set': function set( i, v ) { 1229 * this.data[ i ] = v; 1230 * return this; 1231 * } 1232 * }; 1233 */ 1234 interface signedintegerndarray extends typedndarray<number> { // tslint:disable-line:class-name 1235 /** 1236 * Size (in bytes) of the array. 1237 */ 1238 byteLength: number; 1239 1240 /** 1241 * Size (in bytes) of each array element. 1242 */ 1243 BYTES_PER_ELEMENT: number; 1244 1245 /** 1246 * A reference to the underlying data buffer. 1247 */ 1248 data: SignedIntegerTypedArray; 1249 1250 /** 1251 * Underlying data type. 1252 */ 1253 dtype: SignedIntegerDataType; 1254 1255 /** 1256 * Sets an array element specified according to provided subscripts. 1257 * 1258 * ## Notes 1259 * 1260 * - The number of provided subscripts should equal the number of dimensions. 1261 * 1262 * @param args - subscripts and value to set 1263 * @returns ndarray instance 1264 */ 1265 set( ...args: Array<number> ): signedintegerndarray; 1266 } 1267 1268 /** 1269 * Interface describing an ndarray having a signed 32-bit integer data type. 1270 * 1271 * @example 1272 * const arr: int32ndarray = { 1273 * 'byteLength': 12, 1274 * 'BYTES_PER_ELEMENT': 4, 1275 * 'data': new Int32Array( [ 1, 2, 3 ] ), 1276 * 'dtype': 'int32', 1277 * 'flags': { 1278 * 'ROW_MAJOR_CONTIGUOUS': true, 1279 * 'COLUMN_MAJOR_CONTIGUOUS': false 1280 * }, 1281 * 'length': 3, 1282 * 'ndims': 1, 1283 * 'offset': 0, 1284 * 'order': 'row-major', 1285 * 'shape': [ 3 ], 1286 * 'strides': [ 1 ], 1287 * 'get': function get( i ) { 1288 * return this.data[ i ]; 1289 * }, 1290 * 'set': function set( i, v ) { 1291 * this.data[ i ] = v; 1292 * return this; 1293 * } 1294 * }; 1295 */ 1296 interface int32ndarray extends signedintegerndarray { // tslint:disable-line:class-name 1297 /** 1298 * Size (in bytes) of each array element. 1299 */ 1300 BYTES_PER_ELEMENT: 4; 1301 1302 /** 1303 * A reference to the underlying data buffer. 1304 */ 1305 data: Int32Array; 1306 1307 /** 1308 * Underlying data type. 1309 */ 1310 dtype: 'int32'; 1311 1312 /** 1313 * Sets an array element specified according to provided subscripts. 1314 * 1315 * ## Notes 1316 * 1317 * - The number of provided subscripts should equal the number of dimensions. 1318 * 1319 * @param args - subscripts and value to set 1320 * @returns ndarray instance 1321 */ 1322 set( ...args: Array<number> ): int32ndarray; 1323 } 1324 1325 /** 1326 * Interface describing an ndarray having a signed 16-bit integer data type. 1327 * 1328 * @example 1329 * const arr: int16ndarray = { 1330 * 'byteLength': 6, 1331 * 'BYTES_PER_ELEMENT': 2, 1332 * 'data': new Int16Array( [ 1, 2, 3 ] ), 1333 * 'dtype': 'int16', 1334 * 'flags': { 1335 * 'ROW_MAJOR_CONTIGUOUS': true, 1336 * 'COLUMN_MAJOR_CONTIGUOUS': false 1337 * }, 1338 * 'length': 3, 1339 * 'ndims': 1, 1340 * 'offset': 0, 1341 * 'order': 'row-major', 1342 * 'shape': [ 3 ], 1343 * 'strides': [ 1 ], 1344 * 'get': function get( i ) { 1345 * return this.data[ i ]; 1346 * }, 1347 * 'set': function set( i, v ) { 1348 * this.data[ i ] = v; 1349 * return this; 1350 * } 1351 * }; 1352 */ 1353 interface int16ndarray extends signedintegerndarray { // tslint:disable-line:class-name 1354 /** 1355 * Size (in bytes) of each array element. 1356 */ 1357 BYTES_PER_ELEMENT: 2; 1358 1359 /** 1360 * A reference to the underlying data buffer. 1361 */ 1362 data: Int16Array; 1363 1364 /** 1365 * Underlying data type. 1366 */ 1367 dtype: 'int16'; 1368 1369 /** 1370 * Sets an array element specified according to provided subscripts. 1371 * 1372 * ## Notes 1373 * 1374 * - The number of provided subscripts should equal the number of dimensions. 1375 * 1376 * @param args - subscripts and value to set 1377 * @returns ndarray instance 1378 */ 1379 set( ...args: Array<number> ): int16ndarray; 1380 } 1381 1382 /** 1383 * Interface describing an ndarray having a signed 8-bit integer data type. 1384 * 1385 * @example 1386 * const arr: int8ndarray = { 1387 * 'byteLength': 3, 1388 * 'BYTES_PER_ELEMENT': 1, 1389 * 'data': new Int8Array( [ 1, 2, 3 ] ), 1390 * 'dtype': 'int8', 1391 * 'flags': { 1392 * 'ROW_MAJOR_CONTIGUOUS': true, 1393 * 'COLUMN_MAJOR_CONTIGUOUS': false 1394 * }, 1395 * 'length': 3, 1396 * 'ndims': 1, 1397 * 'offset': 0, 1398 * 'order': 'row-major', 1399 * 'shape': [ 3 ], 1400 * 'strides': [ 1 ], 1401 * 'get': function get( i ) { 1402 * return this.data[ i ]; 1403 * }, 1404 * 'set': function set( i, v ) { 1405 * this.data[ i ] = v; 1406 * return this; 1407 * } 1408 * }; 1409 */ 1410 interface int8ndarray extends signedintegerndarray { // tslint:disable-line:class-name 1411 /** 1412 * Size (in bytes) of each array element. 1413 */ 1414 BYTES_PER_ELEMENT: 1; 1415 1416 /** 1417 * A reference to the underlying data buffer. 1418 */ 1419 data: Int8Array; 1420 1421 /** 1422 * Underlying data type. 1423 */ 1424 dtype: 'int8'; 1425 1426 /** 1427 * Sets an array element specified according to provided subscripts. 1428 * 1429 * ## Notes 1430 * 1431 * - The number of provided subscripts should equal the number of dimensions. 1432 * 1433 * @param args - subscripts and value to set 1434 * @returns ndarray instance 1435 */ 1436 set( ...args: Array<number> ): int8ndarray; 1437 } 1438 1439 /** 1440 * Interface describing an ndarray having an unsigned integer data type. 1441 * 1442 * @example 1443 * const arr: unsignedintegerndarray = { 1444 * 'byteLength': 12, 1445 * 'BYTES_PER_ELEMENT': 4, 1446 * 'data': new Uint32Array( [ 1, 2, 3 ] ), 1447 * 'dtype': 'uint32', 1448 * 'flags': { 1449 * 'ROW_MAJOR_CONTIGUOUS': true, 1450 * 'COLUMN_MAJOR_CONTIGUOUS': false 1451 * }, 1452 * 'length': 3, 1453 * 'ndims': 1, 1454 * 'offset': 0, 1455 * 'order': 'row-major', 1456 * 'shape': [ 3 ], 1457 * 'strides': [ 1 ], 1458 * 'get': function get( i ) { 1459 * return this.data[ i ]; 1460 * }, 1461 * 'set': function set( i, v ) { 1462 * this.data[ i ] = v; 1463 * return this; 1464 * } 1465 * }; 1466 */ 1467 interface unsignedintegerndarray extends typedndarray<number> { // tslint:disable-line:class-name 1468 /** 1469 * Size (in bytes) of the array. 1470 */ 1471 byteLength: number; 1472 1473 /** 1474 * Size (in bytes) of each array element. 1475 */ 1476 BYTES_PER_ELEMENT: number; 1477 1478 /** 1479 * A reference to the underlying data buffer. 1480 */ 1481 data: UnsignedIntegerTypedArray; 1482 1483 /** 1484 * Underlying data type. 1485 */ 1486 dtype: UnsignedIntegerDataType; 1487 1488 /** 1489 * Sets an array element specified according to provided subscripts. 1490 * 1491 * ## Notes 1492 * 1493 * - The number of provided subscripts should equal the number of dimensions. 1494 * 1495 * @param args - subscripts and value to set 1496 * @returns ndarray instance 1497 */ 1498 set( ...args: Array<number> ): unsignedintegerndarray; 1499 } 1500 1501 /** 1502 * Interface describing an ndarray having an unsigned 32-bit integer data type. 1503 * 1504 * @example 1505 * const arr: uint32ndarray = { 1506 * 'byteLength': 12, 1507 * 'BYTES_PER_ELEMENT': 4, 1508 * 'data': new Uint32Array( [ 1, 2, 3 ] ), 1509 * 'dtype': 'uint32', 1510 * 'flags': { 1511 * 'ROW_MAJOR_CONTIGUOUS': true, 1512 * 'COLUMN_MAJOR_CONTIGUOUS': false 1513 * }, 1514 * 'length': 3, 1515 * 'ndims': 1, 1516 * 'offset': 0, 1517 * 'order': 'row-major', 1518 * 'shape': [ 3 ], 1519 * 'strides': [ 1 ], 1520 * 'get': function get( i ) { 1521 * return this.data[ i ]; 1522 * }, 1523 * 'set': function set( i, v ) { 1524 * this.data[ i ] = v; 1525 * return this; 1526 * } 1527 * }; 1528 */ 1529 interface uint32ndarray extends unsignedintegerndarray { // tslint:disable-line:class-name 1530 /** 1531 * Size (in bytes) of each array element. 1532 */ 1533 BYTES_PER_ELEMENT: 4; 1534 1535 /** 1536 * A reference to the underlying data buffer. 1537 */ 1538 data: Uint32Array; 1539 1540 /** 1541 * Underlying data type. 1542 */ 1543 dtype: 'uint32'; 1544 1545 /** 1546 * Sets an array element specified according to provided subscripts. 1547 * 1548 * ## Notes 1549 * 1550 * - The number of provided subscripts should equal the number of dimensions. 1551 * 1552 * @param args - subscripts and value to set 1553 * @returns ndarray instance 1554 */ 1555 set( ...args: Array<number> ): uint32ndarray; 1556 } 1557 1558 /** 1559 * Interface describing an ndarray having an unsigned 16-bit integer data type. 1560 * 1561 * @example 1562 * const arr: uint16ndarray = { 1563 * 'byteLength': 6, 1564 * 'BYTES_PER_ELEMENT': 2, 1565 * 'data': new Uint16Array( [ 1, 2, 3 ] ), 1566 * 'dtype': 'uint16', 1567 * 'flags': { 1568 * 'ROW_MAJOR_CONTIGUOUS': true, 1569 * 'COLUMN_MAJOR_CONTIGUOUS': false 1570 * }, 1571 * 'length': 3, 1572 * 'ndims': 1, 1573 * 'offset': 0, 1574 * 'order': 'row-major', 1575 * 'shape': [ 3 ], 1576 * 'strides': [ 1 ], 1577 * 'get': function get( i ) { 1578 * return this.data[ i ]; 1579 * }, 1580 * 'set': function set( i, v ) { 1581 * this.data[ i ] = v; 1582 * return this; 1583 * } 1584 * }; 1585 */ 1586 interface uint16ndarray extends unsignedintegerndarray { // tslint:disable-line:class-name 1587 /** 1588 * Size (in bytes) of each array element. 1589 */ 1590 BYTES_PER_ELEMENT: 2; 1591 1592 /** 1593 * A reference to the underlying data buffer. 1594 */ 1595 data: Uint16Array; 1596 1597 /** 1598 * Underlying data type. 1599 */ 1600 dtype: 'uint16'; 1601 1602 /** 1603 * Sets an array element specified according to provided subscripts. 1604 * 1605 * ## Notes 1606 * 1607 * - The number of provided subscripts should equal the number of dimensions. 1608 * 1609 * @param args - subscripts and value to set 1610 * @returns ndarray instance 1611 */ 1612 set( ...args: Array<number> ): uint16ndarray; 1613 } 1614 1615 /** 1616 * Interface describing an ndarray having an unsigned 8-bit integer data type. 1617 * 1618 * @example 1619 * const arr: uint8ndarray = { 1620 * 'byteLength': 3, 1621 * 'BYTES_PER_ELEMENT': 1, 1622 * 'data': new Uint8Array( [ 1, 2, 3 ] ), 1623 * 'dtype': 'uint8', 1624 * 'flags': { 1625 * 'ROW_MAJOR_CONTIGUOUS': true, 1626 * 'COLUMN_MAJOR_CONTIGUOUS': false 1627 * }, 1628 * 'length': 3, 1629 * 'ndims': 1, 1630 * 'offset': 0, 1631 * 'order': 'row-major', 1632 * 'shape': [ 3 ], 1633 * 'strides': [ 1 ], 1634 * 'get': function get( i ) { 1635 * return this.data[ i ]; 1636 * }, 1637 * 'set': function set( i, v ) { 1638 * this.data[ i ] = v; 1639 * return this; 1640 * } 1641 * }; 1642 */ 1643 interface uint8ndarray extends unsignedintegerndarray { // tslint:disable-line:class-name 1644 /** 1645 * Size (in bytes) of each array element. 1646 */ 1647 BYTES_PER_ELEMENT: 1; 1648 1649 /** 1650 * A reference to the underlying data buffer. 1651 */ 1652 data: Uint8Array; 1653 1654 /** 1655 * Underlying data type. 1656 */ 1657 dtype: 'uint8'; 1658 1659 /** 1660 * Sets an array element specified according to provided subscripts. 1661 * 1662 * ## Notes 1663 * 1664 * - The number of provided subscripts should equal the number of dimensions. 1665 * 1666 * @param args - subscripts and value to set 1667 * @returns ndarray instance 1668 */ 1669 set( ...args: Array<number> ): uint8ndarray; 1670 } 1671 1672 /** 1673 * Interface describing an ndarray having a clamped unsigned 8-bit integer data type. 1674 * 1675 * @example 1676 * const arr: uint8cndarray = { 1677 * 'byteLength': 12, 1678 * 'BYTES_PER_ELEMENT': 4, 1679 * 'data': new Uint8ClampedArray( [ 1, 2, 3 ] ), 1680 * 'dtype': 'uint8c', 1681 * 'flags': { 1682 * 'ROW_MAJOR_CONTIGUOUS': true, 1683 * 'COLUMN_MAJOR_CONTIGUOUS': false 1684 * }, 1685 * 'length': 3, 1686 * 'ndims': 1, 1687 * 'offset': 0, 1688 * 'order': 'row-major', 1689 * 'shape': [ 3 ], 1690 * 'strides': [ 1 ], 1691 * 'get': function get( i ) { 1692 * return this.data[ i ]; 1693 * }, 1694 * 'set': function set( i, v ) { 1695 * this.data[ i ] = v; 1696 * return this; 1697 * } 1698 * }; 1699 */ 1700 interface uint8cndarray extends unsignedintegerndarray { // tslint:disable-line:class-name 1701 /** 1702 * Size (in bytes) of each array element. 1703 */ 1704 BYTES_PER_ELEMENT: 1; 1705 1706 /** 1707 * A reference to the underlying data buffer. 1708 */ 1709 data: Uint8ClampedArray; 1710 1711 /** 1712 * Underlying data type. 1713 */ 1714 dtype: 'uint8c'; 1715 1716 /** 1717 * Sets an array element specified according to provided subscripts. 1718 * 1719 * ## Notes 1720 * 1721 * - The number of provided subscripts should equal the number of dimensions. 1722 * 1723 * @param args - subscripts and value to set 1724 * @returns ndarray instance 1725 */ 1726 set( ...args: Array<number> ): uint8cndarray; 1727 } 1728 1729 /** 1730 * Interface describing an ndarray having a real-valued data type. 1731 * 1732 * @example 1733 * const arr: realndarray = { 1734 * 'byteLength': 24, 1735 * 'BYTES_PER_ELEMENT': 8, 1736 * 'data': new Float64Array( [ 1, 2, 3 ] ), 1737 * 'dtype': 'float64', 1738 * 'flags': { 1739 * 'ROW_MAJOR_CONTIGUOUS': true, 1740 * 'COLUMN_MAJOR_CONTIGUOUS': false 1741 * }, 1742 * 'length': 3, 1743 * 'ndims': 1, 1744 * 'offset': 0, 1745 * 'order': 'row-major', 1746 * 'shape': [ 3 ], 1747 * 'strides': [ 1 ], 1748 * 'get': function get( i ) { 1749 * return this.data[ i ]; 1750 * }, 1751 * 'set': function set( i, v ) { 1752 * this.data[ i ] = v; 1753 * return this; 1754 * } 1755 * }; 1756 */ 1757 interface realndarray extends typedndarray<number> { // tslint:disable-line:class-name 1758 /** 1759 * Size (in bytes) of the array. 1760 */ 1761 byteLength: number; 1762 1763 /** 1764 * Size (in bytes) of each array element. 1765 */ 1766 BYTES_PER_ELEMENT: number; 1767 1768 /** 1769 * A reference to the underlying data buffer. 1770 */ 1771 data: RealTypedArray; 1772 1773 /** 1774 * Underlying data type. 1775 */ 1776 dtype: RealDataType; 1777 1778 /** 1779 * Sets an array element specified according to provided subscripts. 1780 * 1781 * ## Notes 1782 * 1783 * - The number of provided subscripts should equal the number of dimensions. 1784 * 1785 * @param args - subscripts and value to set 1786 * @returns ndarray instance 1787 */ 1788 set( ...args: Array<number> ): realndarray; 1789 } 1790 1791 /** 1792 * Interface describing an ndarray having a real or complex number data type. 1793 * 1794 * @example 1795 * const arr: realcomplexndarray = { 1796 * 'byteLength': 24, 1797 * 'BYTES_PER_ELEMENT': 8, 1798 * 'data': new Float64Array( [ 1, 2, 3 ] ), 1799 * 'dtype': 'float64', 1800 * 'flags': { 1801 * 'ROW_MAJOR_CONTIGUOUS': true, 1802 * 'COLUMN_MAJOR_CONTIGUOUS': false 1803 * }, 1804 * 'length': 3, 1805 * 'ndims': 1, 1806 * 'offset': 0, 1807 * 'order': 'row-major', 1808 * 'shape': [ 3 ], 1809 * 'strides': [ 1 ], 1810 * 'get': function get( i ) { 1811 * return this.data[ i ]; 1812 * }, 1813 * 'set': function set( i, v ) { 1814 * this.data[ i ] = v; 1815 * return this; 1816 * } 1817 * }; 1818 */ 1819 interface realcomplexndarray extends ndarray { // tslint:disable-line:class-name 1820 /** 1821 * Size (in bytes) of the array. 1822 */ 1823 byteLength: number; 1824 1825 /** 1826 * Size (in bytes) of each array element. 1827 */ 1828 BYTES_PER_ELEMENT: number; 1829 1830 /** 1831 * A reference to the underlying data buffer. 1832 */ 1833 data: RealOrComplexTypedArray; 1834 1835 /** 1836 * Underlying data type. 1837 */ 1838 dtype: RealOrComplexDataType; 1839 1840 /** 1841 * Returns an array element specified according to provided subscripts. 1842 * 1843 * ## Notes 1844 * 1845 * - The number of provided subscripts should equal the number of dimensions. 1846 * 1847 * @param args - subscripts 1848 * @returns array element 1849 */ 1850 get( ...args: Array<number> ): number | ComplexLike | void; 1851 1852 /** 1853 * Sets an array element specified according to provided subscripts. 1854 * 1855 * ## Notes 1856 * 1857 * - The number of provided subscripts should equal the number of dimensions. 1858 * 1859 * @param args - subscripts and value to set 1860 * @returns ndarray instance 1861 */ 1862 set( ...args: Array<number | ComplexLike> ): realcomplexndarray; 1863 } 1864 1865 /** 1866 * Interface describing an ndarray having a floating-point real or complex number data type. 1867 * 1868 * @example 1869 * const arr: floatcomplexndarray = { 1870 * 'byteLength': 24, 1871 * 'BYTES_PER_ELEMENT': 8, 1872 * 'data': new Float64Array( [ 1, 2, 3 ] ), 1873 * 'dtype': 'float64', 1874 * 'flags': { 1875 * 'ROW_MAJOR_CONTIGUOUS': true, 1876 * 'COLUMN_MAJOR_CONTIGUOUS': false 1877 * }, 1878 * 'length': 3, 1879 * 'ndims': 1, 1880 * 'offset': 0, 1881 * 'order': 'row-major', 1882 * 'shape': [ 3 ], 1883 * 'strides': [ 1 ], 1884 * 'get': function get( i ) { 1885 * return this.data[ i ]; 1886 * }, 1887 * 'set': function set( i, v ) { 1888 * this.data[ i ] = v; 1889 * return this; 1890 * } 1891 * }; 1892 */ 1893 interface floatcomplexndarray extends ndarray { // tslint:disable-line:class-name 1894 /** 1895 * Size (in bytes) of the array. 1896 */ 1897 byteLength: number; 1898 1899 /** 1900 * Size (in bytes) of each array element. 1901 */ 1902 BYTES_PER_ELEMENT: number; 1903 1904 /** 1905 * A reference to the underlying data buffer. 1906 */ 1907 data: FloatOrComplexTypedArray; 1908 1909 /** 1910 * Underlying data type. 1911 */ 1912 dtype: FloatOrComplexDataType; 1913 1914 /** 1915 * Returns an array element specified according to provided subscripts. 1916 * 1917 * ## Notes 1918 * 1919 * - The number of provided subscripts should equal the number of dimensions. 1920 * 1921 * @param args - subscripts 1922 * @returns array element 1923 */ 1924 get( ...args: Array<number> ): number | ComplexLike | void; 1925 1926 /** 1927 * Sets an array element specified according to provided subscripts. 1928 * 1929 * ## Notes 1930 * 1931 * - The number of provided subscripts should equal the number of dimensions. 1932 * 1933 * @param args - subscripts and value to set 1934 * @returns ndarray instance 1935 */ 1936 set( ...args: Array<number | ComplexLike> ): floatcomplexndarray; 1937 } 1938 1939 /** 1940 * Interface describing an ndarray having a complex number data type. 1941 * 1942 * @example 1943 * const arr: complexndarray = { 1944 * 'byteLength': 48, 1945 * 'BYTES_PER_ELEMENT': 16, 1946 * 'data': new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), 1947 * 'dtype': 'complex128', 1948 * 'flags': { 1949 * 'ROW_MAJOR_CONTIGUOUS': true, 1950 * 'COLUMN_MAJOR_CONTIGUOUS': false 1951 * }, 1952 * 'length': 3, 1953 * 'ndims': 1, 1954 * 'offset': 0, 1955 * 'order': 'row-major', 1956 * 'shape': [ 3 ], 1957 * 'strides': [ 1 ], 1958 * 'get': function get( i ) { 1959 * return new Complex128( this.data[ i*2 ], this.data[ (i*2)+1 ] ); 1960 * }, 1961 * 'set': function set( i, v ) { 1962 * this.data[ i ] = v; 1963 * return this; 1964 * } 1965 * }; 1966 */ 1967 interface complexndarray extends ndarray { // tslint:disable-line:class-name 1968 /** 1969 * Size (in bytes) of the array. 1970 */ 1971 byteLength: number; 1972 1973 /** 1974 * Size (in bytes) of each array element. 1975 */ 1976 BYTES_PER_ELEMENT: number; 1977 1978 /** 1979 * A reference to the underlying data buffer. 1980 */ 1981 data: ComplexTypedArray; 1982 1983 /** 1984 * Underlying data type. 1985 */ 1986 dtype: ComplexDataType; 1987 1988 /** 1989 * Returns an array element specified according to provided subscripts. 1990 * 1991 * ## Notes 1992 * 1993 * - The number of provided subscripts should equal the number of dimensions. 1994 * 1995 * @param args - subscripts 1996 * @returns array element 1997 */ 1998 get( ...args: Array<number> ): ComplexLike | void; 1999 2000 /** 2001 * Sets an array element specified according to provided subscripts. 2002 * 2003 * ## Notes 2004 * 2005 * - The number of provided subscripts should equal the number of dimensions. 2006 * 2007 * @param args - subscripts and value to set 2008 * @returns ndarray instance 2009 */ 2010 set( ...args: Array<number | ComplexLike> ): complexndarray; 2011 } 2012 2013 /** 2014 * Interface describing an ndarray having a double-precision complex floating-point data type. 2015 * 2016 * @example 2017 * const arr: complex128ndarray = { 2018 * 'byteLength': 48, 2019 * 'BYTES_PER_ELEMENT': 16, 2020 * 'data': new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), 2021 * 'dtype': 'complex128', 2022 * 'flags': { 2023 * 'ROW_MAJOR_CONTIGUOUS': true, 2024 * 'COLUMN_MAJOR_CONTIGUOUS': false 2025 * }, 2026 * 'length': 3, 2027 * 'ndims': 1, 2028 * 'offset': 0, 2029 * 'order': 'row-major', 2030 * 'shape': [ 3 ], 2031 * 'strides': [ 1 ], 2032 * 'get': function get( i ) { 2033 * return new Complex128( this.data[ i*2 ], this.data[ (i*2)+1 ] ); 2034 * }, 2035 * 'set': function set( i, v ) { 2036 * this.data[ i ] = v; 2037 * return this; 2038 * } 2039 * }; 2040 */ 2041 interface complex128ndarray extends complexndarray { // tslint:disable-line:class-name 2042 /** 2043 * Size (in bytes) of each array element. 2044 */ 2045 BYTES_PER_ELEMENT: 16; 2046 2047 /** 2048 * A reference to the underlying data buffer. 2049 */ 2050 data: Complex128Array; 2051 2052 /** 2053 * Underlying data type. 2054 */ 2055 dtype: 'complex128'; 2056 2057 /** 2058 * Returns an array element specified according to provided subscripts. 2059 * 2060 * ## Notes 2061 * 2062 * - The number of provided subscripts should equal the number of dimensions. 2063 * 2064 * @param args - subscripts 2065 * @returns array element 2066 */ 2067 get( ...args: Array<number> ): Complex128 | void; 2068 2069 /** 2070 * Sets an array element specified according to provided subscripts. 2071 * 2072 * ## Notes 2073 * 2074 * - The number of provided subscripts should equal the number of dimensions. 2075 * 2076 * @param args - subscripts and value to set 2077 * @returns ndarray instance 2078 */ 2079 set( ...args: Array<number | ComplexLike> ): complex128ndarray; 2080 } 2081 2082 /** 2083 * Interface describing an ndarray having a single-precision complex floating-point data type. 2084 * 2085 * @example 2086 * const arr: complex64ndarray = { 2087 * 'byteLength': 24, 2088 * 'BYTES_PER_ELEMENT': 8, 2089 * 'data': new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), 2090 * 'dtype': 'complex64', 2091 * 'flags': { 2092 * 'ROW_MAJOR_CONTIGUOUS': true, 2093 * 'COLUMN_MAJOR_CONTIGUOUS': false 2094 * }, 2095 * 'length': 3, 2096 * 'ndims': 1, 2097 * 'offset': 0, 2098 * 'order': 'row-major', 2099 * 'shape': [ 3 ], 2100 * 'strides': [ 1 ], 2101 * 'get': function get( i ) { 2102 * return new Complex64( this.data[ i*2 ], this.data[ (i*2)+1 ] ); 2103 * }, 2104 * 'set': function set( i, v ) { 2105 * this.data[ i ] = v; 2106 * return this; 2107 * } 2108 * }; 2109 */ 2110 interface complex64ndarray extends complexndarray { // tslint:disable-line:class-name 2111 /** 2112 * Size (in bytes) of each array element. 2113 */ 2114 BYTES_PER_ELEMENT: 8; 2115 2116 /** 2117 * A reference to the underlying data buffer. 2118 */ 2119 data: Complex64Array; 2120 2121 /** 2122 * Underlying data type. 2123 */ 2124 dtype: 'complex64'; 2125 2126 /** 2127 * Returns an array element specified according to provided subscripts. 2128 * 2129 * ## Notes 2130 * 2131 * - The number of provided subscripts should equal the number of dimensions. 2132 * 2133 * @param args - subscripts 2134 * @returns array element 2135 */ 2136 get( ...args: Array<number> ): Complex64 | void; 2137 2138 /** 2139 * Sets an array element specified according to provided subscripts. 2140 * 2141 * ## Notes 2142 * 2143 * - The number of provided subscripts should equal the number of dimensions. 2144 * 2145 * @param args - subscripts and value to set 2146 * @returns ndarray instance 2147 */ 2148 set( ...args: Array<number | ComplexLike> ): complex64ndarray; 2149 } 2150 2151 /** 2152 * Interface describing a one-dimensional ndarray having a homogeneous data type. 2153 * 2154 * @example 2155 * const arr: Vector<number> = { 2156 * 'byteLength': 24, 2157 * 'BYTES_PER_ELEMENT': 8, 2158 * 'data': new Float64Array( [ 1, 2, 3 ] ), 2159 * 'dtype': 'float64', 2160 * 'flags': { 2161 * 'ROW_MAJOR_CONTIGUOUS': true, 2162 * 'COLUMN_MAJOR_CONTIGUOUS': false 2163 * }, 2164 * 'length': 3, 2165 * 'ndims': 1, 2166 * 'offset': 0, 2167 * 'order': 'row-major', 2168 * 'shape': [ 3 ], 2169 * 'strides': [ 1 ], 2170 * 'get': function get( i ) { 2171 * return this.data[ i ]; 2172 * }, 2173 * 'set': function set( i, v ) { 2174 * this.data[ i ] = v; 2175 * return this; 2176 * } 2177 * }; 2178 */ 2179 interface Vector<T> extends typedndarray<T> { 2180 /** 2181 * Number of dimensions. 2182 */ 2183 ndims: 1; 2184 2185 /** 2186 * Array shape. 2187 */ 2188 shape: [ number ]; // tslint:disable-line:no-single-element-tuple-type 2189 2190 /** 2191 * Array strides. 2192 */ 2193 strides: [ number ]; // tslint:disable-line:no-single-element-tuple-type 2194 2195 /** 2196 * Sets an array element specified according to provided subscripts. 2197 * 2198 * ## Notes 2199 * 2200 * - The number of provided subscripts should equal the number of dimensions. 2201 * 2202 * @param i - element index 2203 * @param value - value to set 2204 * @returns ndarray instance 2205 */ 2206 set( i: number, value: T ): Vector<T>; 2207 } 2208 2209 /** 2210 * Interface describing a two-dimensional ndarray having a homogeneous data type. 2211 * 2212 * @example 2213 * const arr: Matrix<number> = { 2214 * 'byteLength': 24, 2215 * 'BYTES_PER_ELEMENT': 8, 2216 * 'data': new Float64Array( [ 1, 2, 3 ] ), 2217 * 'dtype': 'float64', 2218 * 'flags': { 2219 * 'ROW_MAJOR_CONTIGUOUS': true, 2220 * 'COLUMN_MAJOR_CONTIGUOUS': false 2221 * }, 2222 * 'length': 3, 2223 * 'ndims': 2, 2224 * 'offset': 0, 2225 * 'order': 'row-major', 2226 * 'shape': [ 1, 3 ], 2227 * 'strides': [ 3, 1 ], 2228 * 'get': function get( i ) { 2229 * return this.data[ i ]; 2230 * }, 2231 * 'set': function set( i, v ) { 2232 * this.data[ i ] = v; 2233 * return this; 2234 * } 2235 * }; 2236 */ 2237 interface Matrix<T> extends typedndarray<T> { 2238 /** 2239 * Number of dimensions. 2240 */ 2241 ndims: 2; 2242 2243 /** 2244 * Array shape. 2245 */ 2246 shape: [ number, number ]; 2247 2248 /** 2249 * Array strides. 2250 */ 2251 strides: [ number, number ]; 2252 2253 /** 2254 * Sets an array element specified according to provided subscripts. 2255 * 2256 * ## Notes 2257 * 2258 * - The number of provided subscripts should equal the number of dimensions. 2259 * 2260 * @param i - index along first dimension 2261 * @param j - index along second dimension 2262 * @param value - value to set 2263 * @returns ndarray instance 2264 */ 2265 set( i: number, j: number, value: T ): Matrix<T>; 2266 } 2267 } 2268 2269 /** 2270 * Module containing object definitions. 2271 * 2272 * @example 2273 * import * as obj from `@stdlib/types/object`; 2274 * 2275 * const desc: obj.DataPropertyDescriptor = { 2276 * 'configurable': false, 2277 * 'enumerable': true, 2278 * 'writable': false, 2279 * 'value': 'beep' 2280 * }; 2281 * 2282 * @example 2283 * import { DataPropertyDescriptor } from `@stdlib/types/object`; 2284 * 2285 * const desc: DataPropertyDescriptor = { 2286 * 'configurable': false, 2287 * 'enumerable': true, 2288 * 'writable': false, 2289 * 'value': 'beep' 2290 * }; 2291 */ 2292 declare module '@stdlib/types/object' { 2293 import { ArrayLike, TypedArray } from '@stdlib/types/array'; 2294 2295 /** 2296 * Interface describing a data property descriptor object. 2297 * 2298 * @example 2299 * const desc: DataPropertyDescriptor = { 2300 * 'configurable': false, 2301 * 'enumerable': true, 2302 * 'writable': false, 2303 * 'value': 'beep' 2304 * }; 2305 */ 2306 interface DataPropertyDescriptor { 2307 /** 2308 * Specifies whether a property descriptor may be changed and whether a property may be deleted from a corresponding object (default: `false`). 2309 */ 2310 configurable?: boolean; 2311 2312 /** 2313 * Specifies whether a property can be enumerated (default: `false`). 2314 */ 2315 enumerable?: boolean; 2316 2317 /** 2318 * Specifies whether the value associated with a property can be changed via the assignment operator (default: `false`). 2319 */ 2320 writable?: boolean; 2321 2322 /** 2323 * Value associated with a property (default: `undefined`). 2324 */ 2325 value?: any; 2326 } 2327 2328 /** 2329 * Interface describing an accessor property descriptor object. 2330 * 2331 * @example 2332 * const desc: AccessorPropertyDescriptor = { 2333 * 'configurable': false, 2334 * 'enumerable': true, 2335 * 'get': (): string => 'foo', 2336 * 'set': () => { throw new Error( 'invalid operation.' ); } 2337 * }; 2338 */ 2339 interface AccessorPropertyDescriptor { 2340 /** 2341 * Specifies whether a property descriptor may be changed and whether a property may be deleted from a corresponding object (default: `false`). 2342 */ 2343 configurable?: boolean; 2344 2345 /** 2346 * Specifies whether a property can be enumerated (default: `false`). 2347 */ 2348 enumerable?: boolean; 2349 2350 /** 2351 * A function which serves as a getter for the property. 2352 * 2353 * ## Notes 2354 * 2355 * - If omitted from a descriptor, a property value cannot be accessed. 2356 * - When the property is accessed, the function is called without arguments and with `this` set to the object through which the property is accessed (note: this may **not** be the object on which the property is defined due to inheritance). 2357 * - The return value will be used as the value of the property. 2358 */ 2359 get?(): any; 2360 2361 /** 2362 * A function which serves as a setter for the property. 2363 * 2364 * ## Notes 2365 * 2366 * - If omitted from a descriptor, a property value cannot be assigned. 2367 * - When the property is assigned to, the function is called with one argument (the value being assigned to the property) and with `this` set to the object through which the property is assigned. 2368 */ 2369 set?( x: any ): void; 2370 } 2371 2372 /** 2373 * Property descriptor object. 2374 * 2375 * @example 2376 * const desc: PropertyDescriptor = { 2377 * 'configurable': false, 2378 * 'enumerable': true, 2379 * 'writable': false, 2380 * 'value': 'beep' 2381 * }; 2382 */ 2383 type PropertyDescriptor = DataPropertyDescriptor | AccessorPropertyDescriptor; // tslint:disable-line:max-line-length 2384 2385 /** 2386 * An object property name. 2387 * 2388 * @example 2389 * const prop: PropertyName = 'foo'; 2390 */ 2391 type PropertyName = string | symbol; 2392 2393 /** 2394 * A collection, which is defined as either an array, typed array, or an array-like object (excluding strings and functions). 2395 * 2396 * @example 2397 * const arr: Collection = [ 1, 2, 3 ]; 2398 */ 2399 type Collection = Array<any> | TypedArray | ArrayLike<any>; 2400 2401 /** 2402 * Complex number data type. 2403 */ 2404 type ComplexDataType = 'complex64' | 'complex128'; 2405 2406 /** 2407 * A complex number-like object. 2408 * 2409 * @example 2410 * const x: ComplexLike = { 're': 5.0, 'im': 3.0 }; 2411 */ 2412 interface ComplexLike { 2413 /** 2414 * Real component. 2415 */ 2416 re: number; 2417 2418 /** 2419 * Imaginary component. 2420 */ 2421 im: number; 2422 } 2423 2424 /** 2425 * A 64-bit complex number. 2426 * 2427 * @example 2428 * const x: Complex64 = { 2429 * 're': 5.0, 2430 * 'im': 3.0, 2431 * 'byteLength': 8, 2432 * 'BYTES_PER_ELEMENT': 4 2433 * }; 2434 */ 2435 interface Complex64 extends ComplexLike { 2436 /** 2437 * Size (in bytes) of the complex number. 2438 */ 2439 byteLength: 8; 2440 2441 /** 2442 * Size (in bytes) of each component. 2443 */ 2444 BYTES_PER_ELEMENT: 4; 2445 } 2446 2447 /** 2448 * A 128-bit complex number. 2449 * 2450 * @example 2451 * const x: Complex128 = { 2452 * 're': 5.0, 2453 * 'im': 3.0, 2454 * 'byteLength': 16, 2455 * 'BYTES_PER_ELEMENT': 8 2456 * }; 2457 */ 2458 interface Complex128 extends ComplexLike { 2459 /** 2460 * Size (in bytes) of the complex number. 2461 */ 2462 byteLength: 16; 2463 2464 /** 2465 * Size (in bytes) of each component. 2466 */ 2467 BYTES_PER_ELEMENT: 8; 2468 } 2469 } 2470 2471 /** 2472 * Module containing PRNG definitions. 2473 * 2474 * @example 2475 * import * as random from `@stdlib/types/random`; 2476 * 2477 * const rand: random.PRNG = () => 3.14; 2478 * 2479 * @example 2480 * import { PRNG } from `@stdlib/types/random`; 2481 * 2482 * const rand: PRNG = () => 3.14; 2483 */ 2484 declare module '@stdlib/types/random' { 2485 import { ArrayLike } from '@stdlib/types/array'; 2486 2487 /** 2488 * A pseudorandom number generator (PRNG). 2489 * 2490 * @param args - PRNG parameters 2491 * @returns pseudorandom number 2492 * 2493 * @example 2494 * const rand: PRNG = () => 3.14; 2495 */ 2496 type PRNG = ( ...args: Array<any> ) => number; 2497 2498 /** 2499 * A pseudorandom number generator (PRNG) seed for the 32-bit Mersenne Twister (MT19937) PRNG. 2500 * 2501 * @example 2502 * const s: PRNGSeedMT19937 = 12345; 2503 * 2504 * @example 2505 * const s: PRNGSeedMT19937 = [ 12345, 67891 ]; 2506 */ 2507 type PRNGSeedMT19937 = number | ArrayLike<number>; 2508 2509 /** 2510 * A pseudorandom number generator (PRNG) state for the 32-bit Mersenne Twister (MT19937) PRNG. 2511 * 2512 * @example 2513 * const s: PRNGStateMT19937 = new Uint32Array( 627 ); 2514 */ 2515 type PRNGStateMT19937 = Uint32Array; 2516 2517 /** 2518 * A pseudorandom number generator (PRNG) seed for the MINSTD PRNG. 2519 * 2520 * @example 2521 * const s: PRNGSeedMINSTD = 12345; 2522 * 2523 * @example 2524 * const s: PRNGSeedMINSTD = [ 12345, 67891 ]; 2525 */ 2526 type PRNGSeedMINSTD = number | ArrayLike<number>; 2527 2528 /** 2529 * A pseudorandom number generator (PRNG) state for the MINSTD PRNG. 2530 * 2531 * @example 2532 * const s: PRNGStateMINSTD = new Int32Array( 6 ); 2533 */ 2534 type PRNGStateMINSTD = Int32Array; 2535 }