using System.IO; namespace NumSharp { public partial class NDArray { /// /// Write array to a file as text or binary (default).

/// Data is always written in ‘C’ order, independent of the order of a.

The data produced by this method can be recovered using the function fromfile(). ///
/// An open file object, or a string containing a filename. /// https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.tofile.html public void tofile(string fid) { //TODO! support for sliced data (if sliced, clone and then save) unsafe { using (var fs = File.Open(fid, FileMode.OpenOrCreate)) using (var ums = new UnmanagedMemoryStream((byte*)this.Array.Address, this.Array.BytesLength)) { fs.SetLength(0); ums.CopyTo(fs); } } } } }