| #include <Eigen/Core> |
| #include <iostream> |
|
|
| class MyVectorType : public Eigen::VectorXd |
| { |
| public: |
| MyVectorType(void):Eigen::VectorXd() {} |
|
|
| |
| template<typename OtherDerived> |
| MyVectorType(const Eigen::MatrixBase<OtherDerived>& other) |
| : Eigen::VectorXd(other) |
| { } |
|
|
| |
| template<typename OtherDerived> |
| MyVectorType& operator=(const Eigen::MatrixBase <OtherDerived>& other) |
| { |
| this->Eigen::VectorXd::operator=(other); |
| return *this; |
| } |
| }; |
|
|
| int main() |
| { |
| MyVectorType v = MyVectorType::Ones(4); |
| v(2) += 10; |
| v = 2 * v; |
| std::cout << v.transpose() << std::endl; |
| } |
|
|