26 #include <Eigen/Dense>
29 typedef Eigen::MatrixXd dMat;
30 typedef Eigen::VectorXd dVec;
32 #include <unsupported/Eigen/MatrixFunctions>
34 inline void removeRow(dMat& matrix,
unsigned int rowToRemove)
36 unsigned int numRows = matrix.rows()-1;
37 unsigned int numCols = matrix.cols();
39 if( rowToRemove < numRows )
40 matrix.block(rowToRemove,0,numRows-rowToRemove,numCols) = matrix.block(rowToRemove+1,0,numRows-rowToRemove,numCols);
42 matrix.conservativeResize(numRows,numCols);
45 inline void removeColumn(dMat& matrix,
unsigned int colToRemove)
47 unsigned int numRows = matrix.rows();
48 unsigned int numCols = matrix.cols()-1;
50 if( colToRemove < numCols )
51 matrix.block(0,colToRemove,numRows,numCols-colToRemove) = matrix.block(0,colToRemove+1,numRows,numCols-colToRemove);
53 matrix.conservativeResize(numRows,numCols);
56 inline void removeElement(dVec &vec,
unsigned int k)
60 std::copy(vec.data()+k+1,vec.data()+vec.size(),vec.data()+k);
61 vec.conservativeResize(vec.size()-1);
64 inline void addElement(dVec &vec,
unsigned int k,
const double &xk)
66 if (k >= vec.size()+1)
68 vec.conservativeResize(vec.size()+1);
69 std::copy(vec.data()+k,vec.data()+vec.size()-1,vec.data()+k+1);