Grafiken erweitert
This commit is contained in:
@@ -1,16 +1,54 @@
|
||||
Linear Algebra Refresher
|
||||
# Linear Algebra Refresher
|
||||
|
||||
Addition von Vektoren
|
||||
## Grundgerüst
|
||||
|
||||
```python
|
||||
# -*- coding: iso-8859-15 -*
|
||||
from math import sqrt
|
||||
|
||||
class Vector(object):
|
||||
def __init__(self, coordinates):
|
||||
try:
|
||||
if not coordinates:
|
||||
raise ValueError
|
||||
self.coordinates = tuple(coordinates)
|
||||
self.dimension = len(coordinates)
|
||||
|
||||
except ValueError:
|
||||
raise ValueError('Die Koordinaten dürfen nicht leer sein')
|
||||
|
||||
except TypeError:
|
||||
raise TypeError('Die Koordinaten müssen iterierbar sein')
|
||||
|
||||
def __str__(self):
|
||||
return 'Vector: {}'.format(self.coordinates)
|
||||
|
||||
def __eq__(self, v):
|
||||
return self.coordinates == v.coordinates
|
||||
```
|
||||
|
||||
## Addition von Vektoren
|
||||
|
||||
$\left[ {\begin{array}{*{20}{c}}
|
||||
1\\
|
||||
2
|
||||
5\\
|
||||
0
|
||||
\end{array}} \right] + \left[ {\begin{array}{*{20}{c}}
|
||||
3\\
|
||||
1
|
||||
2\\
|
||||
2
|
||||
\end{array}} \right] = \left[ {\begin{array}{*{20}{c}}
|
||||
4\\
|
||||
3
|
||||
7\\
|
||||
2
|
||||
\end{array}} \right]$
|
||||
|
||||
<img src="vektor_add.png" style="zoom:50%;" />
|
||||
```python
|
||||
veka1 = Vector([0,5])
|
||||
veka2 = Vector([2,2])
|
||||
|
||||
print (veka1.plus(veka2))
|
||||
```
|
||||
|
||||
<img src="vektor_add.png" style="zoom:40%;" />
|
||||
|
||||
```python
|
||||
veka1 = Vector([0,5])
|
||||
```
|
||||
Reference in New Issue
Block a user