-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.cpp
44 lines (34 loc) · 1.19 KB
/
example.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
#include "vmatrix.h"
#include <iostream>
#include <vector>
int main() {
VMatrix::Matrix m1 = VMatrix::Matrix(3, 3);
m1.fillMatrixWithRandNums(1, 99);
VMatrix::Matrix m2 = VMatrix::Matrix(3, 3);
m2.fillMatrixWithRandNums(1, 99);
std::cout << "Matrix1: " << std::endl;
m1.printMatrix();
std::cout << "Matrix2: " << std::endl;
m2.printMatrix();
std::cout << "Matrix1 + Matrix2: " << std::endl;
(m1 + m2).printMatrix();
std::cout << "Matrix1 - Matrix2: " <<std::endl;
(m1 - m2).printMatrix();
std::cout << "Matrix1 * Matrix2: " << std::endl;
(m1 * m2).printMatrix();
//Create custom 2x2
VMatrix::MatrixVector mVec;
mVec.push_back(std::vector<int>(2)); // row 1
mVec.push_back(std::vector<int>(2)); // row 2
mVec[0][0] = 12; mVec[0][1] = 21;
mVec[1][0] = 10; mVec[1][1] = 11;
VMatrix::Matrix custMatrix = VMatrix::Matrix(mVec, 2, 2);
// or
VMatrix::Matrix custMatrix2 = VMatrix::Matrix(2, 2);
custMatrix2.setNewMatrix(mVec);
std::cout << "Printing Custom Matrix: " << std::endl;
custMatrix.printMatrix();
std::cout << "Printing Custom Matrix2: " << std::endl;
custMatrix2.printMatrix();
return 0;
}