8#ifndef MX_XD_DYNAMICS_H
9#define MX_XD_DYNAMICS_H
24 unsigned int nrows = 1,
25 unsigned int ncols = 1) : casadi::MX(nrows, ncols){
40 unsigned int arows = std::min (nrows,
rows());
41 unsigned int acols = std::min (ncols,
cols());
43 for (
unsigned int i = 0; i < arows; i++) {
44 for (
unsigned int j = 0; j < acols; j++) {
45 result(i,j) = (*this)(i,j);
53 return casadi::MX::zeros(nrows, ncols);
56 *
this = casadi::MX::zeros(this->
rows(), this->
cols());
61 return casadi::MX::ones(nrows, ncols);
64 *
this = casadi::MX::ones(this->
rows(), this->
cols());
69 return casadi::MX::eye(
size);
72 *
this = casadi::MX::eye(
cols());
83 return this->casadi::MX::operator()(
84 casadi::Slice(
static_cast<casadi_int
>(i),
static_cast<casadi_int
>(i+1)),
85 casadi::Slice(
static_cast<casadi_int
>(j),
static_cast<casadi_int
>(j+1)));
88 return this->casadi::MX::operator()(i, j);
91 void resize(
unsigned int newI,
unsigned int newJ = 1){
92 *
this = casadi::MX(newI, newJ);
95 unsigned int rows()
const {
96 return static_cast<unsigned int>(this->casadi::MX::rows());
99 unsigned int cols()
const {
100 return static_cast<unsigned int>(this->casadi::MX::columns());
107 template <
unsigned int row_count,
unsigned int col_count>
109 unsigned int row_start,
110 unsigned int col_start)
112 return this->casadi::MX::operator()(
113 casadi::Slice(
static_cast<casadi_int
>(row_start),
static_cast<casadi_int
>(row_start+row_count)),
114 casadi::Slice(
static_cast<casadi_int
>(col_start),
static_cast<casadi_int
>(col_start+col_count)));
116 template <
unsigned int row_count,
unsigned int col_count>
118 unsigned int row_start,
119 unsigned int col_start)
const
121 return this->casadi::MX::operator()(
122 casadi::Slice(
static_cast<casadi_int
>(row_start),
static_cast<casadi_int
>(row_start+row_count)),
123 casadi::Slice(
static_cast<casadi_int
>(col_start),
static_cast<casadi_int
>(col_start+col_count)));
127 unsigned int row_start,
128 unsigned int col_start,
129 unsigned int row_count,
130 unsigned int col_count)
132 return this->casadi::MX::operator()(
133 casadi::Slice(
static_cast<casadi_int
>(row_start),
static_cast<casadi_int
>(row_start+row_count)),
134 casadi::Slice(
static_cast<casadi_int
>(col_start),
static_cast<casadi_int
>(col_start+col_count)));
137 unsigned int row_start,
138 unsigned int col_start,
139 unsigned int row_count,
140 unsigned int col_count)
const
142 return this->casadi::MX::operator()(
143 casadi::Slice(
static_cast<casadi_int
>(row_start),
static_cast<casadi_int
>(row_start+row_count)),
144 casadi::Slice(
static_cast<casadi_int
>(col_start),
static_cast<casadi_int
>(col_start+col_count)));
148 unsigned int numberRows)
150 return (*this).block(0, 0, numberRows,
cols());
153 unsigned int numberRows)
const
155 return (*this).
block(0, 0, numberRows,
cols());
168 return casadi::MX::dot(*
this, other_vector);
172 return casadi::MX::norm_2(*
this);
185 this->casadi::MX::operator+=(other);
190 return out.casadi::MX::operator+=(other);
194 this->casadi::MX::operator-=(other);
199 return out.casadi::MX::operator-=(other);
203 *
this = casadi::MX::mtimes(*
this, m2);
206 return casadi::MX::mtimes(*
this, other);
209 return casadi::MX::mtimes(*
this, other);
212 return casadi::MX::mtimes(*
this, other);
215 return casadi::MX::mtimes(*
this, other);
219 for (
unsigned int i = 0; i <
rows() *
cols(); i++)
220 this->casadi::MX::operator/=(scalar(0, 0));
224 for (
unsigned int i = 0; i <
rows(); ++i){
225 for (
unsigned int j = 0; j <
cols(); ++j){
226 result(i, j) /= scalar;
234 for (
unsigned int i = 0; i <
rows(); ++i){
235 for (
unsigned int j = 0; j <
cols(); ++j){
236 result(i, j) /= scalar;
MX_Xd_dynamic transpose() const
unsigned int rows() const
MX_Xd_dynamic(const casadi::MX &m)
MX_Xd_dynamic operator*(const MX_Xd_SubMatrix &other) const
MX_Xd_dynamic & setZero()
unsigned int cols() const
MX_Xd_dynamic operator*(const MX_Xd_dynamic &other) const
MX_Xd_dynamic squaredNorm() const
void resize(unsigned int newI, unsigned int newJ=1)
MX_Xd_dynamic(unsigned int nrows=1, unsigned int ncols=1)
MX_Xd_SubMatrix topRows(unsigned int numberRows)
MX_Xd_dynamic topRows(unsigned int numberRows) const
MX_Xd_dynamic norm() const
MX_Xd_scalar dot(const MX_Xd_dynamic &other_vector) const
void operator+=(const MX_Xd_dynamic &other)
MX_Xd_dynamic operator/(const MX_Xd_scalar &scalar) const
MX_Xd_dynamic operator*(const double &other) const
MX_Xd_dynamic block(unsigned int row_start, unsigned int col_start, unsigned int row_count, unsigned int col_count) const
MX_Xd_dynamic & setOnes()
MX_Xd_dynamic block(unsigned int row_start, unsigned int col_start) const
MX_Xd_scalar operator[](unsigned int i) const
unsigned int size() const
MX_Xd_SubMatrix operator()(unsigned int i, unsigned int j=0)
void operator*=(const MX_Xd_dynamic &m2)
static MX_Xd_dynamic Identity(unsigned int size, unsigned int ignoredSize=0)
void conservativeResize(unsigned int nrows, unsigned int ncols=1)
void operator/=(const MX_Xd_scalar &scalar)
MX_Xd_dynamic & setIdentity()
MX_Xd_SubMatrix block(unsigned int row_start, unsigned int col_start, unsigned int row_count, unsigned int col_count)
MX_Xd_dynamic operator*(const MX_Xd_scalar &other) const
MX_Xd_SubMatrix operator[](unsigned int i)
MX_Xd_dynamic inverse() const
MX_Xd_dynamic operator/(const MX_Xd_SubMatrix &scalar) const
static MX_Xd_dynamic One(unsigned int nrows, unsigned int ncols=1)
void operator-=(const MX_Xd_dynamic &other)
MX_Xd_scalar operator()(unsigned int i, unsigned int j=0) const
MX_Xd_dynamic operator+(const MX_Xd_dynamic &other) const
static MX_Xd_dynamic Zero(unsigned int nrows, unsigned int ncols=1)
MX_Xd_dynamic operator-(const MX_Xd_dynamic &other) const
MX_Xd_SubMatrix block(unsigned int row_start, unsigned int col_start)