nlcpy.sca.convert_optimized_array

nlcpy.sca.convert_optimized_array(a, dtype=None) ndarray

Converts existing ndarrays into optimized ndarrays, whose strides are adjusted to improve perfomance, filled with zeros.

Parameters
andarray

The ndarray to be optimized.

dtypestr or dtype, optional

The type of the output array. If dtype is not given or None, infer the data type from input arguments.

Returns
optimized_arrayndarray

The optimized ndarray.

Note

This function returns a copy of the input ndarray a, not a view. So, id(optimized_array) is different from that of id(a).

Examples

>>> import nlcpy as vp
>>> x = vp.random.rand(1000, 1000)
>>> x_opt = vp.sca.convert_optimized_array(x, dtype='f8')
>>> x_opt.strides
(8008, 8)
>>> (x == x_opt).all()
array(True)