User Tools

Site Tools


tools:matrix:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tools:matrix:start [2022/04/07 12:23] ursgraftools:matrix:start [2022/04/20 13:29] (current) – [Logging Matrices] ursgraf
Line 8: Line 8:
 Vector3<> v;  Vector3<> v; 
 </code> </code>
-as ''Vector3'' is a predefined type with three dimensions and the default element type is ''double''. A ''Vector3'' is identical to the type ''Matrix<3,1,double>''. The vector could be initializer as follows+as ''Vector3'' is a predefined type with three dimensions and the default element type is ''double''. A ''Vector3'' is identical to the type ''Matrix<3,1,double>''. The vector could be initialized as follows
 <code cpp> <code cpp>
 v = {1.5, -2, 0} v = {1.5, -2, 0}
Line 21: Line 21:
      7, 8, 9;      7, 8, 9;
 </code> </code>
-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 +The first three numbers will be filled into the first row. While the internal representation is simply a one dimensional vector, the matrix could be visualized as 
  
 | ^col0^col1^col2^ | ^col0^col1^col2^
Line 27: Line 27:
 ^row1|4|5|6| ^row1|4|5|6|
 ^row2|7|8|9| ^row2|7|8|9|
 +When declaring and initializing a matrix, the values must be given colon per colon. The same matrix as given above would be initialized as follows  
 +<code cpp> 
 +Matrix<3, 3, int> m{1, 4, 7, 2, 5, 8, 3, 6, 9}; 
 +</code>  
 ===== 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:
Line 33: Line 36:
 m.get(0,0);  // returns element, 1 m.get(0,0);  // returns element, 1
 m.get(1,0);  // returns element, 4 m.get(1,0);  // returns element, 4
-m.getRow(1);  // returns row, [2,5,8+m.getRow(1);  // returns row, [4,5,6
-m.getCol(0);  // returns column, [1,2,3]' +m.getCol(0);  // returns column, [1,4,7]' 
-m.getSubMatrix<2,2>(0,1);   // returns matrix [[4,5][7,8]]+m.getSubMatrix<2,2>(0,1);   // returns matrix [[2,5][3,6]]
 </code> </code>
 Single elements, rows or columns can be written with the methods //set()//, //setRow()//, or //setCol()// Single elements, rows or columns can be written with the methods //set()//, //setRow()//, or //setCol()//
Line 66: Line 69:
 <code> <code>
 2021-09-16 17:37:18:122    I:  [1]' 2021-09-16 17:37:18:122    I:  [1]'
-2021-09-16 17:37:18:122    I:  [1 2]' +2021-09-16 17:37:18:122    I:  [1 2]'         // one colon with two rows 
-2021-09-16 17:37:18:122    I:  [ [1]' [2]' ]'+2021-09-16 17:37:18:122    I:  [ [1]' [2]' ]' // one row with two colons
 </code> </code>
  
tools/matrix/start.1649327028.txt.gz · Last modified: 2022/04/07 12:23 by ursgraf