xorbits.numpy.asfortranarray#
- xorbits.numpy.asfortranarray(a, dtype=None, *, like=None)[源代码]#
Return an array (ndim >= 1) laid out in Fortran order in memory.
- 参数
a (array_like) – Input array.
dtype (str or dtype object, optional) – By default, the data-type is inferred from the input data.
like (array_like, optional) –
Reference object to allow the creation of arrays which are not NumPy arrays. If an array-like passed in as
like
supports the__array_function__
protocol, the result will be defined by it. In this case, it ensures the creation of an array object compatible with that passed in via this argument.1.20.0(numpy) 新版功能.
- 返回
out – The input a in Fortran, or column-major, order.
- 返回类型
ndarray
参见
ascontiguousarray
Convert input to a contiguous (C order) array.
asanyarray
Convert input to an ndarray with either row or column-major memory order.
require
Return an ndarray that satisfies requirements.
ndarray.flags
Information about the memory layout of the array.
实际案例
Starting with a C-contiguous array:
>>> x = np.ones((2, 3), order='C') >>> x.flags['C_CONTIGUOUS'] True
Calling
asfortranarray
makes a Fortran-contiguous copy:>>> y = np.asfortranarray(x) >>> y.flags['F_CONTIGUOUS'] True >>> np.may_share_memory(x, y) False
Now, starting with a Fortran-contiguous array:
>>> x = np.ones((2, 3), order='F') >>> x.flags['F_CONTIGUOUS'] True
Then, calling
asfortranarray
returns the same object:>>> y = np.asfortranarray(x) >>> x is y True
Note: This function returns an array with at least one-dimension (1-d) so it will not preserve 0-d arrays.
This docstring was copied from numpy.