Commit Graph

244 Commits

Author SHA1 Message Date
kritz f981cea2ae add possibility to iterate over SparseVector data at runtime (#143) 2020-08-09 09:44:49 +02:00
kamilritz e714a28c83 use size_t instead of int in sparseVector 2020-08-07 19:45:02 +02:00
kritz 18699416b0 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>
2020-08-07 18:44:48 +02:00
kamilritz 6ed5dbc2db Construct Vector from Slice<1,M> alias row() 2020-08-06 16:15:05 +02:00
Matthias Grob 572bafb01f Quaternion: use template type for division by two 2020-07-20 18:44:08 +02:00
Matthias Grob 242b38ee9e Quaternion: remove deprecated axis_angle conversions 2020-07-20 18:44:08 +02:00
Matthias Grob 7a3009f7a3 Remove asserts for unsigned integer >= 0
GCC 10 gives a warning
"comparison of unsigned expression in ‘>= 0’ is always true"
for these asserts since checking if an unsigned integer cannot
be negative and hence the statement gets droped.
2020-07-20 15:10:49 +02:00
Matthias Grob 0fd99c59f1 Switch operator() to return a const reference 2020-07-17 10:43:34 +02:00
kamilritz 8a59b463f2 Quaternion: Use template type instead of single hardcoded type 2020-07-17 10:37:18 +02:00
Julian Kent f3cf615023 Do += -= and scalar *= /= in place 2020-06-30 10:37:10 -04:00
kamilritz f529358e9a Add missing const modifier 2020-06-28 14:24:49 +02:00
kamilritz 674bd99f3b Add operator* and operator/ for slice with type 2020-06-12 11:34:09 +02:00
Nicolas MARTIN 38b3acce96 fix conjugate_inversed comment 2020-06-11 16:17:28 +02:00
Matthias Grob 2bee0d078c Quaternion: refactor multiplication to matrix multiplication style
Most often the multiplication in convention descriptions and papers is
described in matrix multiplication style like this:
q · p := Q(q)p

Q(q) :=
[q0 −q1 −q2 −q3]
[q1 q0 −q3 q2]
[q2 q3 q0 −q1]
[q3 −q2 q1 q0]

I'm just rearanging the terms such that it's easily comparable with
these definitions additional to it being clearly described by
documenting we use the hamilton convention.
2020-05-06 13:17:02 +02:00
kamilritz d613055462 Add more assignment operators for slices 2020-04-07 09:12:17 +02:00
Matthias Grob 976ada411b Matrix: min max comments and test style 2020-03-23 09:46:07 +01:00
Matthias Grob fa7153ecfb Matrix: omit min max nan case with same result
I observed this during review in
https://github.com/PX4/Matrix/pull/105/files#r348386226
2020-03-23 09:46:07 +01:00
Matthias Grob a32892926c Matrix: capture stdout for print() test
I want to switch the print() function back to use printf()
such that it's fully compatible with all (embedded) platforms.

To still test the print function I'm capturing stdout into a file
such that the print() function can stay unchanged and the result of
the printf()s can be evaluated.
2020-03-12 13:24:08 +01:00
Matthias Grob c6db357c92 Matrix: correct print buffer size prediction
Apparently printf of %8.8g can result in
8 significant digits + dot + scientific notation e.g. "e+12" = 14 bytes
2020-03-12 10:08:04 +01:00
Matthias Grob 2cca35c8fe AxisAngle: call q.imag().norm() for conversion
This is important depending on the platform because norm()
calls matrix::squrt() which dispatches correctly to the implementation
for the used type. Otherwise float squrt()s can get calculated as
double.
2020-03-12 07:35:44 +01:00
kritz 4873dc1c1e Analytic inverse implementation (#122)
* Add analytic 2x2 matrix inverse

* Add analytical 3x3 matrix inverse
2020-03-04 09:14:04 +01:00
Julian Kent 649c837b6b Use faster but less accurate average 2020-02-25 15:08:17 +01:00
kamilritz a37b91c96a Type cast remaining integer 2020-01-13 12:21:18 +01:00
kritz d18be0d0fa Fix AngleAxis constructors (#117) 2019-12-28 17:18:15 -05:00
kritz e81483a808 Catch quaternion canonical corner cases (#116) 2019-12-18 14:12:47 +01:00
kritz 4f3565da94 Add asserts (#115)
* Add asserts

* Type cast literals

* asserts for indexing vectors

* include assert

* Fix accessing elements outside of slice
2019-12-09 10:21:27 +01:00
kritz 2f6398168d Add several functions that are useful for coavriance matrices: (#114)
* uncorrelateCovariance
	* uncorrelateCovarianceSetVariance
	* makeBlockSymmetric
	* makeRowColSymmetric
	* isBlockSymmetric
	* isRowColSymmetric
2019-12-06 12:03:26 +01:00
kritz 5cbcf6035a Set Matrix's col amd row to single value (#113) 2019-12-05 18:16:14 +01:00
kritz ef442fab92 Getter function for the diag elements of slice (#112) 2019-12-05 11:39:21 +01:00
kritz de6a2d31ff Slice assign value (#111)
* Assign value to slice

* Readme for formatting
2019-12-04 14:33:33 +01:00
Daniel Agar a8009a36a3 Quaternion multiply inline return 2019-11-29 14:40:11 -05:00
Daniel Agar dba84236cb Vector3f cross product directly return result (#109) 2019-11-28 10:36:13 +01:00
Matthias Grob de85dcff97 Vector: switch read only functions to const (#108) 2019-11-26 13:46:45 +01:00
Julien Lecoeur a172c3cdac Add implementation of pseudo-inverse (#102)
* Fix compilation error

* Add implementation of pseudo-inverse

The implementation is based on this publication:
Courrieu, P. (2008). Fast Computation of Moore-Penrose Inverse Matrices, 8(2), 25–29. http://arxiv.org/abs/0804.4809
It is a fully templated implementation to guaranty type correctness.

* Add tests for pseudoinverse

* Apply suggestions from code review

Co-Authored-By: Mathieu Bresciani <brescianimathieu@gmail.com>

* Adapt fullRankCholesky tolerance to type

* Add pseudoinverse test with effectiveness matrix

* Fix coverage

* Fix rebase issue

* Fix SquareMatrix test, add null Matrix test
2019-11-18 14:36:30 -08:00
Daniel Agar cd185c995b add braces around statements and cleanup formatting (#107) 2019-11-13 10:41:38 -08:00
kritz 38e966cea1 Add min, max, constrain function for Matrix (#105)
* Add min, max, constrain function for Matrix

* Set individual elements to nan in constrain

* Deal with NANs
2019-11-12 18:57:12 +01:00
Julian Kent 9f46483951 Fix GCC-4.8 bug 2019-11-04 11:11:30 -05:00
Julian Kent 445f58d484 Fix weird C preprocessor conflicts (#101) 2019-11-01 14:23:35 +01:00
Julian Kent 215203fc6f Automatic Differentiation 'Dual' Type (#100)
* Dual numbers initial implementation

* Add test coverage, with partial derivative example

* Add Jacobian test, fix small issues

* Improve test to demonstrate non-square jacobian

* Better naming for collectReals/Derivatives

* Improve comments

* Potential GCC 4.8 bug workaround

* Add fallback workaround for non-IEEE float platforms
2019-10-23 12:07:51 +02:00
Julian Kent 92d1c8761e More features: longerThan, norm, copyTo and slice on a Slice (#97)
* Allow slices of slices, add longerThan to Vector/Slice
2019-10-03 13:47:36 +02:00
Matthias Grob 740324cf1e Make all array constructors explicit (#99)
* Make all array constructors explicit

to avoid accidental implicit casts like e.g.
Vector3f v = 0;
assigning nullpointer content.
2019-10-03 13:38:51 +02:00
Matthias Grob 973999a4d3 Fix some template type conversions and style 2019-09-23 10:59:12 +02:00
Matthias Grob c34e8dc98f helper: consider matrices with the same NANs and INFINITYs equal
to simplify bulk checks when these values are expected
2019-09-18 09:59:50 +02:00
Matthias Grob bbaa93880b helper: consider NAN equal to NAN such that vectors can be compared exactly 2019-09-18 09:59:50 +02:00
Matthias Grob 33a629105c Matrix: add proper print function testing
Before the print function was just implicitly called somewhere
and that's why we had 100% line coverage. With this we have actual
testing of the functions.
2019-09-18 09:59:50 +02:00
Matthias Grob 3747232724 LeastSquaresSolver: Fix nasty GCC compile optimization error
The original implementation with no wrapping on size_t is more readable
but the compiler errors with:
internal compiler error: in trunc_int_for_mode, at explow.c:55
I read up and it's apparently a loop optimization problem.
Inspired by https://stackoverflow.com/a/27224697/6326048
I used a far less readable implementation that works fine and
wrote a comment to explain it.
2019-09-18 09:59:50 +02:00
Matthias Grob 5844b0e46e Implement one float equality check and use it everywhere 2019-09-18 09:59:50 +02:00
Matthias Grob a374f37a54 Include helper_functions like all other library components 2019-09-18 09:59:50 +02:00
James Goppert 60c9c99dcc Fix type for division. 2019-09-17 11:08:00 -04:00
Julian Kent b4714e2ed2 Don't lose array sizes in copyTo 2019-09-17 15:09:12 +02:00