xtensor
xtensor copied to clipboard
load_csv<uint8_t> loads ASCII values
This code to load a binary matrix and prints its values results in the ASCII values of the elements being loaded, i.e. 48 and 49 instead of 0 and 1. Is this an unsupported use case of the API?
#include <iostream>
#include <fstream>
#include <xtensor/xarray.hpp>
#include <xtensor/xcsv.hpp>
#include <xtensor/xio.hpp>
#include <stdint.h>
int main() {
std::ifstream f;
f.open("/tmp/mymatrix.csv");
if (!f.is_open()) {
throw std::runtime_error("failed to open file");
}
xt::xarray<uint8_t> m = xt::load_csv<uint8_t>(f);
f.close();
std::cout << m << std::endl;
return 0;
}
Sample matrix file mymatrix.csv:
1,0,1
0,1,1
The output is:
{{49,48,49},
{48,49,49}}