74 template <
typename Result>
78 : m_correspondence(DEFAULT_CORRESPONDENCE)
80 , m_max_iterations(DEFAULT_MAX_ITERATIONS)
81 , m_normalize(DEFAULT_NORMALIZE)
82 , m_outliers(DEFAULT_OUTLIERS)
83 , m_sigma2(DEFAULT_SIGMA2)
84 , m_tolerance(DEFAULT_TOLERANCE) {}
94 std::unique_ptr<GaussTransform> gauss_transform) {
95 m_gauss_transform = std::move(gauss_transform);
101 m_max_iterations = max_iterations;
107 m_normalize = normalize;
113 m_outliers = outliers;
125 m_tolerance = tolerance;
131 auto tic = std::chrono::high_resolution_clock::now();
134 fixed = normalization.
fixed;
135 moving = normalization.
moving;
138 this->init(fixed, moving);
142 if (m_sigma2 == 0.0) {
144 }
else if (m_normalize) {
151 double ntol = m_tolerance + 10.0;
153 while (iter < m_max_iterations && ntol > m_tolerance &&
154 result.
sigma2 > 10 * std::numeric_limits<double>::epsilon()) {
157 this->modify_probabilities(probabilities);
159 ntol = std::abs((probabilities.
l - l) / probabilities.
l);
163 this->compute_one(fixed, moving, probabilities, result.
sigma2);
170 if (m_correspondence) {
172 fixed, result.
points, m_sigma2, m_outliers);
176 auto toc = std::chrono::high_resolution_clock::now();
178 std::chrono::duration_cast<std::chrono::microseconds>(toc - tic);
204 virtual bool linked()
const = 0;
207 bool m_correspondence;
208 std::unique_ptr<GaussTransform> m_gauss_transform;
209 size_t m_max_iterations;
const bool DEFAULT_NORMALIZE
Whether points should be normalized by default.
Definition: transform.hpp:39
IndexVector correspondence
The correspondence vector.
Definition: transform.hpp:58
Matrix moving
The moving points.
Definition: normalization.hpp:40
Utility to scale/offset points to (roughly) conform to unit shape centered at zero.
Basic typedefs for our flavors of Eigen matrices.
const double DEFAULT_TOLERANCE
The default tolerance.
Definition: transform.hpp:43
double sigma2
The final sigma2 value.
Definition: transform.hpp:56
size_t iterations
The number of iterations.
Definition: transform.hpp:62
Eigen::MatrixXd Matrix
Our base matrix class.
Definition: matrix.hpp:29
const double DEFAULT_OUTLIERS
The default outlier weight.
Definition: transform.hpp:41
The always-present, always-ambiguous utils file.
Eigen::Matrix< Matrix::Index, Eigen::Dynamic, 1 > IndexVector
Typedef for an index vector, used to index other matrices.
Definition: matrix.hpp:35
double default_sigma2(const Matrix &fixed, const Matrix &moving)
Computes the default sigma2 for the given matrices.
const size_t DEFAULT_MAX_ITERATIONS
The default number of iterations allowed.
Definition: transform.hpp:37
std::chrono::microseconds runtime
The runtime.
Definition: transform.hpp:60
const double DEFAULT_SIGMA2
The default sigma2.
Definition: transform.hpp:45
The result of a generic transform run.
Definition: transform.hpp:52
const bool DEFAULT_LINKED
Are the scalings of the two datasets linked by default?
Definition: transform.hpp:49
The results of normalizing data to a unit cube (or whatever dimensionality).
Definition: normalization.hpp:30
IndexVector correspondence
The correspondence vector between the two datasets.
Definition: gauss_transform.hpp:42
Matrix fixed
The fixed points.
Definition: normalization.hpp:34
Matrix points
The final moved points.
Definition: transform.hpp:54
Top-level cpd namespace.
Definition: affine.hpp:26
const bool DEFAULT_CORRESPONDENCE
Whether correspondence vector should be computed by default.
Definition: transform.hpp:47
double fixed_scale
The scaling factor for the fixed points.
Definition: normalization.hpp:36
Probability matrices produced by comparing two data sets with a GaussTransform.
Definition: gauss_transform.hpp:32
double l
The total error.
Definition: gauss_transform.hpp:40
virtual void denormalize(const Normalization &normalization)
De-normalize this result.