You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
1.2 KiB

2 years ago
# mmathlib
2 years ago
*get repo*
4 years ago
```bash
2 years ago
git clone https://code.smolnet.org/micke/mmathlib.git
cd mmathlib
4 years ago
```
4 years ago
2 years ago
*Compile and run*
**fractions**
```
g++ -o fractions fractions.cpp
```
***Output***
4 years ago
```
2 years ago
./fractions
4 years ago
7/3=(7/3)
7/3=2.333333333
1/11=(1/11)
1/11=0.09090909091
(7/3)+(1/11)=(80/33)
(7/3)+(1/11)=2.424242424
(7/3)-(1/11)=(74/33)
(7/3)-(1/11)=2.242424242
(7/3)*(1/11)=(7/33)
(7/3)*(1/11)=0.2121212121
(7/3)/(1/11)=(77/3)
(7/3)/(1/11)=25.66666667
0.75=(3/4)
2 years ago
```
**Complex numbers**
```
g++ -o cnumber cnumber.cpp
./cnumber
```
***Output***
```
4 years ago
a = 3+2i
a* = 3-2i
a*a* = 13
b = 4-3i
b* = 4+3i
b*b* = 25
a + b = 7-i
(a + b)* = 7+i
a - b = -1+5i
(a - b)* = -1-5i
a * b = 18-i
(a * b)* = 18+i
a / b = (6/25)+(17/25)i
(a / b)* = (6/25)-(17/25)i
2 years ago
```
**vectors**
```
g++ -o vector vector.cpp
./vector
```
***output***
```
v:
| 1 |
| 2 |
| i |
w:
| 3 |
| 4 |
| 5 |
v * w:
11+5i
```
**matrices**
```
g++ -o matrix matrix.cpp
./matrix
```
***output***
```
The matrix m:
| 7 | 5 | i |
| 0 | 2 | 0 |
| -i | 0 | 4 |
The matrix m's transpose:
| 7 | 0 | -i |
| 5 | 2 | 0 |
| i | 0 | 4 |
The matrix m is not hermitian, here is the hermitian conjugate:
| 7 | 0 | i |
| 5 | 2 | 0 |
| -i | 0 | 4 |
4 years ago
```