示例#1
0
def _new_operator1(shape, **kwargs):
    infield = DenseData(name='infield', shape=shape, dtype=np.int32)
    infield.data[:] = np.arange(reduce(mul, shape), dtype=np.int32).reshape(shape)

    outfield = DenseData(name='outfield', shape=shape, dtype=np.int32)

    stencil = Eq(outfield.indexify(), outfield.indexify() + infield.indexify()*3.0)

    # Run the operator
    op = Operator(stencil, **kwargs)
    op(infield=infield, outfield=outfield)

    return outfield, op
示例#2
0
def symbol(name, dimensions, value=0., mode='function'):
    """Short-cut for symbol creation to test "function"
    and "indexed" API."""
    assert(mode in ['function', 'indexed'])
    s = DenseData(name=name, dimensions=dimensions)
    s.data[:] = value
    return s.indexify() if mode == 'indexed' else s
示例#3
0
def test_arithmetic_deep(expr, result):
    """Tests basic point-wise arithmetic on multi-dimensional data"""
    i = Dimension(name='i', size=3)
    j = Dimension(name='j', size=4)
    k = Dimension(name='k', size=5)
    l = Dimension(name='l', size=6)

    a = DenseData(name='a', dimensions=(i, j, k, l))
    a.data[:] = 2.
    ai = a.indexify()
    b = DenseData(name='b', dimensions=(j, k))
    b.data[:] = 3.
    bi = b.indexify()

    eqn = eval(expr)
    StencilKernel(eqn)(ai.base.function, bi.base.function)
    assert np.allclose(ai.base.function.data, result, rtol=1e-12)
示例#4
0
def bi(x, y, name='b', value=3.):
    b = DenseData(name=name, dimensions=(x, y))
    b.data[:] = value
    return b.indexify()
示例#5
0
def ai(x, y, name='a', value=2.):
    a = DenseData(name=name, dimensions=(x, y))
    a.data[:] = value
    return a.indexify()