[uBLAS] Matrix creation vs resize
I need to remove rows from a matrix if it fails a comparison. I have two
possible options to remove the matrix rows. Option 1 adds a row to the new
matrix for each row from the old matrix that passes the comparison. Option
2 keeps track of the rows from the old matrix that passed the comparison and
then creates a new matrix all at once. I'm wondering which option is more
efficient or is there a simpler way to achieve the same results?
Ryan
Option 1
void(
matrix<double> const& H,
matrix<double> const& P,
matrix<double> const& R,
vector<double> const& v)
{
double const rejection_criterion = 2;
matrix<double> M = prod(H, matrix<double>(prod(P, trans(H))) + R;
matrix<double> result;
int matrix_size = 1;
for (unsigned i = 0; i < v.size(); ++i) {
if ( v[i] * v[i] < rejection_criterion * M(i,i)) {
result.resize(matrix_size, H.size2(), true);
matrix_row
participants (1)
-
Ryan