Beispiel #1
0
 def __mul__(self, other):
   # tuple mult
   if isinstance(other, Tuple):
     j = [ sum([x[0] * x[1] for x in zip(self.getRow(i), [other.x, other.y, other.z, other.w])]) for i in range(0,4) ]
     return Tuple(*j)
   # matrix mult
   elif isinstance(other, matrix):
     newMatrix = matrix(self.rows, self.columns)
     for r in range(self.rows):
       for c in range(self.columns):
         newMatrix[r,c] = sum([ x[0] * x[1]  for x in zip( self.getRow(r), other.getColumn(c))])
     return newMatrix
Beispiel #2
0
def step_impl(context):
  context.a = Tuple(4.3, -4.2, 3.1, 1.0)
Beispiel #3
0
def step_impl(context):
  context.a2 = Tuple(-2,3,1,0)
Beispiel #4
0
def step_impl(context):
  assert context.a1 + context.a2 == Tuple(1,1,6,1)
Beispiel #5
0
def step_impl(context):
  assert context.a / 2 == Tuple(0.5, -1, 1.5, -2) 
Beispiel #6
0
def step_impl(context):
  context.a1 = Tuple(3,-2,5,1)
Beispiel #7
0
def step_impl(context):
  assert context.a * 3.5 == Tuple(3.5, -7, 10.5, -14)
Beispiel #8
0
def step_impl(context):
  print(context.a * 0.5)
  assert context.a * 0.5 == Tuple(0.5, -1, 1.5, -2)
Beispiel #9
0
def step_impl(context):
  context.a = Tuple(1,-2,3,-4)
Beispiel #10
0
def step_impl(context):
  assert -context.a == Tuple(-1,2,-3,4)
Beispiel #11
0
def step_impl(context):
    context.tg = Tuple(1, 2, 3, 4)
Beispiel #12
0
def step_impl(context):
    assert context.F * context.b == Tuple(18, 24, 33, 1)
Beispiel #13
0
def step_impl(context):
    context.b = Tuple(1, 2, 3, 1)