Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork0
stdlib-js/array-typed
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
About stdlib...
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 onGitHub, and please considerfinancially supporting stdlib. We greatly appreciate your continued support!
Create a typed array.
importtypedarrayfrom'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs';
Creates atyped array having a specifieddata type.
vararr=typedarray();// returns <Float64Array>
By default, the outputtyped array data type isfloat64. To specify an alternative data type, provide adtype argument.
vararr=typedarray('int32');// returns <Int32Array>
Returns atyped array having a specifiedlength.
vararr1=typedarray(5);// returns <Float64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0 ]vararr2=typedarray(5,'uint8');// returns <Uint8Array>[ 0, 0, 0, 0, 0 ]
Creates atyped array from anothertyped array.
vararr1=typedarray([5.0,-3.0,2.0]);// returns <Float64Array>[ 5.0, -3.0, 2.0 ]vararr2=typedarray(arr1);// returns <Float64Array>[ 5.0, -3.0, 2.0 ]vararr3=typedarray(arr1,'int32');// returns <Int32Array>[ 5, -3, 2 ]
Creates atyped array from an array-like object or iterable.
vararr1=typedarray([0.5,0.5,0.5]);// returns <Float64Array>[ 0.5, 0.5, 0.5 ]vararr2=typedarray([0.5,0.5,0.5],'float32');// returns <Float32Array>[ 0.5, 0.5, 0.5 ]
Ifdtype is complex number data type and an array-like object contains interleaved real and imaginary components, the array-like object must have a length which is a multiple of two.
Returns atyped array view of anArrayBuffer.
importArrayBufferfrom'https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs';varbuf=newArrayBuffer(32);vararr1=typedarray(buf);// returns <Float64Array>[ 0.0, 0.0, 0.0, 0.0 ]vararr2=typedarray(buf,'float32');// returns <Float32Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]vararr3=typedarray(buf,16);// returns <Float64Array>[ 0.0, 0.0 ]vararr4=typedarray(buf,16,'float32');// returns <Float32Array>[ 0.0, 0.0, 0.0, 0.0 ]vararr5=typedarray(buf,16,1);// returns <Float64Array>[ 0.0 ]vararr6=typedarray(buf,10,4,'int16');// returns <Int16Array>[ 0, 0, 0, 0 ]
- When providing a complex number array, if
dtypeis unspecified or the specified data type is not a complex number data type, the returned array contains interleaved real and imaginary components.
<!DOCTYPE html><htmllang="en"><body><scripttype="module">importrandufrom'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs';importtypedarrayfrom'https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@esm/index.mjs';vararr=typedarray(100,'float64');vari;for(i=0;i<arr.length;i++){arr[i]=randu()*100.0;}console.log(arr);</script></body></html>
@stdlib/array-complex128:Complex128Array.@stdlib/array-complex64:Complex64Array.@stdlib/array-float64:Float64Array.@stdlib/array-float32:Float32Array.@stdlib/array-int32:Int32Array.@stdlib/array-uint32:Uint32Array.@stdlib/array-int16:Int16Array.@stdlib/array-uint16:Uint16Array.@stdlib/array-int8:Int8Array.@stdlib/array-uint8:Uint8Array.@stdlib/array-uint8c:Uint8ClampedArray.
This package is part ofstdlib, a standard library 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 developstdlib, see the main projectrepository.
SeeLICENSE.
Copyright © 2016-2025. The StdlibAuthors.
About
Create a typed array.
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.