matrix.py
Go to the documentation of this file.
1 import sympy
2 import sys
3 
4 assert sys.version_info >= (3, 5)
5 
6 
7 def dot(left, right):
8  assert(isinstance(left, sympy.Matrix))
9  assert(isinstance(right, sympy.Matrix))
10 
11  sum = 0
12  for c in range(0, left.cols):
13  for r in range(0, left.rows):
14  sum += left[r, c] * right[r, c]
15  return sum
16 
17 
18 def squared_norm(m):
19  assert(isinstance(m, sympy.Matrix))
20  return dot(m, m)
21 
22 
23 def Vector2(x, y):
24  return sympy.Matrix([x, y])
25 
26 
28  return Vector2(0, 0)
29 
30 
31 def Vector3(x, y, z):
32  return sympy.Matrix([x, y, z])
33 
34 
36  return Vector3(0, 0, 0)
37 
38 
39 def Vector6(a, b, c, d, e, f):
40  return sympy.Matrix([a, b, c, d, e, f])
41 
42 
44  return Vector6(0, 0, 0, 0, 0, 0)
45 
46 
47 def proj(v):
48  m, n = v.shape
49  assert m > 1
50  assert n == 1
51  l = [v[i] / v[m - 1] for i in range(0, m - 1)]
52  r = sympy.Matrix(m - 1, 1, l)
53  return r
54 
55 
56 def unproj(v):
57  m, n = v.shape
58  assert m >= 1
59  assert n == 1
60  return v.col_join(sympy.Matrix.ones(1, 1))
sophus.matrix.Vector2
def Vector2(x, y)
Definition: matrix.py:23
sophus.matrix.Vector3
def Vector3(x, y, z)
Definition: matrix.py:31
sophus.matrix.ZeroVector3
def ZeroVector3()
Definition: matrix.py:35
sophus.matrix.ZeroVector6
def ZeroVector6()
Definition: matrix.py:43
sophus.matrix.squared_norm
def squared_norm(m)
Definition: matrix.py:18
sophus.matrix.ZeroVector2
def ZeroVector2()
Definition: matrix.py:27
sophus.matrix.Vector6
def Vector6(a, b, c, d, e, f)
Definition: matrix.py:39
sophus.matrix.unproj
def unproj(v)
Definition: matrix.py:56
sophus.matrix.dot
def dot(left, right)
Definition: matrix.py:7
sophus.matrix.proj
def proj(v)
Definition: matrix.py:47


sophus
Author(s): Hauke Strasdat
autogenerated on Wed Mar 2 2022 01:01:47