I'm trying to define a dynamic Matrix in C++ , using Eigen library . First I get the number of rows and columns as an input (nZ) then I define my Matrix in the following class but it doesn't let me to use (nZ) as the number of rows variable ! Do you have any idea what should I do?
GetParams Params ;
class Hamiltonian {
public:
Hamiltonian();
void SetHam0(double,double,int,double)
virtual ~Hamiltonian();
int nZ = Params.Get_nZ() ;private:
Eigen::MatrixXd U_on = Eigen::MatrixXd.setZero(nZ,1) ;
Eigen::MatrixXd Ham0 = Eigen::MatrixXd.setZero(nZ,nZ) ;
Eigen::MatrixXd mstar = Eigen::MatrixXd.setZero(nZ,nZ) ;
Eigen::MatrixXd U_v = Eigen::MatrixXd.setZero(nZ,1) ;};
nZ
valuation and allsetZero
calls must be done in the constructor. – Michael M.