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
Next revisionBoth sides next revision
tools:matrix:start [2021/11/14 16:41] ursgraftools:matrix:start [2022/04/07 12:25] – [Accessing Elements] ursgraf
Line 17: Line 17:
 <code cpp> <code cpp>
 Matrix<3, 3, int> m;  Matrix<3, 3, int> m; 
-m << 1, 47+m << 1, 23
-     2, 5, 8+     4, 5, 6
-     36, 9;+     78, 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 colon. While the internal representation is simply a one dimensional vector, the matrix could be visualized as 
Line 32: Line 32:
 <code cpp> <code cpp>
 m.get(0,0);  // returns element, 1 m.get(0,0);  // returns element, 1
-m.getRow(1);  // returns row, [2,5,8+m.get(1,0);  // returns element, 4 
-m.getCol(0);  // returns column, [1,2,3]' +m.getRow(1);  // returns row, [4,5,6
-m.getSubMatrix<2,2>(0,1);   // returns matrix [[4,5][7,8]]+m.getCol(0);  // returns column, [1,4,7]' 
 +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 70: Line 71:
  
 ===== Matrix Operations ===== ===== Matrix Operations =====
 +Some examples show basic matrix operations.
 +<code cpp>
 +Vector2 v1{1,2};
 +Matrix<1,2> v2{3,4};
 +log.info() << v1 * v2;            // will print [ [3 6]' [4 8]' ]
 +log.info() << v2 * v1;            // will print [11]'
  
 +Matrix<2,2,double> m1{1,1.5,-1,2};
 +log.info() << v2 * m1;            // will print [ [9]' [5]' ]
 +log.info() << v1.transpose() * m1;// will print [ [4]' [3]' ]
 +
 +auto x = v2 * m1;
 +Vector2 v4 = x.transpose();
 +log.info() << v4;                 // will print [9 5]'
 +</code>
tools/matrix/start.txt · Last modified: 2022/04/20 13:29 by ursgraf