UNINIT - Create an uninitialized variable (like ZEROS but faster)

バージョン 1.0.0.0 (7.24 KB) 作成者: James Tursa
UNINIT is similar to ZEROS, except UNINIT returns uninitialized values instead of zero values.
ダウンロード: 1.1K
更新 2011/5/9

ライセンスの表示

UNINIT is very similar to the ZEROS function, except that UNINIT returns an uninitialized array instead of a zero-filled array. Thus, UNINIT is faster than the ZEROS function for large size arrays. Since the return variable is uninitialized, the user must take care to assign values to the elements before using them. UNINIT is useful for preallocation of an array where you know the elements will be assigned values before using them.

Syntax (nearly identical to the ZEROS function)

B = uninit
B = uninit(n)
B = uninit(m,n)
B = uninit([m n])
B = uninit(m,n,p,...)
B = uninit([m n p ...])
B = uninit(size(A))
B = uninit(m, n,...,classname)
B = uninit([m,n,...],classname)
B = uninit(m, n,...,complexity)
B = uninit([m,n,...],complexity)
B = uninit(m, n,...,classname,complexity)
B = uninit([m,n,...],classname,complexity)

Description

B = uninit
Returns a 1-by-1 scalar uninitialized value.

B = uninit(n)
Returns an n-by-n matrix of uninitialized values. An error message
appears if n is not a scalar.

B = uninit(m,n) or B = uninit([m n])
Returns an m-by-n matrix of uninitialized values.

B = uninit(m,n,p,...) or B = uninit([m n p ...])
Returns an m-by-n-by-p-by-... array of uninitialized values. The
size inputs m, n, p, ... should be nonnegative integers. Negative
integers are treated as 0.

B = uninit(size(A))
Returns an array the same size as A consisting of all uninitialized
values.

If any of the numeric size inputs are empty, they are taken to be 0.

The optional classname argument can be used with any of the above.
classname is a string specifying the data type of the output.
classname can have the following values:
'double', 'single', 'int8', 'uint8', 'int16', 'uint16',
'int32', 'uint32', 'int64', 'uint64', 'logical', or 'char'.
(Note: 'logical' and 'char' are not allowed in the ZEROS function)
The default classname is 'double'.

The optional complexity argument can be used with any of the above.
complexity can be 'real' or 'complex', except that 'logical' and 'char'
outputs cannot be complex. (this option not allowed in the ZEROS function)
The default complexity is 'real'.

UNINIT is typically self building. That is, the first time you call UNINIT, the uninit.m file recognizes that the mex routine needs to be compiled and then the compilation will happen automatically. UNINIT uses the undocumented MATLAB API function mxCreateUninitNumericMatrix. It has been tested in PC WinXP versions R2006b through R2011a, but may not work in future versions or non-PC versions of MATLAB.

引用

James Tursa (2024). UNINIT - Create an uninitialized variable (like ZEROS but faster) (https://www.mathworks.com/matlabcentral/fileexchange/31362-uninit-create-an-uninitialized-variable-like-zeros-but-faster), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2006b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersArithmetic Operations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
バージョン 公開済み リリース ノート
1.0.0.0