コード例 #1
0
ファイル: StrideTricks.cs プロジェクト: thild/numpy.net
        public static ndarray as_strided(ndarray x, npy_intp[] shape = null, npy_intp[] strides = null, bool subok = false, bool writeable = false)
        {
            var view = np.array(x, copy: false, subok: subok);

            if (shape != null)
            {
                NpyCoreApi.SetArrayDimsOrStrides(view, shape, shape.Length, true);
            }
            if (strides != null)
            {
                NpyCoreApi.SetArrayDimsOrStrides(view, strides, strides.Length, false);
            }

            if (view.flags.writeable && !writeable)
            {
                view.flags.writeable = false;
            }

            return(view);
        }