Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: remove evecs_, evals_ from Leaf struct #71

Open
wants to merge 2 commits into
base: fix/target_cloud_updated_false
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ()),
masahiro-kubota marked this conversation as resolved.
Show resolved Hide resolved
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
Loading