Skip to content

Commit

Permalink
added move constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarke committed Oct 30, 2020
1 parent 0d17932 commit b585cb0
Show file tree
Hide file tree
Showing 12 changed files with 182 additions and 63 deletions.
3 changes: 1 addition & 2 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/**",
"${workspaceFolder}/include"
"/usr/include/**"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
Expand Down
23 changes: 16 additions & 7 deletions include/lie_algebras/rn.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,33 @@ static const unsigned int dim_ = N;
static const unsigned int size1_ = N;
static const unsigned int size2_ = 1;

// The rule of 5!!

/**
* Default constructor. Initializes algebra element to identity.
*/
rn() : data_(Eigen::Matrix<double,N,1>::Zero()) {}


/**
* Copy constructor.
*/
rn(const rn & u) : data_(u.data_) {}

/**
* Copy assignment.
*/
void operator = (const rn& u){data_ = u.data_;}

/**
* Move constructor.
*/
rn(const rn && u) : data_(u.data_) {}

/**
* Move assignment.
*/
void operator = (const rn&& u){data_ = u.data_;}

/**
* Initializes algebra element to the one given.
* @param[in] data The data of an element of \f$\mathbb{R}^2\f$
Expand Down Expand Up @@ -191,12 +206,6 @@ rn operator + (const rn& u){return rn(data_ + u.data_);}
*/
rn operator - (const rn& u){return rn(data_ - u.data_);}

/**
* Creates a deep copy of the element
* @param u An element of the Lie algebra.
*/
void operator = (const rn& u){data_ = u.data_;}

/**
* Performs Scalar multiplication and returns the result.
* @param scalar The scalar that will scale the element of the Lie algebra
Expand Down
23 changes: 17 additions & 6 deletions include/lie_algebras/se2.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ se2(): p_(data_.data()), th_(data_.data()+2), data_(Eigen::Matrix<double,3,1>::Z
*/
se2(const se2 & u) : p_(data_.data()), th_(data_.data()+2), data_(u.data_){}

/**
* Copy assignment
*/
void operator = (const se2& u){data_ = u.data_;}

/**
* Move constructor.
*/
se2(const se2 && u) : p_(data_.data()), th_(data_.data()+2), data_(u.data_){}

/**
* Move assignment.
*/
void operator = (const se2&& u){data_ = u.data_;}



/**
* Initializes algebra element to the one given.
* @param[in] data The data of an element of Cartesian space of \f$se(2)\f$
Expand Down Expand Up @@ -194,12 +211,6 @@ se2 operator + (const se2& u){return se2(data_ + u.data_);}
*/
se2 operator - (const se2& u){return se2(data_ - u.data_);}

/**
* Creates a deep copy of the element
* @param u An element of the Lie algebra.
*/
void operator = (const se2& u){data_ = u.data_;}

/**
* Performs Scalar multiplication and returns the result.
* @param scalar The scalar that will scale the element of the Lie algebra
Expand Down
22 changes: 16 additions & 6 deletions include/lie_algebras/se3.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ se3() : p_(data_.data()), th_(data_.data()+3), data_(Eigen::Matrix<double,6,1>::
*/
se3(const se3 & u) : p_(data_.data()), th_(data_.data()+3), data_(u.data_) {}

/**
*Copy assignment
*/
void operator = (const se3& u){data_ = u.data_;}

/**
* Move constructor.
*/
se3(const se3 && u) : p_(data_.data()), th_(data_.data()+3), data_(u.data_) {}

/**
*Move assignment
*/
void operator = (const se3&& u){data_ = u.data_;}


/**
* Initializes algebra element to the one given.
* @param[in] data The data of an element of Cartesian space of \f$se(3)\f$
Expand Down Expand Up @@ -198,12 +214,6 @@ se3 operator + (const se3& u){return se3(data_ + u.data_);}
*/
se3 operator - (const se3& u){return se3(data_ - u.data_);}

/**
* Creates a deep copy of the element
* @param u An element of the Lie algebra.
*/
void operator = (const se3& u){data_ = u.data_;}

/**
* Performs Scalar multiplication and returns the result.
* @param scalar The scalar that will scale the element of the Lie algebra
Expand Down
15 changes: 15 additions & 0 deletions include/lie_algebras/so2.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ so2() : data_(Eigen::Matrix<double,1,1>::Zero()){}
*/
so2(const so2 & u) : data_(u.data_){}

/**
* Copy assignment.
*/
void operator = (const so2& u){data_ = u.data_;}

/**
* Move constructor.
*/
so2(const so2 && u) : data_(u.data_){}

/**
* Move assignment.
*/
void operator = (const so2&& u){data_ = u.data_;}

/**
* Initializes algebra element to the one given.
* @param[in] data The data of an element of Cartesian space of \f$so(2)\f$
Expand Down
21 changes: 15 additions & 6 deletions include/lie_algebras/so3.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ so3() : data_(Eigen::Matrix<double,3,1>::Zero()){}
*/
so3(const so3 & u) : data_(u.data_) {}

/**
* Copy assignment.
*/
void operator = (const so3& u){data_ = u.data_;}

/**
* Move constructor.
*/
so3(const so3 && u) : data_(u.data_) {}

/**
* Move assignment.
*/
void operator = (const so3&& u){data_ = u.data_;}

/**
* Initializes algebra element to the one given.
* @param[in] data The data of an element of Cartesian space of \f$so(3)\f$
Expand Down Expand Up @@ -183,12 +198,6 @@ so3 operator + (const so3& u){return so3(data_ + u.data_);}
*/
so3 operator - (const so3& u){return so3(data_ - u.data_);}

/**
* Creates a deep copy of the element
* @param u An element of the Lie algebra.
*/
void operator = (const so3& u){data_ = u.data_;}

/**
* Performs Scalar multiplication and returns the result.
* @param scalar The scalar that will scale the element of the Lie algebra
Expand Down
22 changes: 15 additions & 7 deletions include/lie_groups/Rn.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ Rn() : data_(Eigen::Matrix<double,N,1>::Zero()) {}
*/
Rn(const Rn & g) : data_(g.data_) {}

/**
* Copy assignment
*/
void operator = (const Rn& g){ this->data_ = g.data_; }

/**
* Move constructor.
*/
Rn(const Rn && g) : data_(g.data_) {}

/**
* Move assignment
*/
void operator = (const Rn&& g){ this->data_ = g.data_; }

/**
* Initializes group element to the one given. If verify is true
* it will check that the input is an element of \f$\mathbb{R}^n\f$
Expand Down Expand Up @@ -80,13 +95,6 @@ Eigen::Matrix<double,N,1> Log(){return data_;}
*/
Rn operator * (const Rn& g){ return Rn(data_ + g.data_);}


/**
* Assignment Operator. Deep copy of the input parameter
* @param g The element to be copied.
*/
void operator = (const Rn& g){ this->data_ = g.data_; }

/**
* Performs the OPlus operation
* @param g_data The data belonging to the group element.
Expand Down
22 changes: 15 additions & 7 deletions include/lie_groups/SE2.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ SE2() : t_(data_.data()+6), R_(data_.block(0,0,2,2)), data_(Eigen::Matrix3d::Ide
*/
SE2(const SE2 & g) : t_(data_.data()+6), R_(data_.block(0,0,2,2)), data_(g.data_) {}

/**
* Copy assignment
*/
void operator = (const SE2& g){ this->data_ = g.data_; }

/**
* Move constructor.
*/
SE2(const SE2 && g) : t_(data_.data()+6), R_(data_.block(0,0,2,2)), data_(g.data_) {}

/**
* Move assignment
*/
void operator = (const SE2&& g){ this->data_ = g.data_; }

/**
* Initializes group element to the one given. If verify is true
* it will check that the input is an element of \f$SE(2)\f$
Expand Down Expand Up @@ -85,13 +100,6 @@ Eigen::Matrix<double,3,1> Log() {return se2::Log(this->data_);}
*/
SE2 operator * (const SE2& g){ return SE2(data_ *g.data_);}


/**
* Assignment Operator. Deep copy of the input parameter
* @param g The element to be copied.
*/
void operator = (const SE2& g){ this->data_ = g.data_; }

/**
* Performs the OPlus operation
* @param g_data The data belonging to the group element.
Expand Down
21 changes: 15 additions & 6 deletions include/lie_groups/SE3.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ SE3() : t_(data_.data()+12), R_(data_.block(0,0,3,3)), data_(Eigen::Matrix<doubl
*/
SE3(const SE3 & g) : t_(data_.data()+12), R_(data_.block(0,0,3,3)), data_(g.data_) {}

/**
* Copy assignment
*/
void operator = (const SE3& g){ this->data_ = g.data_; }

/**
* Move constructor.
*/
SE3(const SE3 && g) : t_(data_.data()+12), R_(data_.block(0,0,3,3)), data_(g.data_) {}

/**
* Move assignment
*/
void operator = (const SE3&& g){ this->data_ = g.data_; }

/**
* Initializes group element to the one given. If verify is true
* it will check that the input is an element of \f$SE(3)\f$
Expand Down Expand Up @@ -89,12 +104,6 @@ Eigen::Matrix<double,6,1> Log() {return se3::Log(this->data_);}
*/
SE3 operator * (const SE3& g){ return SE3(data_ *g.data_);}

/**
* Assignment Operator. Deep copy of the input parameter
* @param g The element to be copied.
*/
void operator = (const SE3& g){ this->data_ = g.data_; }

/**
* Performs the OPlus operation
* @param g_data The data belonging to the group element.
Expand Down
22 changes: 15 additions & 7 deletions include/lie_groups/SO2.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ SO2() : data_(Eigen::Matrix<double,2,2>::Identity()){}
*/
SO2(const SO2 & g) : data_(g.data_) {}

/**
* Copy assignment
*/
void operator = (const SO2& g){ this->data_ = g.data_; }

/**
* Move constructor.
*/
SO2(const SO2 && g) : data_(g.data_) {}

/**
* Move assignment
*/
void operator = (const SO2&& g){ this->data_ = g.data_; }

/**
* Initializes group element to the one given. If verify is true
* it will check that the input is an element of \f$SO(2)\f$
Expand Down Expand Up @@ -81,13 +96,6 @@ Eigen::Matrix<double,1,1> Log();
*/
SO2 operator * (const SO2& g){ return SO2(data_ *g.data_);}


/**
* Assignment Operator. Deep copy of the input parameter
* @param g The element to be copied.
*/
void operator = (const SO2& g){ this->data_ = g.data_; }

/**
* Performs the OPlus operation
* @param g_data The data belonging to the group element.
Expand Down
22 changes: 15 additions & 7 deletions include/lie_groups/SO3.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ SO3() : data_(Eigen::Matrix3d::Identity()){}
*/
SO3(const SO3 & g) : data_(g.data_) {}

/**
* copy assignment
*/
void operator = (const SO3& g){ this->data_ = g.data_; }

/**
* Move constructor.
*/
SO3(const SO3 && g) : data_(g.data_) {}

/**
* Move assignment
*/
void operator = (const SO3&& g){ this->data_ = g.data_; }

/**
* Initializes group element to the one given. If verify is true
* it will check that the input is an element of \f$SO(3)\f$
Expand Down Expand Up @@ -77,13 +92,6 @@ Eigen::Matrix<double,3,1> Log();
*/
SO3 operator * (const SO3& g){ return SO3(data_ *g.data_);}


/**
* Assignment Operator. Deep copy of the input parameter
* @param g The element to be copied.
*/
void operator = (const SO3& g){ this->data_ = g.data_; }

/**
* Performs the OPlus operation
* @param g_data The data belonging to the group element.
Expand Down
Loading

0 comments on commit b585cb0

Please sign in to comment.