> Eigen matrices have a range of methods to access their submatrices (blocks), instead of individual entries at a time.Suppose A is an Eigen::MatrixXd object, then a few useful methods are:
*`A.row(i)`: the i-th row of A,
*`A.col(j)`: the j-th column of A,
*`A.topRows(p)`: the first p rows of A,
*`A.leftCols(q)`: the first q columns of A,
*`A.bottomRightCorner(p,q)`: the p by q matrix formed by the intersection of the last p rows and last q columns of A, and more generally
*`A.block(i,j,p,q)`: the p by q submatrix of A, whose top-left corner is at the index (i,j).
> The purpose of this exercise is to learn to declare and initialize Eigen matrices, and to get familiar with some handy typedefs and methods.
> Open "MatrixBlocks.hpp" and fill in the missing code in between the delimiters `// START` and `// END` according to the instructions preceded by `// TO DO:`.
> Read each function of the program carefully. The code will not compile until after the first two tasks are finished, which is to include headers and set the namespace.
> There are three functions in MatrixBlocks.hpp and main.cpp has one test for each function.
***
> `zero_row_col( MatrixXd A, int p, int q )`: This function returns a copy of A with row p and column q set to zero.
The test prints `zero_row_col(Matrix3d::Constant(-1),0,1)`, and the correct result is:
```
0 0 0
-1 0 -1
-1 0 -1
```
***
> `swap_left_right_blocks( MatrixXd A, int p )`: This function swaps splits the matrix A into two blocks, the first p columns and the rest, and returns a matrix in which these blocks have been swapped.
The test prints `swap_left_right_blocks(MatrixXd::Identity(4,3),2)`, and the correct result is:
```
0 1 0
0 0 1
1 0 0
0 0 0
```
***
> `tridiagonal( int n, double a, double b, double c)`: This function creates an n by n tridiagonal matrix with constant diagonals with the values a, b, and c.
The test prints `tridiagonal(4,-1,2,-1)`, and the correct result is: