Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1
Create an uninitialized ndarray having the same shape and data type as a provided ndarray.
License
stdlib-js/ndarray-empty-like
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 an uninitializedndarray having the same shape anddata type as a provided ndarray.
importemptyLikefrom'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@deno/mod.js';
Creates an uninitializedndarray having the same shape anddata type as a provided ndarray.
importzerosfrom'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@deno/mod.js';varx=zeros([2,2]);// returns <ndarray>vary=emptyLike(x);// returns <ndarray>varsh=y.shape;// returns [ 2, 2 ]vardt=y.dtype;// returns 'float64'
The function supports the followingoptions:
- dtype: outputndarraydata type. Overrides the input ndarray's inferreddata type.
- shape: outputndarray shape. Overrides the input ndarray's inferred shape.
- order: specifies whether the outputndarray should be
'row-major'(C-style) or'column-major'(Fortran-style). Overrides the input ndarray's inferred order. - mode: specifies how to handle indices which exceed array dimensions (see
ndarray). Default:'throw'. - submode: a mode array which specifies for each dimension how to handle subscripts which exceed array dimensions (see
ndarray). If provided fewer modes than dimensions, the constructor recycles modes using modulo arithmetic. Default:[ options.mode ].
To override either thedtype,shape, ororder, specify the corresponding option. For example, to override the inferreddata type,
importzerosfrom'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@deno/mod.js';varx=zeros([2,2]);// returns <ndarray>vardt=x.dtype;// returns 'float64'vary=emptyLike(x,{'dtype':'int32'});// returns <ndarray>varsh=y.shape;// returns [ 2, 2 ]dt=y.dtype;// returns 'int32'
- If the resolved output data type is
'generic', the function always returns a zero-filled array. - For returnedndarrays whose underlying memory isnot initialized, memory contents are unknown and may containsensitive data.
importdtypesfrom'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@deno/mod.js';importemptyfrom'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@deno/mod.js';importemptyLikefrom'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@deno/mod.js';// Get a list of data types:vardt=dtypes();// Generate uninitialized arrays...varx;vary;vari;for(i=0;i<dt.length;i++){x=empty([2,2],{'dtype':dt[i]});y=emptyLike(x);console.log(y.data);}
@stdlib/ndarray-empty:create an uninitialized ndarray having a specified shape and data type.@stdlib/ndarray-zeros-like:create a zero-filled ndarray having the same shape and data type as a provided ndarray.
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 an uninitialized ndarray having the same shape and data type as a provided ndarray.
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.