Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@stdlib/array-float32
Advanced tools
@stdlib/array-float32 is a package that provides utilities for creating and manipulating Float32 arrays. It is part of the larger @stdlib library, which is a collection of standard libraries for JavaScript and Node.js.
Creating a Float32Array
This feature allows you to create a new Float32Array from an array of numbers.
const Float32Array = require('@stdlib/array-float32');
const arr = new Float32Array([1.0, 2.0, 3.0, 4.0]);
console.log(arr);
Accessing elements
This feature allows you to access elements in the Float32Array using index notation.
const Float32Array = require('@stdlib/array-float32');
const arr = new Float32Array([1.0, 2.0, 3.0, 4.0]);
console.log(arr[0]); // 1.0
console.log(arr[1]); // 2.0
Setting elements
This feature allows you to set elements in the Float32Array using index notation.
const Float32Array = require('@stdlib/array-float32');
const arr = new Float32Array(4);
arr[0] = 1.0;
arr[1] = 2.0;
arr[2] = 3.0;
arr[3] = 4.0;
console.log(arr);
Typed array methods
This feature allows you to use various typed array methods such as subarray to manipulate the Float32Array.
const Float32Array = require('@stdlib/array-float32');
const arr = new Float32Array([1.0, 2.0, 3.0, 4.0]);
const subarray = arr.subarray(1, 3);
console.log(subarray); // Float32Array [ 2.0, 3.0 ]
The 'typedarray' package provides a polyfill for the JavaScript typed array API, which includes Float32Array. It is useful for environments that do not support typed arrays natively. Compared to @stdlib/array-float32, it is more focused on providing compatibility rather than additional utilities.
The 'buffer' package from Node.js provides a way to handle binary data directly. It includes support for creating and manipulating Float32Arrays. While it is more general-purpose and includes support for various binary data types, @stdlib/array-float32 is more specialized for Float32 arrays.
The 'ndarray' package provides a multidimensional array implementation for JavaScript. It supports various data types, including Float32. Compared to @stdlib/array-float32, 'ndarray' is more focused on multidimensional arrays and scientific computing.
We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.
The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.
When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.
To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!
Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in the platform byte order.
npm install @stdlib/array-float32
var Float32Array = require( '@stdlib/array-float32' );
A typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in the platform byte order.
var arr = new Float32Array();
// returns <Float32Array>
Returns a typed array having a specified length.
var arr = new Float32Array( 5 );
// returns <Float32Array>[ 0.0, 0.0, 0.0, 0.0, 0.0 ]
Creates a typed array from another typed array.
var Float64Array = require( '@stdlib/array-float64' );
var arr1 = new Float64Array( [ 0.5, 0.5, 0.5 ] );
var arr2 = new Float32Array( arr1 );
// returns <Float32Array>[ 0.5, 0.5, 0.5 ]
Creates a typed array from an array-like object
or iterable.
var arr = new Float32Array( [ 0.5, 0.5, 0.5 ] );
// returns <Float32Array>[ 0.5, 0.5, 0.5 ]
Returns a typed array view of an ArrayBuffer
.
var ArrayBuffer = require( '@stdlib/array-buffer' );
var buf = new ArrayBuffer( 16 );
var arr = new Float32Array( buf, 0, 4 );
// returns <Float32Array>[ 0.0, 0.0, 0.0, 0.0 ]
Number of bytes per view element.
var nbytes = Float32Array.BYTES_PER_ELEMENT;
// returns 4
Typed array constructor name.
var str = Float32Array.name;
// returns 'Float32Array'
Read-only property which returns the ArrayBuffer
referenced by the typed array.
var arr = new Float32Array( 5 );
var buf = arr.buffer;
// returns <ArrayBuffer>
Read-only property which returns the length (in bytes) of the typed array.
var arr = new Float32Array( 5 );
var byteLength = arr.byteLength;
// returns 20
Read-only property which returns the offset (in bytes) of the typed array from the start of its ArrayBuffer
.
var arr = new Float32Array( 5 );
var byteOffset = arr.byteOffset;
// returns 0
Number of bytes per view element.
var arr = new Float32Array( 5 );
var nbytes = arr.BYTES_PER_ELEMENT;
// returns 4
Read-only property which returns the number of view elements.
var arr = new Float32Array( 5 );
var len = arr.length;
// returns 5
Creates a new typed array from an array-like object
or an iterable.
var arr = Float32Array.from( [ 1.0, 2.0 ] );
// returns <Float32Array>[ 1.0, 2.0 ]
To invoke a function for each src
value, provide a callback function.
function mapFcn( v ) {
return v * 2.0;
}
var arr = Float32Array.from( [ 1.0, 2.0 ], mapFcn );
// returns <Float32Array>[ 2.0, 4.0 ]
A callback function is provided two arguments:
value
: source valueindex
: source indexTo set the callback execution context, provide a thisArg
.
function mapFcn( v ) {
this.count += 1;
return v * 2.0;
}
var ctx = {
'count': 0
};
var arr = Float32Array.from( [ 1.0, 2.0 ], mapFcn, ctx );
// returns <Float32Array>[ 2.0, 4.0 ]
var n = ctx.count;
// returns 2
Creates a new typed array from a variable number of arguments.
var arr = Float32Array.of( 1.0, 2.0 );
// returns <Float32Array>[ 1.0, 2.0 ]
Copies a sequence of elements within an array starting at start
and ending at end
(non-inclusive) to the position starting at target
.
var arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
// Copy the last two elements to the first two elements:
arr.copyWithin( 0, 3 );
var v = arr[ 0 ];
// returns 4.0
v = arr[ 1 ];
// returns 5.0
By default, end
equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an end
argument.
var arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
// Copy the first two elements to the last two elements:
arr.copyWithin( 3, 0, 2 );
var v = arr[ 3 ];
// returns 1.0
v = arr[ 4 ];
// returns 2.0
When a target
, start
, and/or end
index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example:
var arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
// Copy the first two elements to the last two elements:
arr.copyWithin( -2, -5, -3 );
var v = arr[ 3 ];
// returns 1.0
v = arr[ 4 ];
// returns 2.0
Returns an iterator for iterating over array key-value pairs.
var arr = new Float32Array( [ 1.0, 2.0 ] );
// Create an iterator:
var it = arr.entries();
// Iterate over key-value pairs...
var v = it.next().value;
// returns [ 0, 1.0 ]
v = it.next().value;
// returns [ 1, 2.0 ]
var bool = it.next().done;
// returns true
Tests whether all array elements pass a test implemented by a predicate
function.
function predicate( v ) {
return ( v <= 1.0 );
}
var arr = new Float32Array( [ 1.0, 2.0 ] );
var bool = arr.every( predicate );
// returns false
A predicate
function is provided three arguments:
value
: array elementindex
: array indexarr
: array on which the method is invokedTo set the callback execution context, provide a thisArg
.
function predicate( v ) {
this.count += 1;
return ( v >= 1.0 );
}
var ctx = {
'count': 0
};
var arr = new Float32Array( [ 1.0, 2.0 ] );
var bool = arr.every( predicate, ctx );
// returns true
var n = ctx.count;
// returns 2
Fills an array from a start
index to an end
index (non-inclusive) with a provided value
.
var arr = new Float32Array( 2 );
// Set all array elements to the same value:
arr.fill( 2.0 );
var v = arr[ 0 ];
// returns 2.0
v = arr[ 1 ];
// returns 2.0
// Set all array elements starting from the first index to the same value:
arr.fill( 3.0, 1 );
v = arr[ 0 ];
// returns 2.0
v = arr[ 1 ];
// returns 3.0
// Set all array elements, except the last element, to the same value:
arr.fill( 4.0, 0, arr.length-1 );
v = arr[ 0 ];
// returns 4.0
v = arr[ 1 ];
// returns 3.0
When a start
and/or end
index is negative, the respective index is determined relative to the last array element.
var arr = new Float32Array( 2 );
// Set all array elements, except the last element, to the same value:
arr.fill( 2.0, -arr.length, -1 );
var v = arr[ 0 ];
// returns 2.0
v = arr[ 1 ];
// returns 0.0
Creates a new array (of the same data type as the host array) which includes those elements for which a predicate
function returns a truthy value.
function predicate( v ) {
return ( v >= 2.0 );
}
var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var arr2 = arr1.filter( predicate );
// returns <Float32Array>[ 2.0, 3.0 ]
If a predicate
function does not return a truthy value for any array element, the method returns an empty array.
function predicate( v ) {
return ( v >= 10.0 );
}
var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var arr2 = arr1.filter( predicate );
// returns <Float32Array>[]
A predicate
function is provided three arguments:
value
: array elementindex
: array indexarr
: array on which the method is invokedTo set the callback execution context, provide a thisArg
.
function predicate( v ) {
this.count += 1;
return ( v >= 2.0 );
}
var ctx = {
'count': 0
};
var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var arr2 = arr1.filter( predicate, ctx );
var n = ctx.count;
// returns 3
Returns the first array element for which a provided predicate
function returns a truthy value.
function predicate( v ) {
return ( v > 2.0 );
}
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var v = arr.find( predicate );
// returns 3.0
If a predicate
function does not return a truthy value for any array element, the method returns undefined
.
function predicate( v ) {
return ( v < 1.0 );
}
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var v = arr.find( predicate );
// returns undefined
A predicate
function is provided three arguments:
value
: array elementindex
: array indexarr
: array on which the method is invokedTo set the callback execution context, provide a thisArg
.
function predicate( v ) {
this.count += 1;
return ( v > 2.0 );
}
var ctx = {
'count': 0
};
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var v = arr.find( predicate, ctx );
// returns 3.0
var n = ctx.count;
// returns 3
Returns the index of the first array element for which a provided predicate
function returns a truthy value.
function predicate( v ) {
return ( v >= 3.0 );
}
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var idx = arr.findIndex( predicate );
// returns 2
If a predicate
function does not return a truthy value for any array element, the method returns -1
.
function predicate( v ) {
return ( v < 1.0 );
}
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var idx = arr.findIndex( predicate );
// returns -1
A predicate
function is provided three arguments:
value
: array elementindex
: array indexarr
: array on which the method is invokedTo set the callback execution context, provide a thisArg
.
function predicate( v ) {
this.count += 1;
return ( v >= 3.0 );
}
var ctx = {
'count': 0
};
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var idx = arr.findIndex( predicate, ctx );
// returns 2
var n = ctx.count;
// returns 3
Invokes a callback for each array element.
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var str = '';
function fcn( v, i ) {
str += i + ':' + v;
if ( i < arr.length-1 ) {
str += ' ';
}
}
arr.forEach( fcn );
console.log( str );
// => '0:1 1:2 2:3'
The callback is provided three arguments:
value
: array elementindex
: array indexarr
: array on which the method is invokedTo set the callback execution context, provide a thisArg
.
function fcn() {
this.count += 1;
}
var ctx = {
'count': 0
};
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
arr.forEach( fcn, ctx );
var n = ctx.count;
// returns 3
Returns a boolean
indicating whether an array includes a search element.
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var bool = arr.includes( 3.0 );
// returns true
bool = arr.includes( 0.0 );
// returns false
By default, the method searches the entire array (fromIndex = 0
). To begin searching from a specific array index, provide a fromIndex
.
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var bool = arr.includes( 1.0, 1 );
// returns false
When a fromIndex
is negative, the starting index is resolved relative to the last array element.
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var bool = arr.includes( 1.0, -2 );
// returns false
The method does not distinguish between signed and unsigned zero.
Returns the index of the first array element strictly equal to a search element.
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var idx = arr.indexOf( 3.0 );
// returns 2
idx = arr.indexOf( 0.0 );
// returns -1
By default, the method searches the entire array (fromIndex = 0
). To begin searching from a specific array index, provide a fromIndex
.
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var idx = arr.indexOf( 1.0, 1 );
// returns -1
When a fromIndex
is negative, the starting index is resolved relative to the last array element.
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var idx = arr.indexOf( 1.0, -2 );
// returns -1
The method does not distinguish between signed and unsigned zero.
Serializes an array by joining all array elements as a string.
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var str = arr.join();
// returns '1,2,3'
By default, the method delineates array elements using a comma ,
. To specify a custom separator, provide a separator
string.
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var str = arr.join( '|' );
// returns '1|2|3'
Returns an iterator for iterating over array keys.
var arr = new Float32Array( [ 1.0, 2.0 ] );
// Create an iterator:
var it = arr.keys();
// Iterate over keys...
var v = it.next().value;
// returns 0
v = it.next().value;
// returns 1
var bool = it.next().done;
// returns true
Returns the index of the last array element strictly equal to a search element, iterating from right to left.
var arr = new Float32Array( [ 1.0, 0.0, 2.0, 0.0, 1.0 ] );
var idx = arr.lastIndexOf( 0.0 );
// returns 3
idx = arr.lastIndexOf( 3.0 );
// returns -1
By default, the method searches the entire array (fromIndex = -1
). To begin searching from a specific array index, provide a fromIndex
.
var arr = new Float32Array( [ 1.0, 0.0, 2.0, 0.0, 1.0 ] );
var idx = arr.lastIndexOf( 0.0, 2 );
// returns 1
When a fromIndex
is negative, the starting index is resolved relative to the last array element.
var arr = new Float32Array( [ 1.0, 0.0, 2.0, 0.0, 1.0 ] );
var idx = arr.lastIndexOf( 0.0, -3 );
// returns 1
The method does not distinguish between signed and unsigned zero.
Maps each array element to an element in a new array having the same data type as the host array.
function fcn( v ) {
return v * 2.0;
}
var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var arr2 = arr1.map( fcn );
// returns <Float32Array>[ 2.0, 4.0, 6.0 ]
A callback is provided three arguments:
value
: array elementindex
: array indexarr
: array on which the method is invokedTo set the callback execution context, provide a thisArg
.
function fcn( v ) {
this.count += 1;
return v * 2.0;
}
var ctx = {
'count': 0
};
var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var arr2 = arr1.map( fcn, ctx );
var n = ctx.count;
// returns 3
Applies a function against an accumulator and each element in an array and returns the accumulated result.
function fcn( acc, v ) {
return acc + ( v*v );
}
var arr = new Float32Array( [ 2.0, 1.0, 3.0 ] );
var v = arr.reduce( fcn );
// returns 12.0
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.
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.
function fcn( acc, v ) {
return acc + ( v*v );
}
var arr = new Float32Array( [ 2.0, 1.0, 3.0 ] );
var v = arr.reduce( fcn, 0.0 );
// returns 14.0
A callback is provided four arguments:
acc
: accumulated resultvalue
: array elementindex
: array indexarr
: array on which the method is invokedApplies a function against an accumulator and each element in an array and returns the accumulated result, iterating from right to left.
function fcn( acc, v ) {
return acc + ( v*v );
}
var arr = new Float32Array( [ 2.0, 1.0, 3.0 ] );
var v = arr.reduceRight( fcn );
// returns 8.0
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.
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.
function fcn( acc, v ) {
return acc + ( v*v );
}
var arr = new Float32Array( [ 2.0, 1.0, 3.0 ] );
var v = arr.reduce( fcn, 0.0 );
// returns 14.0
A callback is provided four arguments:
acc
: accumulated resultvalue
: array elementindex
: array indexarr
: array on which the method is invokedReverses an array in-place (thus mutating the array on which the method is invoked).
var arr = new Float32Array( [ 2.0, 0.0, 3.0 ] );
// Reverse the array:
arr.reverse();
var v = arr[ 0 ];
// returns 3.0
v = arr[ 1 ];
// returns 0.0
v = arr[ 2 ];
// returns 2.0
Sets array elements.
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
// returns <Float32Array>[ 1.0, 2.0, 3.0 ]
// Set the first two array elements:
arr.set( [ 4.0, 5.0 ] );
var v = arr[ 0 ];
// returns 4.0
v = arr[ 1 ];
// returns 5.0
By default, the method starts writing values at the first array index. To specify an alternative index, provide an index offset
.
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
// returns <Float32Array>[ 1.0, 2.0, 3.0 ]
// Set the last two array elements:
arr.set( [ 4.0, 5.0 ], 1 );
var v = arr[ 1 ];
// returns 4.0
v = arr[ 2 ];
// returns 5.0
Copies array elements to a new array with the same underlying data type as the host array.
var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var arr2 = arr1.slice();
var bool = ( arr1 === arr2 );
// returns false
bool = ( arr1.buffer === arr2.buffer );
// returns false
var v = arr2[ 0 ];
// returns 1.0
v = arr2[ 1 ];
// returns 2.0
v = arr2[ 2 ];
// returns 3.0
By default, the method copies elements beginning with the first array element. To specify an alternative array index at which to begin copying, provide a begin
index (inclusive).
var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var arr2 = arr1.slice( 1 );
var len = arr2.length;
// returns 2
var v = arr2[ 0 ];
// returns 2.0
v = arr2[ 1 ];
// returns 3.0
By default, the method copies all array elements after begin
. To specify an alternative array index at which to end copying, provide an end
index (exclusive).
var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var arr2 = arr1.slice( 0, 2 );
var len = arr2.length;
// returns 2
var v = arr2[ 0 ];
// returns 1.0
v = arr2[ 1 ];
// returns 2.0
When a begin
and/or end
index is negative, the respective index is determined relative to the last array element.
var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var arr2 = arr1.slice( -arr1.length, -1 );
var len = arr2.length;
// returns 2
var v = arr2[ 0 ];
// returns 1.0
v = arr2[ 1 ];
// returns 2.0
Tests whether at least one array element passes a test implemented by a predicate
function.
function predicate( v ) {
return ( v >= 2.0 );
}
var arr = new Float32Array( [ 1.0, 2.0 ] );
var bool = arr.some( predicate );
// returns true
A predicate
function is provided three arguments:
value
: array elementindex
: array indexarr
: array on which the method is invokedTo set the callback execution context, provide a thisArg
.
function predicate( v ) {
this.count += 1;
return ( v >= 2.0 );
}
var ctx = {
'count': 0
};
var arr = new Float32Array( [ 1.0, 1.0 ] );
var bool = arr.some( predicate, ctx );
// returns false
var n = ctx.count;
// returns 2
Sorts an array in-place (thus mutating the array on which the method is invoked).
var arr = new Float32Array( [ 2.0, 3.0, 0.0 ] );
// Sort the array (in ascending order):
arr.sort();
var v = arr[ 0 ];
// returns 0.0
v = arr[ 1 ];
// returns 2.0
v = arr[ 2 ];
// returns 3.0
By default, the method sorts array elements in ascending order. To impose a custom order, provide a compareFunction
.
function descending( a, b ) {
return b - a;
}
var arr = new Float32Array( [ 2.0, 3.0, 0.0 ] );
// Sort the array (in descending order):
arr.sort( descending );
var v = arr[ 0 ];
// returns 3.0
v = arr[ 1 ];
// returns 2.0
v = arr[ 2 ];
// returns 0.0
The comparison function is provided two array elements, a
and b
, per invocation, and its return value determines the sort order as follows:
a
to an index lower than b
(i.e., a
should come before b
).a
to an index higher than b
(i.e., b
should come before a
).a
and b
should remain unchanged.Creates a new typed array view over the same underlying ArrayBuffer
and with the same underlying data type as the host array.
var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var arr2 = arr1.subarray();
// returns <Float32Array>[ 1.0, 2.0, 3.0 ]
var bool = ( arr1.buffer === arr2.buffer );
// returns true
By default, the method creates a typed array view beginning with the first array element. To specify an alternative array index at which to begin, provide a begin
index (inclusive).
var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var arr2 = arr1.subarray( 1 );
// returns <Float32Array>[ 2.0, 3.0 ]
var bool = ( arr1.buffer === arr2.buffer );
// returns true
By default, the method creates a typed array view which includes all array elements after begin
. To limit the number of array elements after begin
, provide an end
index (exclusive).
var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var arr2 = arr1.subarray( 0, 2 );
// returns <Float32Array>[ 1.0, 2.0 ]
var bool = ( arr1.buffer === arr2.buffer );
// returns true
When a begin
and/or end
index is negative, the respective index is determined relative to the last array element.
var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var arr2 = arr1.subarray( -arr1.length, -1 );
// returns <Float32Array>[ 1.0, 2.0 ]
var bool = ( arr1.buffer === arr2.buffer );
// returns true
If the method is unable to resolve indices to a non-empty array subsequence, the method returns an empty typed array.
var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var arr2 = arr1.subarray( 10, -1 );
// returns <Float32Array>[]
Serializes an array as a locale-specific string
.
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var str = arr.toLocaleString();
// returns '1,2,3'
Serializes an array as a string
.
var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] );
var str = arr.toString();
// returns '1,2,3'
Returns an iterator for iterating over array elements.
var arr = new Float32Array( [ 1.0, 2.0 ] );
// Create an iterator:
var it = arr.values();
// Iterate over array elements...
var v = it.next().value;
// returns 1.0
v = it.next().value;
// returns 2.0
var bool = it.next().done;
// returns true
var randu = require( '@stdlib/random-base-randu' );
var ctor = require( '@stdlib/array-float32' );
var arr;
var i;
arr = new ctor( 10 );
for ( i = 0; i < arr.length; i++ ) {
arr[ i ] = randu() * 100.0;
}
console.log( arr );
@stdlib/array-buffer
: ArrayBuffer.@stdlib/array-float64
: Float64Array.@stdlib/array-int16
: Int16Array.@stdlib/array-int32
: Int32Array.@stdlib/array-int8
: Int8Array.@stdlib/array-uint16
: Uint16Array.@stdlib/array-uint32
: Uint32Array.@stdlib/array-uint8
: Uint8Array.@stdlib/array-uint8c
: Uint8ClampedArray.This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
See LICENSE.
Copyright © 2016-2024. The Stdlib Authors.
0.2.2 (2024-07-27)
<section class="commits">A total of 1 person contributed to this release. Thank you to this contributor:
FAQs
Float32Array.
The npm package @stdlib/array-float32 receives a total of 338,565 weekly downloads. As such, @stdlib/array-float32 popularity was classified as popular.
We found that @stdlib/array-float32 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.