示例#1
0
 def __init__(self, dir, name=None):
     super().__init__(ScalarShape())
     self._dir = dir
     if name == None:
         self._name = Expr._dirName(dir)
     else:
         self._name = name
示例#2
0
 def _getShape(x):
     '''Return the shape of the argument x. '''
     if isinstance(x, Expr):
         return x.shape()
     elif isinstance(x, Number):
         return ScalarShape()
     raise ValueError('Expr._getShape() got bad arg [{}]'.format(x))
示例#3
0
class ScalarBasisBase:
    _shape = ScalarShape()

    def __init__(self):
        pass

    def shape(self):
        return ScalarBasisBase._shape
示例#4
0
 def outputShape(self, input):
     if isinstance(input, (VectorShape, VectorShape)):
         return ScalarShape()
     if isinstance(input, TensorShape):
         return VectorShape(input.dim())
     raise ValueError(
         'Div.outputShape expected vector or tensor, got [{}]'.format(
             input))
示例#5
0
    def test_Rot(self):

        x = Coordinate(0)
        y = Coordinate(1)

        rot = _Rot()
        F = Vector(x, y)
        rotF = rot(F)

        print('Rot(F)=', rotF)
        assert (rotF.sameas(DiffOp(rot, F)) and rotF.shape() == ScalarShape())
示例#6
0
    def test_Div(self):

        x = Coordinate(0)
        y = Coordinate(1)

        div = _Div()
        F = Vector(x, y)
        divF = Div(F)

        print('Div(F)=', divF)
        assert (divF.sameas(DiffOp(div, F)) and divF.shape() == ScalarShape())
示例#7
0
 def __init__(self, parent, myIndex):
     super().__init__(ScalarShape())
     super(Expr, self).__init__(parent, myIndex)
示例#8
0
 def __init__(self, data):
     super().__init__(data, ScalarShape())
示例#9
0
 def __init__(self, L, R):
     super().__init__(L, R, ScalarShape())
示例#10
0
 def outputShape(self, input):
     assert (self.acceptShape(input))
     return ScalarShape()
示例#11
0
 def __init__(self, y, x):
     super().__init__(y, x, ScalarShape())