mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-02 01:01:36 +08:00
SparseVector (#140)
* Add SparseVector temp * Add gtest * Some reworking of the sparse concept * Change type of M from int to size_t * Add const modifier * Add needed declaration for accessing elements of _indices * Add norm_squared, norm, longerThan * Add test for all sparse vector functions * Add missing const to slice's norm_squared, norm and longerThan * Construction from Vector<M> and carray[N] * try to fix ci Co-authored-by: Julian Kent <julian@auterion.com>
This commit is contained in:
+4
-4
@@ -240,9 +240,9 @@ public:
|
||||
return res;
|
||||
}
|
||||
|
||||
Type norm_squared()
|
||||
Type norm_squared() const
|
||||
{
|
||||
Slice<Type, P, Q, M, N>& self = *this;
|
||||
const Slice<Type, P, Q, M, N>& self = *this;
|
||||
Type accum(0);
|
||||
for (size_t i = 0; i < P; i++) {
|
||||
for (size_t j = 0; j < Q; j++) {
|
||||
@@ -252,12 +252,12 @@ public:
|
||||
return accum;
|
||||
}
|
||||
|
||||
Type norm()
|
||||
Type norm() const
|
||||
{
|
||||
return matrix::sqrt(norm_squared());
|
||||
}
|
||||
|
||||
bool longerThan(Type testVal)
|
||||
bool longerThan(Type testVal) const
|
||||
{
|
||||
return norm_squared() > testVal*testVal;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user