nlcpy.empty

nlcpy.empty(shape, dtype=<class 'float'>, order='C')[source]

Returns a new array of given shape and type, without initializing entries.

Parameters
shapeint or sequence of int

Shape of the empty array, e.g., (2, 3) or 2.

dtypedtype, optional

Desired output dtype for the array, e.g, nlcpy.int64. Default is nlcpy.float64.

order{‘C’, ‘F’}, optional

Whether to store multi-dimensional data in row-major (C-style) or column-major (Fortran-style) order in memory.

Returns
outndarray

Array of uninitialized (arbitrary) data of the given shape, dtype, and order.

See also

empty_like

Returns a new array with the same shape and type as a given array.

ones

Returns a new array of given shape and type, filled with ones.

zeros

Returns a new array of given shape and type, filled with zeros.

full

Returns a new array of given shape and type, filled with fill_value.

Note

empty(), unlike zeros(), does not set the array values to zero, and may therefore be marginally faster. On the other hand, it requires the user to manually set all the values in the array, and should be used with caution.

Examples

>>> import nlcpy as vp
>>> vp.empty([2, 2]) 
array([[0., 0.],
       [0., 0.]])          # They are not always zero. (uninitialized)
>>> vp.empty([2, 2], dtype=int) 
array([[0, 0],
       [0, 0]])            # They are not always zero. (uninitialized)