2016-09-03 70 views
1

我需要std::vectordlib::matrix,但我不知道在编译时的矩阵大小;文档告诉我:DLIB C++如何使一个std ::向量的dlib :: matrix

// (Note that if you don't know the dimensionality of your vectors at compile time 
// you can change the 2 to a 0 and then set the size at runtime) 
typedef matrix<double,2,1> sample_type; 

确定,但我需要这个对象的std::vector,所以我必须对我的std::vector设置什么模板参数? 例如(get_dimensionality()给了我正确的dimensionanlity):

matrix<double,0,1> m; 
m.set_size(get_dimensionality(),1); 
std::vector<matrix<double,????????,1> v; 
v.push_back(m); 

什么号码在????????

回答

2

你有你的问题的答案。使用向量作为

std::vector<matrix<double, 0, 1> v; 

所以你可以设置每个元素的大小,因为它运行,你做的矩阵本身。

+0

但是如果我调整了后期...它仍然兼容?例如:v.at(0).set_size(get_dimensionality(),1);不再是,所以我改变了std :: vector中的对象类型... – volperossa