## Matrix implementation in cpp

A matrix is a data structure with rows and columns. It could be thought of as a two-dimensional array.
Matrices are expressed by their number of rows and columns usually denoted by the letters m and n respectively. For example, a matrix with 6 rows and 3 columns is denoted as a 6 by 3 matrix.

Two example matrices:

Usage
Matrices have many applications. Consider graphics, where a digital image is basically a matrix to begin with. Rows and columns of the matrix correspond to rows and columns of pixels, and the numerical entries correspond to the pixels’ color values.
Other applications include decoding digital video, processing digital sound, and so on.
As another example, graphs are often represented using matrices, where the values show which vertices of the graph are connected.

Operations
Matrices support many operations, such as addition and multiplication, as well as some more specific ones, like transposition, row operations, and submatrix.

Matrix Operations

Addition and scalar multiplication are the most basic matrix operations.
These are heavily used in calculations that solve problems in algebra, physics, and many other fields.

Scalar Multiplication
As the name suggests, a matrix is multiplied by a scalar (a constant), which results in a matrix where each element of the original matrix has been multiplied by the scalar.
For example:

In order to add two matrices, they must correspond in dimensional sense (must have the same dimensions). For example, you cannot add a 3 by 4 matrix to a 4 by 2 matrix. Instead, we can add a 3 by 4 matrix to another 3 by 4 matrix.
Check out the following example:

Each element from the first matrix is added to its corresponding element from the second matrix

Implementation in cpp:

```#include <iostream>
using namespace std;

int main() {
int a = {
{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12}
};

int b = {
{12, 11, 10, 9},
{8, 7, 6, 5},
{4, 3, 2, 1}
};

int res;

for(int j = 0; j < 3; j++)
for(int k = 0; k < 4; k++)
res[j][k] = a[j][k] + b[j][k];

for(int i = 0; i < 3; i++) {
for(int j = 0; j < 4; j++) {
cout << res[i][j] << " ";
}
cout << endl;
}

return 0;
}```