def __init__(self, *args):
     if len(args) == 1:
         if Geometry.isTensor(args[0]):
             self.tensor = args[0]
         else:
             self.tensor = Geometry.Tensor(args[0])
             assert self.tensor.rank == 2
     elif len(args) == 3 and Geometry.isVector(args[0]) \
              and Geometry.isVector(args[1]) and Geometry.isVector(args[2]):
         self.tensor = Geometry.Tensor(
             [args[0].array, args[1].array, args[2].array]).transpose()
예제 #2
0
 def __init__(self, *args):
     if len(args) == 1:
         if Geometry.isTensor(args[0]):
             self.tensor = args[0]
         else:
             self.tensor = Geometry.Tensor(args[0])
             assert self.tensor.rank == 2
     elif len(args) == 3 and Geometry.isVector(args[0]) \
              and Geometry.isVector(args[1]) and Geometry.isVector(args[2]):
         self.tensor = Geometry.Tensor([args[0].array, args[1].array,
                                        args[2].array]).transpose()
 def __mul__(self, other):
     from Scientific import Geometry
     if isTensor(other):
         a = self.array[self.rank * (slice(None), ) + (N.NewAxis, )]
         b = other.array[other.rank * (slice(None), ) + (N.NewAxis, )]
         return Tensor(N.innerproduct(a, b), 1)
     elif Geometry.isVector(other):
         return other.__rmul__(self)
     else:
         return Tensor(self.array * other, 1)
예제 #4
0
 def __mul__(self, other):
     from Scientific import Geometry
     if isTensor(other):
         a = self.array[self.rank*(slice(None),)+(N.NewAxis,)]
         b = other.array[other.rank*(slice(None),)+(N.NewAxis,)]
         return Tensor(N.innerproduct(a, b), 1)
     elif Geometry.isVector(other):
         return other.__rmul__(self)
     else:
         return Tensor(self.array*other, 1)