I want to do something similar to MATLAB
's function:
mat = vec2mat(vec,matcol)
mat = vec2mat(vec,matcol,padding)
[mat,padded] = vec2mat(...)
but in armadillo c++ library,开发者_如何学Go Do you know How?.
It shouldn't be so hard to achieve similar behavior with reshape I think:
mat vec2mat(vec V, size_t cols) {
size_t rows = std::ceil(V.n_elems / double(cols));
return V.reshape(cols, rows);// return the original vector as matrix
}
It's not exactly the same (it padds always with 0), but it's quite similar I think.
精彩评论