Skip to content

Commit

Permalink
perf: remove evecs_, evals_
Browse files Browse the repository at this point in the history
  • Loading branch information
atsushi421 committed Nov 22, 2024
1 parent f557f39 commit 106cbaa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 33 deletions.
31 changes: 1 addition & 30 deletions include/pclomp/voxel_grid_covariance_omp.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,14 @@ namespace pclomp
struct Leaf
{
/** \brief Constructor.
* Sets \ref nr_points, \ref icov_, \ref mean_ and \ref evals_ to 0 and \ref cov_ and \ref evecs_ to the identity matrix
* Sets \ref nr_points, \ref icov_, \ref mean_ and \ref cov_ to the identity matrix
*/
Leaf () :
nr_points (0),
mean_ (Eigen::Vector3d::Zero ()),
centroid (),
cov_ (Eigen::Matrix3d::Identity ()),
icov_ (Eigen::Matrix3d::Zero ()),
evecs_ (Eigen::Matrix3d::Identity ()),
evals_ (Eigen::Vector3d::Zero ())
{
}

Expand Down Expand Up @@ -138,26 +136,6 @@ namespace pclomp
return (mean_);
}

/** \brief Get the eigen vectors of the voxel covariance.
* \note Order corresponds with \ref getEvals
* \return matrix whose columns contain eigen vectors
*/
Eigen::Matrix3d
getEvecs () const
{
return (evecs_);
}

/** \brief Get the eigen values of the voxel covariance.
* \note Order corresponds with \ref getEvecs
* \return vector of eigen values
*/
Eigen::Vector3d
getEvals () const
{
return (evals_);
}

/** \brief Get the number of points contained by this voxel.
* \return number of points
*/
Expand All @@ -183,13 +161,6 @@ namespace pclomp

/** \brief Inverse of voxel covariance matrix */
Eigen::Matrix3d icov_;

/** \brief Eigen vectors of voxel covariance matrix */
Eigen::Matrix3d evecs_;

/** \brief Eigen values of voxel covariance matrix */
Eigen::Vector3d evals_;

};

/** \brief Pointer to VoxelGridCovariance leaf structure */
Expand Down
6 changes: 3 additions & 3 deletions include/pclomp/voxel_grid_covariance_omp_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ pclomp::VoxelGridCovariance<PointT>::applyFilter (PointCloud &output)
// Eigen values and vectors calculated to prevent near singular matrices
Eigen::SelfAdjointEigenSolver<Eigen::Matrix3d> eigensolver;
Eigen::Matrix3d eigen_val;
Eigen::Matrix3d eigen_vec;
Eigen::Vector3d pt_sum;

// Eigen values less than a threshold of max eigen value are inflated to a set fraction of the max eigen value.
Expand Down Expand Up @@ -332,7 +333,7 @@ pclomp::VoxelGridCovariance<PointT>::applyFilter (PointCloud &output)
//Normalize Eigen Val such that max no more than 100x min.
eigensolver.compute (leaf.cov_);
eigen_val = eigensolver.eigenvalues ().asDiagonal ();
leaf.evecs_ = eigensolver.eigenvectors ();
eigen_vec = eigensolver.eigenvectors ();

if (eigen_val (0, 0) < 0 || eigen_val (1, 1) < 0 || eigen_val (2, 2) <= 0)
{
Expand All @@ -352,9 +353,8 @@ pclomp::VoxelGridCovariance<PointT>::applyFilter (PointCloud &output)
eigen_val (1, 1) = min_covar_eigvalue;
}

leaf.cov_ = leaf.evecs_ * eigen_val * leaf.evecs_.inverse ();
leaf.cov_ = eigen_vec * eigen_val * eigen_vec.inverse ();
}
leaf.evals_ = eigen_val.diagonal ();

leaf.icov_ = leaf.cov_.inverse ();
if (leaf.icov_.maxCoeff () == std::numeric_limits<float>::infinity ( )
Expand Down

0 comments on commit 106cbaa

Please sign in to comment.