|
|
@ -7,17 +7,13 @@ cd mmathlib
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
***Compile and run***
|
|
|
|
***Compile and run***
|
|
|
|
|
|
|
|
|
|
|
|
**fractions**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
g++ -o fractions fractions.cpp
|
|
|
|
g++ main.cpp vector.cpp -o example
|
|
|
|
|
|
|
|
./example
|
|
|
|
```
|
|
|
|
```
|
|
|
|
*Output*
|
|
|
|
*Output*
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
./fractions
|
|
|
|
|
|
|
|
7/3=(7/3)
|
|
|
|
7/3=(7/3)
|
|
|
|
7/3=2.333333333
|
|
|
|
7/3=2.333333333
|
|
|
|
1/11=(1/11)
|
|
|
|
1/11=(1/11)
|
|
|
@ -31,16 +27,6 @@ g++ -o fractions fractions.cpp
|
|
|
|
(7/3)/(1/11)=(77/3)
|
|
|
|
(7/3)/(1/11)=(77/3)
|
|
|
|
(7/3)/(1/11)=25.66666667
|
|
|
|
(7/3)/(1/11)=25.66666667
|
|
|
|
0.75=(3/4)
|
|
|
|
0.75=(3/4)
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
**Complex numbers**
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
g++ -o cnumber cnumber.cpp
|
|
|
|
|
|
|
|
./cnumber
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*Output*
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
a = 3+2i
|
|
|
|
a = 3+2i
|
|
|
|
a* = 3-2i
|
|
|
|
a* = 3-2i
|
|
|
|
a*a* = 13
|
|
|
|
a*a* = 13
|
|
|
@ -55,14 +41,6 @@ a * b = 18-i
|
|
|
|
(a * b)* = 18+i
|
|
|
|
(a * b)* = 18+i
|
|
|
|
a / b = (6/25)+(17/25)i
|
|
|
|
a / b = (6/25)+(17/25)i
|
|
|
|
(a / b)* = (6/25)-(17/25)i
|
|
|
|
(a / b)* = (6/25)-(17/25)i
|
|
|
|
```
|
|
|
|
|
|
|
|
**vectors**
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
g++ -o vector vector.cpp
|
|
|
|
|
|
|
|
./vector
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
*output*
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
v:
|
|
|
|
v:
|
|
|
|
| 1 |
|
|
|
|
| 1 |
|
|
|
|
| 2 |
|
|
|
|
| 2 |
|
|
|
@ -103,14 +81,6 @@ Manually set elements of k to elements of v
|
|
|
|
| 1 |
|
|
|
|
| 1 |
|
|
|
|
| 2 |
|
|
|
|
| 2 |
|
|
|
|
| i |
|
|
|
|
| i |
|
|
|
|
```
|
|
|
|
|
|
|
|
**matrices**
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
g++ -o matrix matrix.cpp
|
|
|
|
|
|
|
|
./matrix
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
*output*
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
The matrix m
|
|
|
|
The matrix m
|
|
|
|
| 1 | 1 |
|
|
|
|
| 1 | 1 |
|
|
|
|
| 1 | 1 |
|
|
|
|
| 1 | 1 |
|
|
|
@ -133,6 +103,15 @@ The matrix n's diagonal:
|
|
|
|
The matrix n's off diagonal:
|
|
|
|
The matrix n's off diagonal:
|
|
|
|
| 1+i |
|
|
|
|
| 1+i |
|
|
|
|
| 1-i |
|
|
|
|
| 1-i |
|
|
|
|
|
|
|
|
The vector d:
|
|
|
|
|
|
|
|
| 1-i |
|
|
|
|
|
|
|
|
| 5 |
|
|
|
|
|
|
|
|
The matrix n * the vector d
|
|
|
|
|
|
|
|
| 2-2i | 2 |
|
|
|
|
|
|
|
|
| 5-5i | 25 |
|
|
|
|
|
|
|
|
The vector d * the matrix n
|
|
|
|
|
|
|
|
| 7-7i |
|
|
|
|
|
|
|
|
| 27 |
|
|
|
|
The matrix m * n
|
|
|
|
The matrix m * n
|
|
|
|
| 3-i | 6+i |
|
|
|
|
| 3-i | 6+i |
|
|
|
|
| 3-i | 6+i |
|
|
|
|
| 3-i | 6+i |
|
|
|
|