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:
kritz
2020-08-07 18:44:48 +02:00
committed by GitHub
co-authored by Julian Kent
parent 6ed5dbc2db
commit 18699416b0
9 changed files with 299 additions and 6 deletions
+4 -4
View File
@@ -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;
}