mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-15 07:10:37 +08:00
8fdffdd573
Also fix a small mistake (Vector3d instead of VectorXd).
31 lines
766 B
C++
31 lines
766 B
C++
#include <Eigen/Core>
|
|
#include <iostream>
|
|
|
|
class MyVectorType : public Eigen::VectorXd
|
|
{
|
|
public:
|
|
MyVectorType(void):Eigen::VectorXd() {}
|
|
|
|
// This constructor allows you to construct MyVectorType from Eigen expressions
|
|
template<typename OtherDerived>
|
|
MyVectorType(const Eigen::MatrixBase<OtherDerived>& other)
|
|
: Eigen::VectorXd(other)
|
|
{ }
|
|
|
|
// This method allows you to assign Eigen expressions to MyVectorType
|
|
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;
|
|
}
|