I wonder how can I create a matrix whose size is given from command line. It can be done trivially if it is a non template matrix class. But what if the matrix class is a template class (like in Eigen), how can I do to create a matrix whose size is given from command line?
template<int _row, int _col>
class Matrix{
...
};
int main{
// assign rows and cols dynamically
int row;
int col;
std::cin >> row >> col;
// Some procedures
Matrix<row, col> m;
return 0;
}
Edit:
Thanks @hyde and @marcinj. I thought there are some magic mechanism behind Eigen's implementation. By looking into the Eigen's code again, I think they use template arguments int _Cols, int _Rows
only for small matrix and define Dynamic
to be some constants like -1 and handle it on runtime.