예제 #1
0
    def _visit_StencilVectorGlobalBasis(self, expr, **kwargs):
        pads = expr.pads
        rank = expr.rank
        tag = expr.tag
        name = 'g_vec_{}'.format(tag)

        return IndexedVariable(name, dtype='real', rank=rank)
예제 #2
0
    def _visit_MatrixLocalBasis(self, expr, **kwargs):
        dim = self.dim
        rank = self._visit(expr.rank)
        target = SymbolicExpr(expr.target)

        name = 'arr_{}'.format(target.name)
        return IndexedVariable(name, dtype='real', rank=rank)
예제 #3
0
    def _visit_StencilMatrixLocalBasis(self, expr, **kwargs):
        pads = expr.pads
        rank = expr.rank
        tag = expr.tag
        name = 'l_mat_{}'.format(tag)

        return IndexedVariable(name, dtype='real', rank=rank)
예제 #4
0
 def contruct_variable(cls, name, dtype, rank, **args):
     if issubclass(cls, Variable):
         return Variable(dtype, name, rank=rank, **args)
     elif issubclass(cls, IndexedVariable):
         return IndexedVariable(name, dtype=dtype, rank=rank, **args)
     else:
         raise TypeError(
             'only Variables and IndexedVariables are supported')
예제 #5
0
from sympy.utilities.pytest import raises


from pyccel.ast import (Assign, AugAssign, datatype,
                        Bool, Int, Float, Double, Void,
                        IndexedVariable,
                        For, Variable, FunctionDef)

n = Variable('int', 'n')
x = Variable('double', 'x')
y = Variable('double', 'y')

#A = MatrixSymbol('A', 3, 1)
#mat = Matrix([1, 2, 3])

B = IndexedVariable('B', dtype='double')
i = Variable('int', 'i')

def test_Assign():
    # Here we just do things to show they don't error
    Assign(x, y)
    Assign(x, 0)
#    Assign(A, mat)
#    Assign(A[1, 0], 0)
#    Assign(A[1, 0], x)
    Assign(B[i], x)
    Assign(B[i], 0)
    a = Assign(x, y)
    assert a.func(*a.args) == a
#    # Here we test things to show that they error
#    # Matrix to scalar