57 template<
typename dtype>
67 if (inSep.compare(
"") == 0)
70 std::ifstream file(inFilename.c_str(), std::ios::in | std::ios::binary);
76 file.seekg(0, file.end);
77 const uint32 fileSize =
static_cast<uint32>(file.tellg());
78 file.seekg(0, file.beg);
80 const auto fileBuffer = std::make_unique<char[]>(fileSize);
81 file.read(fileBuffer.get(), fileSize);
83 if (file.bad() || file.fail())
90 NdArray<dtype> returnArray(
reinterpret_cast<dtype*
>(fileBuffer.get()), fileSize /
sizeof(dtype));
97 if (!(inSep.compare(
" ") == 0 || inSep.compare(
"\t") == 0 || inSep.compare(
"\n") == 0))
102 std::vector<dtype> values;
104 std::ifstream file(inFilename.c_str());
111 std::getline(file, line);
113 std::istringstream iss(line);
119 values.push_back(value);
122 catch (
const std::invalid_argument& ia)
124 std::cout <<
"Warning: fromfile: line " << lineNumber <<
"\n" << ia.what() << std::endl;
128 std::cout <<
"Warning: fromfile: line " << lineNumber << std::endl;