-
Notifications
You must be signed in to change notification settings - Fork 7
/
Demo.cpp
49 lines (42 loc) · 1000 Bytes
/
Demo.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
/**
* Demo file for the exercise on numbers with units
*
* @author Erel Segal-Halevi
* @since 2019-02
*
* Edited by Tal Zichlinsky
* @since 2022-02
*/
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdexcept>
using namespace std;
#include "Matrix.hpp"
using namespace zich;
int main() {
std::vector<double> identity = {1, 0, 0, 0, 1, 0, 0, 0, 1};
std::vector<double> arr = {3, 0, 0, 0, 3, 0, 0, 0, 3};
Matrix a{identity, 3, 3}; // constructor taking a vector and a matrix size
cout << a << endl;
/* prints [1 0 0]
[0 1 0]
[0 0 1]*/
cout << (-a) << endl;
/* prints [-1 0 0]
[0 -1 0]
[0 0 -1]*/
cout << (3*a) << endl;
/* prints [3 0 0]
[0 3 0]
[0 0 3]*/
Matrix b{arr, 3, 3};
a *= -3;
cout << (a+b) << endl; // prints the 0 matrix
cout << (b-a) << endl;
/* prints [6 0 0]
[0 6 0]
[0 0 6]*/
cout << "End of demo!" << endl;
return 0;
}