tools:matrix:start
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tools:matrix:start [2017/03/17 12:31] – [Accessing Elements] graf | tools:matrix:start [2021/11/12 11:43] – [Logging Matrices] ursgraf | ||
---|---|---|---|
Line 2: | Line 2: | ||
The blocks in the control system are connected among each other with the aid of signals. As described in [[eeros_architecture: | The blocks in the control system are connected among each other with the aid of signals. As described in [[eeros_architecture: | ||
<code cpp> | <code cpp> | ||
- | | + | Vector< |
- | v << 1.5, -2, 0; | + | v << 1.5, -2, 0; |
</ | </ | ||
The declaration could be simplified to | The declaration could be simplified to | ||
<code cpp> | <code cpp> | ||
- | | + | Vector3<> |
- | v << 1.5, -2, 0; | + | v << 1.5, -2, 0; |
</ | </ | ||
as '' | as '' | ||
<code cpp> | <code cpp> | ||
- | | + | Matrix< |
- | m << 1, 4, 7, | + | m << 1, 4, 7, |
- | | + | |
- | | + | |
</ | </ | ||
+ | The first three numbers will be filled into the first colon. While the internal representation is simply a one dimensional vector, the matrix could be visualized as | ||
+ | |||
+ | | ^col0^col1^col2^ | ||
+ | ^row0|1|2|3| | ||
+ | ^row1|4|5|6| | ||
+ | ^row2|7|8|9| | ||
===== Accessing Elements ===== | ===== Accessing Elements ===== | ||
You can access rows, columns or single elements of matrices with the following methods: | You can access rows, columns or single elements of matrices with the following methods: | ||
<code cpp> | <code cpp> | ||
- | m.get(0, | + | m.get(0, |
- | m.getRow(1); | + | m.getRow(1); |
- | m.getCol(0); | + | m.getCol(0); |
+ | m.getSubMatrix< | ||
+ | </ | ||
+ | Single elements, rows or columns can be written with the methods //set()//, // | ||
+ | |||
+ | The operators () and [] work as well as can be seen by the following example | ||
+ | <code cpp> | ||
+ | m(3); // returns element or sets element with index 3 | ||
+ | m[3]; // returns element or sets element with index 3 | ||
+ | m(2, | ||
+ | m[2, | ||
+ | </ | ||
+ | |||
+ | ===== Logging Matrices ===== | ||
+ | A matrix can be logged simply by writing | ||
+ | |||
+ | <code cpp> | ||
+ | log.info() << m; | ||
+ | </ | ||
+ | With the 3 x 3 matrix from above we would get | ||
+ | <code bash> | ||
+ | 2021-09-16 17: | ||
+ | </ | ||
+ | The matrix is plotted colon per colon. To give some more examples: | ||
+ | <code cpp> | ||
+ | Matrix< | ||
+ | Matrix< | ||
+ | Matrix< | ||
+ | </ | ||
+ | This matrices will be printed as | ||
+ | <code bash> | ||
+ | 2021-09-16 17: | ||
+ | 2021-09-16 17: | ||
+ | 2021-09-16 17: | ||
+ | </ |
tools/matrix/start.txt · Last modified: 2022/04/20 13:29 by ursgraf