Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Create an uninitialized ndarray having the same shape and data type as a provided ndarray.

License

NotificationsYou must be signed in to change notification settings

stdlib-js/ndarray-empty-like

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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!

emptyLike

NPM versionBuild StatusCoverage Status

Create an uninitializedndarray having the same shape anddata type as a provided ndarray.

Usage

importemptyLikefrom'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty-like@deno/mod.js';

emptyLike( x[, options] )

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 (seendarray). Default:'throw'.
  • submode: a mode array which specifies for each dimension how to handle subscripts which exceed array dimensions (seendarray). 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'

Notes

  • 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.

Examples

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);}

See Also


Notice

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.

Community

Chat


License

SeeLICENSE.

Copyright

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

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp