53 template<
typename dtype>
56 if (!std::filesystem::exists(inFilename))
62 std::ifstream file(inFilename.c_str(), std::ios::in | std::ios::binary);
68 file.seekg(0, std::ifstream::end);
69 const uint32 fileSize =
static_cast<uint32>(file.tellg());
70 file.seekg(0, std::ifstream::beg);
72 std::vector<char> fileBuffer;
73 fileBuffer.reserve(fileSize);
74 file.read(fileBuffer.data(), fileSize);
76 if (file.bad() || file.fail())
83 NdArray<dtype> returnArray(
reinterpret_cast<dtype*
>(fileBuffer.data()), fileSize /
sizeof(dtype));
98 template<
typename dtype>
101 std::ifstream file(inFilename.c_str());
107 std::stringstream buffer;
108 buffer << file.rdbuf();
111 return fromstring<dtype>(buffer.str(), inSep);
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:37
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:139
Definition: Cartesian.hpp:40
NdArray< dtype > fromfile(const std::string &inFilename)
Definition: fromfile.hpp:54
std::uint32_t uint32
Definition: Types.hpp:40