Commit 4d29deb3da1f349213c061fe320acbbd7cad46f1

Authored by Brendan Klare
1 parent 3b6db8cd

Helper function to remove item from square matrix

Showing 1 changed file with 19 additions and 0 deletions
openbr/core/eigenutils.cpp
@@ -76,3 +76,22 @@ float eigStd(const Eigen::MatrixXf& x) { @@ -76,3 +76,22 @@ float eigStd(const Eigen::MatrixXf& x) {
76 float mean = eigMean(x); 76 float mean = eigMean(x);
77 return sqrt((x.array() - mean).pow(2).sum() / (x.cols() * x.rows())); 77 return sqrt((x.array() - mean).pow(2).sum() / (x.cols() * x.rows()));
78 } 78 }
  79 +
  80 +MatrixXf removeRowCol(MatrixXf X, int row, int col) {
  81 + MatrixXf Y(X.rows() - 1,X.cols() - 1);
  82 +
  83 + for (int i1 = 0, i2 = 0; i1 < X.rows(); i1++) {
  84 + if (i1 == row)
  85 + continue;
  86 + i2++;
  87 +
  88 + for (int j1 = 0, j2 = 0; j1 < X.cols(); j1++) {
  89 + if (j1 == col)
  90 + continue;
  91 + j2++;
  92 +
  93 + Y(i2,j2) = X(i1,j1);
  94 + }
  95 + }
  96 + return Y;
  97 +}