Fixed -> Matrix
parent
6ea60745eb
commit
628c4fbdab
|
|
@ -39,17 +39,17 @@ class OptionalJacobian {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// Fixed size type
|
/// ::Fixed size type
|
||||||
typedef Eigen::Matrix<double, Rows, Cols> Fixed;
|
typedef Eigen::Matrix<double, Rows, Cols> Matrix;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Eigen::Map<Fixed> map_; /// View on constructor argument, if given
|
Eigen::Map<Matrix> map_; /// View on constructor argument, if given
|
||||||
|
|
||||||
// Trick from http://eigen.tuxfamily.org/dox/group__TutorialMapClass.html
|
// Trick from http://eigen.tuxfamily.org/dox/group__TutorialMapClass.html
|
||||||
// uses "placement new" to make map_ usurp the memory of the fixed size matrix
|
// uses "placement new" to make map_ usurp the memory of the fixed size matrix
|
||||||
void usurp(double* data, int rows, int cols) {
|
void usurp(double* data, int rows, int cols) {
|
||||||
new (&map_) Eigen::Map<Fixed>(data, rows, cols);
|
new (&map_) Eigen::Map<Matrix>(data, rows, cols);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -60,13 +60,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Constructor that will usurp data of a fixed-size matrix
|
/// Constructor that will usurp data of a fixed-size matrix
|
||||||
OptionalJacobian(Fixed& fixed) :
|
OptionalJacobian(Matrix& fixed) :
|
||||||
map_(NULL) {
|
map_(NULL) {
|
||||||
usurp(fixed.data(), fixed.rows(), fixed.cols());
|
usurp(fixed.data(), fixed.rows(), fixed.cols());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Constructor that will usurp data of a fixed-size matrix, pointer version
|
/// Constructor that will usurp data of a fixed-size matrix, pointer version
|
||||||
OptionalJacobian(Fixed* fixedPtr) :
|
OptionalJacobian(Matrix* fixedPtr) :
|
||||||
map_(NULL) {
|
map_(NULL) {
|
||||||
if (fixedPtr)
|
if (fixedPtr)
|
||||||
usurp(fixedPtr->data(), fixedPtr->rows(), fixedPtr->cols());
|
usurp(fixedPtr->data(), fixedPtr->rows(), fixedPtr->cols());
|
||||||
|
|
@ -104,12 +104,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// De-reference, like boost optional
|
/// De-reference, like boost optional
|
||||||
Eigen::Map<Fixed>& operator*() {
|
Eigen::Map<Matrix>& operator*() {
|
||||||
return map_;
|
return map_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TODO: operator->()
|
/// TODO: operator->()
|
||||||
Eigen::Map<Fixed>* operator->(){ return &map_; }
|
Eigen::Map<Matrix>* operator->(){ return &map_; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// The pure dynamic specialization of this is needed to support
|
// The pure dynamic specialization of this is needed to support
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue