Skip to content

Commit

Permalink
Merge pull request #11 from pariterre/master
Browse files Browse the repository at this point in the history
Allow for chaining while using setOnes, setZero or setIdentity
  • Loading branch information
pariterre authored Apr 10, 2020
2 parents bfd7f07 + f454b58 commit 3e87b5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions include/rbdl/CasadiMath/MX_Xd_dynamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,25 @@ class MX_Xd_dynamic : public casadi::MX{
static MX_Xd_dynamic Zero(unsigned int nrows, unsigned int ncols = 1){
return casadi::MX::zeros(nrows, ncols);
}
void setZero(){
MX_Xd_dynamic& setZero(){
*this = casadi::MX::zeros(this->rows(), this->cols());
return *this;
}

static MX_Xd_dynamic One(unsigned int nrows, unsigned int ncols = 1){
return casadi::MX::ones(nrows, ncols);
}
void setOnes(){
MX_Xd_dynamic& setOnes(){
*this = casadi::MX::ones(this->rows(), this->cols());
return *this;
}

static MX_Xd_dynamic Identity(unsigned int size, unsigned int ignoredSize = 0){
return casadi::MX::eye(size);
}
void setIdentity(){
MX_Xd_dynamic& setIdentity(){
*this = casadi::MX::eye(cols());
return *this;
}

MX_Xd_SubMatrix operator[](unsigned int i) {
Expand Down
9 changes: 6 additions & 3 deletions include/rbdl/CasadiMath/MX_Xd_static.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,22 +253,25 @@ class MX_Xd_static : public casadi::MX{
static MX_Xd_static Identity(){
return casadi::MX::eye(ncols);
}
void setIdentity(){
MX_Xd_static& setIdentity(){
*this = casadi::MX::eye(ncols);
return *this;
}

static MX_Xd_static Zero(){
return MX_Xd_static<nrows, ncols>::zeros(nrows, ncols);
}
void setZero(){
MX_Xd_static& setZero(){
*this = casadi::MX::zeros(this->rows(), this->cols());
return *this;
}

static MX_Xd_static One(){
return MX_Xd_static<nrows, ncols>::ones(nrows, ncols);
}
void setOnes(){
MX_Xd_static& setOnes(){
*this = casadi::MX::ones(this->rows(), this->cols());
return *this;
}


Expand Down

0 comments on commit 3e87b5f

Please sign in to comment.