c++ - Read ublas vectors from binary file or init it with array[] -
why cannot read ublas vectors binary file in way (instead of reading 1 element @ time):
boost::numeric::ublas::vector<double> floatvector(10); myfile.read( (char *)&vector, 10 * sizeof(double));
is there way initialize ublas vector array?
double d[10];
you can use this
double array[] = {1., 2., 3.}; boost::numeric::ublas::vector<double> v(sizeof(array) / sizeof(*array)); std::copy(array, array + sizeof(array) / sizeof(*array), v.data().begin());