1
我有一些數學計算在C++,我正在轉向Eigen。以前我手動滾動了我自己的double*
陣列,也使用了GNU科學圖書館的gsl_matrix
。Eigen和動態分配
我困惑的是FAQ of Eigen的措辭。這是什麼意思,是否有某種引用計數和自動內存分配正在進行?
而我只需要確認,這仍是有效的徵:
// n and m are not known at compile-time
MatrixXd myMatrix(n, m);
MatrixXd *myMatrix2 = new MatrixXd(n, m);
myMatrix.resize(0,0); // destroyed by destructor once out-of-scope
myMatrix2->resize(0,0);
delete myMatrix2;
myMatrix2 = NULL; // deallocated properly