Showed compiler that B_ is always initialized

release/4.3a0
Frank Dellaert 2018-10-09 09:11:50 -04:00
parent a34a9b8ff1
commit 767c5d41ee
1 changed files with 49 additions and 51 deletions

View File

@ -74,17 +74,15 @@ const Matrix32& Unit3::basis(OptionalJacobian<6, 2> H) const {
tbb::mutex::scoped_lock lock(B_mutex_);
#endif
// Return cached basis if available and the Jacobian isn't needed.
if (B_ && !H) {
// Return cached basis if available and the Jacobian isn't needed.
return *B_;
}
} else if (B_ && H && H_B_) {
// Return cached basis and derivatives if available.
if (B_ && H && H_B_) {
*H = *H_B_;
return *B_;
}
} else {
B_.reset(Matrix32());
// Get the unit vector and derivative wrt this.
// NOTE(hayk): We can't call point3(), because it would recursively call basis().
const Point3 n(p_);
@ -113,7 +111,6 @@ const Matrix32& Unit3::basis(OptionalJacobian<6, 2> H) const {
Point3 b2 = gtsam::cross(n, b1, H ? &H_b2_n : nullptr, H ? &H_b2_b1 : nullptr);
// Create the basis by stacking b1 and b2.
B_.reset(Matrix32());
(*B_) << b1.x(), b2.x(), b1.y(), b2.y(), b1.z(), b2.z();
if (H) {
@ -130,6 +127,7 @@ const Matrix32& Unit3::basis(OptionalJacobian<6, 2> H) const {
return *B_;
}
}
/* ************************************************************************* */
Point3 Unit3::point3(OptionalJacobian<3, 2> H) const {