Support more of mathlib function for easier swap in px4.

This commit is contained in:
James Goppert
2016-08-16 19:03:54 -04:00
parent 558777f34c
commit 0eb8aa0c0b
10 changed files with 188 additions and 4 deletions
+30
View File
@@ -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) {