示例#1
0
        public static NDArray array(Array array, Type dtype = null, int ndim = 1)
        {
            dtype = (dtype == null) ? array.GetType().GetElementType() : dtype;

            var nd = new NDArray(dtype, new Shape(new int[] { array.Length }));

            if ((array.Rank == 1) && (!array.GetType().GetElementType().IsArray))
            {
                nd.ReplaceData(array);
            }
            else
            {
                throw new Exception("Method is not implemeneted for multidimensional arrays or jagged arrays.");
            }

            return(dtype == null ? nd : nd.astype(dtype));
        }