main.cpp
```1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
```
```#include <iostream>
#include <vector>

//Create a Vector with this Method
void vector(std::vector<int>& vec){

int size_vec; // creates the variable for the size of a vector.
//std::cout << "Enter the Size of the Vector ? " << std::endl; // How many elements should the vectore have ?
std::cin >> size_vec; // store the number of elements (size) in the variable size_vec.
vec.resize(size_vec); // resize the vector with the resize method.

//std::cout << "Enter the " << size_vec << " Elements of the Vector ? " << std::endl; // Enter the elements into the vector.
for(int i = 0 ; i < size_vec ; ++i){ //Use a for loop for that.
std::cin >> vec[i];
}

/*
std::cout << "v " << vec.size() << std::endl; //Output the Vectors elements.
for(unsigned int k = 0 ; k < vec.size(); ++k){ // Use a for loop for that.
std::cout << vec[k] << " "; // Output the elements separated by an space.
}
*/

}

//TODO: Write method to create, size and fill Matrix.
void matrix(std::vector<std::vector<int>>& mat){
int m;
int n;

//std::cout << "Enter number of rows: " << std::endl;
std::cin >> m;

//std::cout << "Enter number of columns: " << std::endl;
std::cin >> n;

mat.resize(m, std::vector<int>(n)); // resize the matrix.

for(int i=0  ; i<m ; ++i){
for(int j=0; j<n ; ++j){
//std::cout << "Enter Elemnts of Matrix: " << std::endl;
std::cin>>mat[i][j];}
std::cout<<std::endl;}

/*
std::cout<<"m"<< m << n << std::endl;
for(int q=0;q<m;++q){
for(int w=0;w<n;++w){
std::cout<<mat[q][w]<<" ";}
std::cout<<std::endl;
}
*/

}

//------------------ Operation Methods ------------------//
//------------------------ below ------------------------//

//PRE: a and b are the same length.
//POST: Returns the dot product of a and b.
int dot_product(std::vector<int>& a, std::vector<int>& b){
int product = 0;
for(unsigned int k=0 ; k < b.size() ; ++k){
product += a[k]*b[k];
}
return product;
}

//TODO: Write function for Matrix vector product
//PRE: input is m and v.
//POST:
void mvp(std::vector<std::vector<int>>& c, std::vector<int>& d){
std::vector<int> mv_product;
for(unsigned int h = 0 ; h < d.size() ; ++h){
for(unsigned int g = 0 ; g < d.size() ; ++g){
mv_product[h] += c[h][g]*d[g];
}
}
}

//TODO: Write function for MATRIXPRODUCT
//PRE: input is m and m.
//POST:
//code here:

int main() {
char x1;
//std::cout << " Press m for matrix and v for vector: " << std::endl;
std::cin >> x1;
std::vector<int> a1;
std::vector<std::vector<int>> b1;

if(x1=='v'){
vector(a1);}
if(x1=='m'){
matrix(b1);}

char x2;
//std::cout << " Again, Press m for matrix and v for vector: " << std::endl;
std::cin >> x2;
std::vector<int> a2;
std::vector<std::vector<int>> b2;

if(x2=='v')
vector(a2);
if(x2=='m')
matrix(b2);

//std::cout << "\n" << "s" << dot_product(a,b) << std::endl;

//TODO: If vector vector check dimensoins, then call dot product function. And output letter and return value.
if(x1=='v' || x2 == 'v')
std::cout << "s " << dot_product(a1,a2) << std::endl;

//TODO: If matrix vector check dimensoins, call Matrix-vector product. And output letter and return value.
if(x1=='m' || x2 == 'v')
mvp(b1, a2);

//TODO: If matrix matrix call Matrix product. And output letter and return value.

//TODO: If vector matrix output error.

return 0;
}
```