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.
Micke Nordin e662c7bebd
Add identity matrix and check for eigenvalue
2 years ago
LICENSE Initial commit 2 years ago
README.md More output 2 years ago
cnumber.cpp Simplyfy a bit 5 years ago
cnumber.hpp Add more construectors 2 years ago
fractions.cpp Switch to long long 5 years ago
fractions.hpp Get types to line up and add this keyword 2 years ago
matrix.cpp Switch terminology and add rotation by one pi radian 2 years ago
matrix.hpp Add identity matrix and check for eigenvalue 2 years ago
vector.cpp Test all functionality 2 years ago
vector.hpp Format 2 years ago

README.md

mmathlib

get repo

git clone https://code.smolnet.org/micke/mmathlib.git
cd mmathlib

Compile and run

fractions

g++ -o fractions fractions.cpp

Output

./fractions
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)

Complex numbers

g++ -o cnumber cnumber.cpp
./cnumber

Output

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

vectors

g++ -o vector vector.cpp           
./vector

output

v:
| 1 |
| 2 |
| i |
w:
| 3 |
| 4 |
| 5 |
v + w:
| 4 |
| 6 |
| 5+i |
v - w:
| -2 |
| -2 |
| -5+i |
v * w:
11+5i
w * i:
| 3i |
| 4i |
| 5i |
Element 0 of v:
1
Element 1 of v:
2
Element 2 of v:
i
A temp vector of dimension 3
| 0 |
| 0 |
| 0 |
Assignment of w to k
| 3 |
| 4 |
| 5 |
Manually set elements of k to elements of v
| 1 |
| 2 |
| i |

matrices

g++ -o matrix matrix.cpp           
./matrix

output

The matrix m:
| 7 | 6+i |
| 5 | 3 |
The matrix m roted by one pi radian:
| 6+i | 3 |
| 7 | 5 |
The determinant of matrix m:
-9-5i
The matrix m's transpose:
| 7 | 5 |
| 6+i | 3 |
The matrix m's diagonal:
| 7 |
| 3 |
The matrix m's off diagonal:
| 6+i |
| 5 |
The matrix n
| 2 | 1+i |
| 1-i | 5 |
The determinant of matrix n:
8
The matrix m * n
| 21-5i | 37+12i |
| 13-3i | 20+5i |
The matrix m is not hermitian, here is the hermitian conjugate:
| 7 | 5 |
| 6-i | 3 |
The matrix n is hermitian, here is the hermitian conjugate:
| 2 | 1+i |
| 1-i | 5 |