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 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959
|
{{alias}}()
A typed array constructor which returns a typed array representing an array
of single-precision floating-point numbers in the platform byte order.
Returns
-------
out: Float32Array
A typed array.
Examples
--------
> var arr = new {{alias}}()
<Float32Array>
{{alias}}( length )
Returns a typed array having a specified length.
Parameters
----------
length: integer
Typed array length.
Returns
-------
out: Float32Array
A typed array.
Examples
--------
> var arr = new {{alias}}( 5 )
<Float32Array>[ 0.0, 0.0, 0.0, 0.0, 0.0 ]
{{alias}}( typedarray )
Creates a typed array from another typed array.
Parameters
----------
typedarray: TypedArray
Typed array from which to generate another typed array.
Returns
-------
out: Float32Array
A typed array.
Examples
--------
> var arr1 = new {{alias:@stdlib/array/float64}}( [ 0.5, 0.5, 0.5 ] );
> var arr2 = new {{alias}}( arr1 )
<Float32Array>[ 0.5, 0.5, 0.5 ]
{{alias}}( obj )
Creates a typed array from an array-like object or iterable.
Parameters
----------
obj: Object
Array-like object or iterable from which to generate a typed array.
Returns
-------
out: Float32Array
A typed array.
Examples
--------
> var arr1 = [ 0.5, 0.5, 0.5 ];
> var arr2 = new {{alias}}( arr1 )
<Float32Array>[ 0.5, 0.5, 0.5 ]
{{alias}}( buffer[, byteOffset[, length]] )
Returns a typed array view of an ArrayBuffer.
Parameters
----------
buffer: ArrayBuffer
Underlying ArrayBuffer.
byteOffset: integer (optional)
Integer byte offset specifying the location of the first typed array
element. Default: 0.
length: integer (optional)
View length. If not provided, the view spans from the byteOffset to
the end of the underlying ArrayBuffer.
Returns
-------
out: Float32Array
A typed array.
Examples
--------
> var buf = new {{alias:@stdlib/array/buffer}}( 16 );
> var arr = new {{alias}}( buf, 0, 4 )
<Float32Array>[ 0.0, 0.0, 0.0, 0.0 ]
{{alias}}.from( src[, map[, thisArg]] )
Creates a new typed array from an array-like object or an iterable.
A callback is provided the following arguments:
- value: source value.
- index: source index.
Parameters
----------
src: ArrayLike|Iterable
Source of array elements.
map: Function (optional)
Callback to invoke for each source element.
thisArg: Any (optional)
Callback execution context.
Returns
-------
out: Float32Array
A typed array.
Examples
--------
> function mapFcn( v ) { return v * 2.0; };
> var arr = {{alias}}.from( [ 1.0, -1.0 ], mapFcn )
<Float32Array>[ 2.0, -2.0 ]
{{alias}}.of( element0[, element1[, ...elementN]] )
Creates a new typed array from a variable number of arguments.
Parameters
----------
element0: number
Array element.
element1: number (optional)
Array element.
elementN: number (optional)
Array elements.
Returns
-------
out: Float32Array
A typed array.
Examples
--------
> var arr = {{alias}}.of( 2.0, -2.0 )
<Float32Array>[ 2.0, -2.0 ]
{{alias}}.BYTES_PER_ELEMENT
Number of bytes per view element.
Examples
--------
> {{alias}}.BYTES_PER_ELEMENT
4
{{alias}}.name
Typed array constructor name.
Examples
--------
> {{alias}}.name
'Float32Array'
{{alias}}.prototype.buffer
Read-only property which returns the ArrayBuffer referenced by the typed
array.
Examples
--------
> var arr = new {{alias}}( 5 );
> arr.buffer
<ArrayBuffer>
{{alias}}.prototype.byteLength
Read-only property which returns the length (in bytes) of the typed array.
Examples
--------
> var arr = new {{alias}}( 5 );
> arr.byteLength
20
{{alias}}.prototype.byteOffset
Read-only property which returns the offset (in bytes) of the typed array
from the start of its ArrayBuffer.
Examples
--------
> var arr = new {{alias}}( 5 );
> arr.byteOffset
0
{{alias}}.prototype.BYTES_PER_ELEMENT
Number of bytes per view element.
Examples
--------
> var arr = new {{alias}}( 5 );
> arr.BYTES_PER_ELEMENT
4
{{alias}}.prototype.length
Read-only property which returns the number of view elements.
Examples
--------
> var arr = new {{alias}}( 5 );
> arr.length
5
{{alias}}.prototype.copyWithin( target, start[, end] )
Copies a sequence of elements within the array starting at `start` and
ending at `end` (non-inclusive) to the position starting at `target`.
Parameters
----------
target: integer
Target start index position.
start: integer
Source start index position.
end: integer (optional)
Source end index position. Default: out.length.
Returns
-------
out: Float32Array
Modified array.
Examples
--------
> var arr = new {{alias}}( [ 2.0, -2.0, 1.0, -1.0, 1.0 ] );
> arr.copyWithin( 3, 0, 2 );
> arr[ 3 ]
2.0
> arr[ 4 ]
-2.0
{{alias}}.prototype.entries()
Returns an iterator for iterating over array key-value pairs.
Returns
-------
iter: Iterator
Iterator for iterating over array key-value pairs.
Examples
--------
> var arr = new {{alias}}( [ 1.0, -1.0 ] );
> it = arr.entries();
> it.next().value
[ 0, 1.0 ]
> it.next().value
[ 1, -1.0 ]
> it.next().done
true
{{alias}}.prototype.every( predicate[, thisArg] )
Tests whether all array elements pass a test implemented by a predicate
function.
A predicate function is provided the following arguments:
- value: array element.
- index: array index.
- arr: array on which the method is invoked.
Parameters
----------
predicate: Function
Predicate function which tests array elements. If a predicate function
returns a truthy value, an array element passes; otherwise, an array
element fails.
thisArg: Any (optional)
Callback execution context.
Returns
-------
bool: boolean
Boolean indicating whether all array elements pass.
Examples
--------
> var arr = new {{alias}}( [ 1.0, -1.0 ] );
> function predicate( v ) { return ( v >= 0.0 ); };
> arr.every( predicate )
false
{{alias}}.prototype.fill( value[, start[, end]] )
Fills an array from a start index to an end index (non-inclusive) with a
provided value.
Parameters
----------
value: number
Fill value.
start: integer (optional)
Start index. If less than zero, the start index is resolved relative to
the last array element. Default: 0.
end: integer (optional)
End index (non-inclusive). If less than zero, the end index is resolved
relative to the last array element. Default: out.length.
Returns
-------
out: Float32Array
Modified array.
Examples
--------
> var arr = new {{alias}}( [ 1.0, -1.0 ] );
> arr.fill( 2.0 );
> arr[ 0 ]
2.0
> arr[ 1 ]
2.0
{{alias}}.prototype.filter( predicate[, thisArg] )
Creates a new array which includes those elements for which a predicate
function returns a truthy value.
A predicate function is provided the following arguments:
- value: array element.
- index: array index.
- arr: array on which the method is invoked.
The returned array has the same data type as the host array.
If a predicate function does not return a truthy value for any array
element, the method returns `null`.
Parameters
----------
predicate: Function
Predicate function which filters array elements. If a predicate function
returns a truthy value, an array element is included in the output
array; otherwise, an array element is not included in the output array.
thisArg: Any (optional)
Callback execution context.
Returns
-------
out: Float32Array
A typed array.
Examples
--------
> var arr1 = new {{alias}}( [ 1.0, 0.0, -1.0 ] );
> function predicate( v ) { return ( v >= 0.0 ); };
> var arr2 = arr1.filter( predicate );
> arr2.length
2
{{alias}}.prototype.find( predicate[, thisArg] )
Returns the first array element for which a provided predicate function
returns a truthy value.
A predicate function is provided the following arguments:
- value: array element.
- index: array index.
- arr: array on which the method is invoked.
If a predicate function never returns a truthy value, the method returns
`undefined`.
Parameters
----------
predicate: Function
Predicate function which tests array elements.
thisArg: Any (optional)
Callback execution context.
Returns
-------
value: number|undefined
Array element.
Examples
--------
> var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] );
> function predicate( v ) { return ( v < 0.0 ); };
> var v = arr.find( predicate )
-1.0
{{alias}}.prototype.findIndex( predicate[, thisArg] )
Returns the index of the first array element for which a provided predicate
function returns a truthy value.
A predicate function is provided the following arguments:
- value: array element.
- index: array index.
- arr: array on which the method is invoked.
If a predicate function never returns a truthy value, the method returns
`-1`.
Parameters
----------
predicate: Function
Predicate function which tests array elements.
thisArg: Any (optional)
Callback execution context.
Returns
-------
idx: integer
Array index.
Examples
--------
> var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] );
> function predicate( v ) { return ( v < 0.0 ); };
> var idx = arr.findIndex( predicate )
2
{{alias}}.prototype.forEach( fcn[, thisArg] )
Invokes a callback for each array element.
A provided function is provided the following arguments:
- value: array element.
- index: array index.
- arr: array on which the method is invoked.
Parameters
----------
fcn: Function
Function to invoke for each array element.
thisArg: Any (optional)
Callback execution context.
Examples
--------
> var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] );
> var str = ' ';
> function fcn( v, i ) { str += i + ':' + v + ' '; };
> arr.forEach( fcn );
> str
' 0:1 1:0 2:-1 '
{{alias}}.prototype.includes( searchElement[, fromIndex] )
Returns a boolean indicating whether an array includes a search element.
The method does not distinguish between signed and unsigned zero.
Parameters
----------
searchElement: number
Search element.
fromIndex: integer (optional)
Array index from which to begin searching. If provided a negative value,
the method resolves the start index relative to the last array element.
Default: 0.
Returns
-------
bool: boolean
Boolean indicating whether an array includes a search element.
Examples
--------
> var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] );
> var bool = arr.includes( 2.0 )
false
> bool = arr.includes( -1.0 )
true
{{alias}}.prototype.indexOf( searchElement[, fromIndex] )
Returns the index of the first array element strictly equal to a search
element.
The method does not distinguish between signed and unsigned zero.
If unable to locate a search element, the method returns `-1`.
Parameters
----------
searchElement: number
Search element.
fromIndex: integer (optional)
Array index from which to begin searching. If provided a negative value,
the method resolves the start index relative to the last array element.
Default: 0.
Returns
-------
idx: integer
Array index.
Examples
--------
> var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] );
> var idx = arr.indexOf( 2.0 )
-1
> idx = arr.indexOf( -1.0 )
2
{{alias}}.prototype.join( [separator] )
Serializes an array by joining all array elements as a string.
Parameters
----------
separator: string (optional)
String delineating array elements. Default: ','.
Returns
-------
str: string
Array serialized as a string.
Examples
--------
> var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] );
> arr.join( '|' )
'1|0|-1'
{{alias}}.prototype.keys()
Returns an iterator for iterating over array keys.
Returns
-------
iter: Iterator
Iterator for iterating over array keys.
Examples
--------
> var arr = new {{alias}}( [ 1.0, -1.0 ] );
> it = arr.keys();
> it.next().value
0
> it.next().value
1
> it.next().done
true
{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] )
Returns the index of the last array element strictly equal to a search
element.
The method iterates from the last array element to the first array element.
The method does not distinguish between signed and unsigned zero.
If unable to locate a search element, the method returns `-1`.
Parameters
----------
searchElement: number
Search element.
fromIndex: integer (optional)
Array index from which to begin searching. If provided a negative value,
the method resolves the start index relative to the last array element.
Default: -1.
Returns
-------
idx: integer
array index.
Examples
--------
> var arr = new {{alias}}( [ 1.0, 0.0, -1.0, 0.0, 1.0 ] );
> var idx = arr.lastIndexOf( 2.0 )
-1
> idx = arr.lastIndexOf( 0.0 )
3
{{alias}}.prototype.map( fcn[, thisArg] )
Maps each array element to an element in a new typed array.
A provided function is provided the following arguments:
- value: array element.
- index: array index.
- arr: array on which the method is invoked.
The returned array has the same data type as the host array.
Parameters
----------
fcn: Function
Function which maps array elements to elements in the new array.
thisArg: Any (optional)
Callback execution context.
Returns
-------
out: Float32Array
A typed array.
Examples
--------
> var arr1 = new {{alias}}( [ 1.0, 0.0, -1.0 ] );
> function fcn( v ) { return v * 2.0; };
> var arr2 = arr1.map( fcn );
<Float32Array>[ 2.0, 0.0, -2.0 ]
{{alias}}.prototype.reduce( fcn[, initialValue] )
Applies a function against an accumulator and each element in an array and
returns the accumulated result.
The provided function is provided the following arguments:
- acc: accumulated result.
- value: current array element.
- index: index of the current array element.
- arr: array on which the method is invoked.
If provided an initial value, the method invokes a provided function with
the initial value as the first argument and the first array element as the
second argument.
If not provided an initial value, the method invokes a provided function
with the first array element as the first argument and the second array
element as the second argument.
Parameters
----------
fcn: Function
Function to apply.
initialValue: Any (optional)
Initial accumulation value.
Returns
-------
out: Any
Accumulated result.
Examples
--------
> var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] );
> function fcn( acc, v ) { return acc + (v*v); };
> var v = arr.reduce( fcn, 0.0 )
2.0
{{alias}}.prototype.reduceRight( fcn[, initialValue] )
Applies a function against an accumulator and each element in an array and
returns the accumulated result, iterating from right to left.
The provided function is provided the following arguments:
- acc: accumulated result.
- value: current array element.
- index: index of the current array element.
- arr: array on which the method is invoked.
If provided an initial value, the method invokes a provided function with
the initial value as the first argument and the last array element as the
second argument.
If not provided an initial value, the method invokes a provided function
with the last array element as the first argument and the second-to-last
array element as the second argument.
Parameters
----------
fcn: Function
Function to apply.
initialValue: Any (optional)
Initial accumulation value.
Returns
-------
out: Any
Accumulated result.
Examples
--------
> var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] );
> function fcn( acc, v ) { return acc + (v*v); };
> var v = arr.reduceRight( fcn, 0.0 )
2.0
{{alias}}.prototype.reverse()
Reverses an array *in-place*.
This method mutates the array on which the method is invoked.
Returns
-------
out: Float32Array
Modified array.
Examples
--------
> var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] )
<Float32Array>[ 1.0, 0.0, -1.0 ]
> arr.reverse()
<Float32Array>[ -1.0, 0.0, 1.0 ]
{{alias}}.prototype.set( arr[, offset] )
Sets array elements.
Parameters
----------
arr: ArrayLike
Source array containing array values to set.
offset: integer (optional)
Array index at which to start writing values. Default: 0.
Examples
--------
> var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] );
> arr.set( [ -2.0, 2.0 ], 1 );
> arr[ 1 ]
-2.0
> arr[ 2 ]
2.0
{{alias}}.prototype.slice( [begin[, end]] )
Copies array elements to a new array with the same underlying data type as
the host array.
If the method is unable to resolve indices to a non-empty array subsequence,
the method returns `null`.
Parameters
----------
begin: integer (optional)
Start element index (inclusive). If less than zero, the start index is
resolved relative to the last array element. Default: 0.
end: integer (optional)
End element index (exclusive). If less than zero, the end index is
resolved relative to the last array element. Default: arr.length.
Returns
-------
out: Float32Array
A typed array.
Examples
--------
> var arr1 = new {{alias}}( [ 1.0, 0.0, -1.0 ] );
> var arr2 = arr1.slice( 1 );
> arr2.length
2
> arr2[ 0 ]
0.0
> arr2[ 1 ]
-1.0
{{alias}}.prototype.some( predicate[, thisArg] )
Tests whether at least one array element passes a test implemented by a
predicate function.
A predicate function is provided the following arguments:
- value: array element.
- index: array index.
- arr: array on which the method is invoked.
Parameters
----------
predicate: Function
Predicate function which tests array elements. If a predicate function
returns a truthy value, a array element passes; otherwise, an array
element fails.
thisArg: Any (optional)
Callback execution context.
Returns
-------
bool: boolean
Boolean indicating whether at least one array element passes.
Examples
--------
> var arr = new {{alias}}( [ 1.0, -1.0 ] );
> function predicate( v ) { return ( v < 0.0 ); };
> arr.some( predicate )
true
{{alias}}.prototype.sort( [compareFunction] )
Sorts an array *in-place*.
The comparison function is provided two array elements per invocation: `a`
and `b`.
The comparison function return value determines the sort order as follows:
- If the comparison function returns a value less than zero, then the method
sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`).
- If the comparison function returns a value greater than zero, then the
method sorts `a` to an index higher than `b` (i.e., `b` should come *before*
`a`).
- If the comparison function returns zero, then the relative order of `a`
and `b` should remain unchanged.
This method mutates the array on which the method is invoked.
Parameters
----------
compareFunction: Function (optional)
Function which specifies the sort order. The default sort order is
ascending order.
Returns
-------
out: Float32Array
Modified array.
Examples
--------
> var arr = new {{alias}}( [ 1.0, -1.0, 0.0, 2.0, -2.0 ] );
> arr.sort()
<Float32Array>[ -2.0, -1.0, 0.0, 1.0, 2.0 ]
{{alias}}.prototype.subarray( [begin[, end]] )
Creates a new typed array over the same underlying ArrayBuffer and with the
same underlying data type as the host array.
If the method is unable to resolve indices to a non-empty array subsequence,
the method returns an empty typed array.
Parameters
----------
begin: integer (optional)
Start element index (inclusive). If less than zero, the start index is
resolved relative to the last array element. Default: 0.
end: integer (optional)
End element index (exclusive). If less than zero, the end index is
resolved relative to the last array element. Default: arr.length.
Returns
-------
out: Float32Array
A new typed array view.
Examples
--------
> var arr1 = new {{alias}}( [ 1.0, -1.0, 0.0, 2.0, -2.0 ] );
> var arr2 = arr1.subarray( 2 )
<Float32Array>[ 0.0, 2.0, -2.0 ]
{{alias}}.prototype.toLocaleString( [locales[, options]] )
Serializes an array as a locale-specific string.
Parameters
----------
locales: string|Array<string> (optional)
A BCP 47 language tag, or an array of such tags.
options: Object (optional)
Options.
Returns
-------
str: string
A typed array string representation.
Examples
--------
> var arr = new {{alias}}( [ 1.0, -1.0, 0.0 ] );
> arr.toLocaleString()
'1,-1,0'
{{alias}}.prototype.toString()
Serializes an array as a string.
Returns
-------
str: string
A typed array string representation.
Examples
--------
> var arr = new {{alias}}( [ 1.0, -1.0, 0.0 ] );
> arr.toString()
'1,-1,0'
{{alias}}.prototype.values()
Returns an iterator for iterating over array elements.
Returns
-------
iter: Iterator
Iterator for iterating over array elements.
Examples
--------
> var arr = new {{alias}}( [ 1.0, -1.0 ] );
> it = arr.values();
> it.next().value
1.0
> it.next().value
-1.0
> it.next().done
true
See Also
--------
|