From 4d29deb3da1f349213c061fe320acbbd7cad46f1 Mon Sep 17 00:00:00 2001 From: Brendan Klare Date: Tue, 27 May 2014 20:49:41 -0400 Subject: [PATCH] Helper function to remove item from square matrix --- openbr/core/eigenutils.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+), 0 deletions(-) diff --git a/openbr/core/eigenutils.cpp b/openbr/core/eigenutils.cpp index f927b33..ad0dc48 100644 --- a/openbr/core/eigenutils.cpp +++ b/openbr/core/eigenutils.cpp @@ -76,3 +76,22 @@ float eigStd(const Eigen::MatrixXf& x) { float mean = eigMean(x); return sqrt((x.array() - mean).pow(2).sum() / (x.cols() * x.rows())); } + +MatrixXf removeRowCol(MatrixXf X, int row, int col) { + MatrixXf Y(X.rows() - 1,X.cols() - 1); + + for (int i1 = 0, i2 = 0; i1 < X.rows(); i1++) { + if (i1 == row) + continue; + i2++; + + for (int j1 = 0, j2 = 0; j1 < X.cols(); j1++) { + if (j1 == col) + continue; + j2++; + + Y(i2,j2) = X(i1,j1); + } + } + return Y; +} -- libgit2 0.21.4