Skip to content

Commit d398a6d

Browse files
committed
Use rankUpdate on MacOS
1 parent bc01c6d commit d398a6d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Libs/Optimize/Function/CorrespondenceFunction.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
#include "CorrespondenceFunction.h"
33

4+
#include <Libs/Utils/PlatformUtils.h>
45
#include <math.h>
56

67
#include "Libs/Utils/Utils.h"
@@ -99,15 +100,14 @@ void CorrespondenceFunction::ComputeUpdates(const ParticleSystem* c) {
99100
if (m_InverseCovMatrix->rows() != num_dims || m_InverseCovMatrix->cols() != num_dims) {
100101
m_InverseCovMatrix->resize(num_dims, num_dims);
101102
}
102-
TIME_START("correspondence::covariance_multiply");
103-
104-
// instead of this:
105-
// m_InverseCovMatrix->noalias() = lhs * rhs;
106-
107-
// we now use the selfadjointView for better performance because the covariance matrix is symmetric
108-
m_InverseCovMatrix->setZero(num_dims, num_dims);
109-
m_InverseCovMatrix->selfadjointView<Eigen::Upper>().rankUpdate(lhs);
110103

104+
TIME_START("correspondence::covariance_multiply");
105+
if (PlatformUtils::is_macos()) {
106+
// this is about 2x faster on MacOS, but slower on Linux
107+
m_InverseCovMatrix->selfadjointView<Eigen::Upper>().rankUpdate(lhs);
108+
} else {
109+
m_InverseCovMatrix->noalias() = lhs * rhs;
110+
}
111111
TIME_STOP("correspondence::covariance_multiply");
112112
}
113113

0 commit comments

Comments
 (0)