Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想做一些类似于MATLAB's 功能的事情:
MATLAB
mat = vec2mat(vec,matcol) mat = vec2mat(vec,matcol,padding) [mat,padded] = vec2mat(...)
但是在犰狳 c++ 库中,你知道怎么做吗?
我认为通过 reshape 实现类似的行为应该不难:
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 }
它不完全相同(它总是用 0 填充),但我认为它非常相似。