53 template<
typename dtype>
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));
99 template<
typename dtype>
104 std::ifstream file(inFilename.c_str());
110 std::vector<dtype> values;
115 std::getline(file, line, inSep);
117 std::istringstream iss(line);
123 values.push_back(value);
126 catch (
const std::invalid_argument& ia)
128 std::cout <<
"Warning: fromfile: line " << lineNumber <<
'\n' << ia.what() << std::endl;
132 std::cout <<
"Warning: fromfile: line " << lineNumber << std::endl;
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
Provides simple filesystem functions.
Definition: Filesystem.hpp:40
Definition: Coordinate.hpp:45
NdArray< dtype > fromfile(const std::string &inFilename)
Definition: fromfile.hpp:54
std::uint32_t uint32
Definition: Types.hpp:40