mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-02 05:04:08 +08:00
add NaN value set for Matrix; add return of URT of a matrix
This commit is contained in:
parent
6b0777d815
commit
96cb9ab146
@ -412,6 +412,11 @@ public:
|
||||
setAll(1);
|
||||
}
|
||||
|
||||
inline void setNaN()
|
||||
{
|
||||
setAll(NAN);
|
||||
}
|
||||
|
||||
void setIdentity()
|
||||
{
|
||||
setZero();
|
||||
@ -512,6 +517,13 @@ Matrix<Type, M, N> ones() {
|
||||
return m;
|
||||
}
|
||||
|
||||
template<size_t M, size_t N>
|
||||
Matrix<float, M, N> nans() {
|
||||
Matrix<float, M, N> m;
|
||||
m.setNaN();
|
||||
return m;
|
||||
}
|
||||
|
||||
template<typename Type, size_t M, size_t N>
|
||||
Matrix<Type, M, N> operator*(Type scalar, const Matrix<Type, M, N> &other)
|
||||
{
|
||||
|
||||
@ -48,7 +48,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// inverse alias
|
||||
inline bool I(SquareMatrix<Type, M> &i) const
|
||||
{
|
||||
@ -67,6 +66,23 @@ public:
|
||||
return res;
|
||||
}
|
||||
|
||||
// get matrix upper right triangle
|
||||
Vector<Type, M * (M + 1) / 2> urt() const
|
||||
{
|
||||
Vector<Type, M * (M + 1) / 2> res;
|
||||
const SquareMatrix<Type, M> &self = *this;
|
||||
|
||||
unsigned idx = 0;
|
||||
for (size_t x = 0; x < M; x++) {
|
||||
for (size_t y = x; y < M; y++) {
|
||||
res(idx) = self(x, y);
|
||||
++idx;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Type trace() const
|
||||
{
|
||||
Type res = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user