| 1 |
#include <iostream> |
| 2 |
#include "matrix.h" |
| 3 |
using namespace std; |
| 4 |
|
| 5 |
int main(int argc, char **argv) |
| 6 |
{ |
| 7 |
Matrix<3, 2> matrix(cin); |
| 8 |
|
| 9 |
Matrix<1, 2> colMargins(matrix); |
| 10 |
cout << "Column marginals:\n"; |
| 11 |
cout << colMargins[0] << " " << colMargins[1] << '\n'; |
| 12 |
|
| 13 |
Matrix<3, 1> rowMargins(matrix); |
| 14 |
cout << "Row marginals:\n"; |
| 15 |
for (size_t idx = 0; idx < 3; idx++) |
| 16 |
cout << rowMargins[idx] << '\n'; |
| 17 |
|
| 18 |
cout << "Sum total: " << Matrix<1, 1>(matrix) << '\n'; |
| 19 |
} |
| 20 |
/* |
| 21 |
Generated output from input: 1 2 3 4 5 6 |
| 22 |
|
| 23 |
Column marginals: |
| 24 |
9 12 |
| 25 |
Row marginals: |
| 26 |
3 |
| 27 |
7 |
| 28 |
11 |
| 29 |
Sum total: 21 |
| 30 |
*/ |