mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 08:53:37 +08:00
Support more of mathlib function for easier swap in px4.
This commit is contained in:
@@ -41,6 +41,12 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
Matrix(const Type data_[][N]) :
|
||||
_data()
|
||||
{
|
||||
memcpy(_data, data_, sizeof(_data));
|
||||
}
|
||||
|
||||
Matrix(const Type *data_) :
|
||||
_data()
|
||||
{
|
||||
@@ -120,6 +126,20 @@ public:
|
||||
return res;
|
||||
}
|
||||
|
||||
Matrix<Type, M, N> edivide(const Matrix<Type, M, N> &other) const
|
||||
{
|
||||
Matrix<Type, M, N> res;
|
||||
const Matrix<Type, M, N> &self = *this;
|
||||
|
||||
for (size_t i = 0; i < M; i++) {
|
||||
for (size_t j = 0; j < N; j++) {
|
||||
res(i , j) = self(i, j)/other(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Matrix<Type, M, N> operator+(const Matrix<Type, M, N> &other) const
|
||||
{
|
||||
Matrix<Type, M, N> res;
|
||||
@@ -334,6 +354,11 @@ public:
|
||||
memset(_data, 0, sizeof(_data));
|
||||
}
|
||||
|
||||
inline void zero()
|
||||
{
|
||||
setZero();
|
||||
}
|
||||
|
||||
void setAll(Type val)
|
||||
{
|
||||
Matrix<Type, M, N> &self = *this;
|
||||
@@ -360,6 +385,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
inline void identity()
|
||||
{
|
||||
setIdentity();
|
||||
}
|
||||
|
||||
inline void swapRows(size_t a, size_t b)
|
||||
{
|
||||
if (a == b) {
|
||||
|
||||
Reference in New Issue
Block a user