Ejemplo n.º 1
0
 def __call__(self, *arg):
     r"""
     Redefinition of :meth:`TensorField.__call__` to allow for a single 
     vector argument. 
     """
     if len(arg) > 1:
         # the endomorphism acting as a type (1,1) tensor on a pair
         # (1-form, vector), returning a scalar:
         return TensorField.__call__(self, *arg)
     # the endomorphism acting as such, on a vector, returning a vector:
     vector = arg[0]
     if not isinstance(vector, VectorField):
         raise TypeError("The argument must be a vector field.")
     frame = self.common_frame(vector)
     t = self.components[frame]
     v = vector.components[frame]
     manif = self.manifold
     result = VectorField(self.domain)
     n = manif.dim
     si = manif.sindex
     for i in range(si, si + n):
         res = 0
         for j in range(si, si + n):
             res += t[[i, j]] * v[[j]]
         result.set_comp(frame)[i] = res
     # Name of the output:
     result.name = None
     if self.name is not None and vector.name is not None:
         result.name = self.name + "(" + vector.name + ")"
     # LaTeX symbol for the output:
     result.latex_name = None
     if self.latex_name is not None and vector.latex_name is not None:
         result.latex_name = self.latex_name + r"\left(" + \
                           vector.latex_name + r"\right)"
     return result
Ejemplo n.º 2
0
 def __call__(self, *arg):
     r"""
     Redefinition of
     :meth:`~sage.geometry.manifolds.tensorfield.TensorField.__call__`
     to allow for a proper
     treatment of the identity map and of the call with a single argument
     """
     if self._is_identity:
         if len(arg) == 1:
             # The identity map acting as such, on a vector field:
             vector = arg[0]
             if vector._tensor_type != (1,0):
                 raise TypeError("the argument must be a vector field")
             dom = self._domain.intersection(vector._domain)
             return vector.restrict(dom)
         elif len(arg) == 2:
             # self acting as a type-(1,1) tensor on a pair
             # (1-form, vector field), returning a scalar field:
             oneform = arg[0]
             vector = arg[1]
             dom = self._domain.intersection(
                               oneform._domain).intersection(vector._domain)
             return oneform.restrict(dom)(vector.restrict(dom))
         else:
             raise TypeError("wrong number of arguments")
     # Generic case
     if len(arg) == 1:
         raise NotImplementedError("__call__  with 1 arg not implemented yet")
     return TensorField.__call__(self, *arg)
Ejemplo n.º 3
0
 def __call__(self, *arg):
     r"""
     Redefinition of :meth:`TensorField.__call__` to allow for a single 
     vector argument. 
     """
     if len(arg) > 1:
         # the endomorphism acting as a type (1,1) tensor on a pair 
         # (1-form, vector), returning a scalar:
         return TensorField.__call__(self, *arg) 
     # the endomorphism acting as such, on a vector, returning a vector:
     vector = arg[0]
     if not isinstance(vector, VectorField):
         raise TypeError("The argument must be a vector field.")
     frame_name = self.common_frame(vector)
     t = self.components[frame_name]
     v = vector.components[frame_name]
     manif = self.manifold
     result = VectorField(self.domain)
     n = manif.dim
     si = manif.sindex
     for i in range(si, si+n):
         res = 0
         for j in range(si, si+n):
             res += t[[i,j]]*v[[j]]
         result.set_comp(frame_name)[i] = res
     # Name of the output:
     result.name = None
     if self.name is not None and vector.name is not None:
         result.name = self.name + "(" + vector.name + ")"
     # LaTeX symbol for the output:
     result.latex_name = None
     if self.latex_name is not None and vector.latex_name is not None:
         result.latex_name = self.latex_name + r"\left(" + \
                           vector.latex_name + r"\right)"
     return result
Ejemplo n.º 4
0
 def __call__(self, *arg):
     r"""
     Redefinition of
     :meth:`~sage.geometry.manifolds.tensorfield.TensorField.__call__`
     to allow for a proper
     treatment of the identity map and of the call with a single argument
     """
     if self._is_identity:
         if len(arg) == 1:
             # The identity map acting as such, on a vector field:
             vector = arg[0]
             if vector._tensor_type != (1, 0):
                 raise TypeError("the argument must be a vector field")
             dom = self._domain.intersection(vector._domain)
             return vector.restrict(dom)
         elif len(arg) == 2:
             # self acting as a type-(1,1) tensor on a pair
             # (1-form, vector field), returning a scalar field:
             oneform = arg[0]
             vector = arg[1]
             dom = self._domain.intersection(oneform._domain).intersection(
                 vector._domain)
             return oneform.restrict(dom)(vector.restrict(dom))
         else:
             raise TypeError("wrong number of arguments")
     # Generic case
     if len(arg) == 1:
         raise NotImplementedError(
             "__call__  with 1 arg not implemented yet")
     return TensorField.__call__(self, *arg)