def test_For(): f = For(n, Range(0, 3), (Assignment(A[n, 0], x + n), aug_assign(x, '+', y))) f = For(n, (1, 2, 3, 4, 5), (Assignment(A[n, 0], x + n), )) assert f.func(*f.args) == f raises(TypeError, lambda: For(n, x, (x + y, )))
# Output will be a template function - this is the type templateT = Type('T') # forward sweep fr = ARange(start + 1, end, 1) body = [] for e in subexpr: body.append( Variable(e[0], type=templateT).as_Declaration(value=e[1].subs(storage_subs))) body.append(convert_eq_to_assignment(teq3c)) body.append(convert_eq_to_assignment(teq4c)) loop1 = For(i, fr, body) # backward sweep br = ARangeClosedEnd(end - 1, start, -1) loop2 = For(i, br, [convert_eq_to_assignment(teq6c)]) tmp_init = VariableWithInit("n", tmp, type=Type("std::vector<T>")).as_Declaration() bc_tmps = [] for e in bc_eqs2: bc_tmps.append(Variable(e.lhs, type=templateT).as_Declaration(value=e.rhs)) body = [tmp_init] body.extend(bc_tmps) body.extend([
def test_For(): f = For(n, Range(0, 3), (Assignment(A[n, 0], x + n), aug_assign(x, '+', y))) f = For(n, (1, 2, 3, 4, 5), (Assignment(A[n, 0], x + n),)) assert f.func(*f.args) == f raises(TypeError, lambda: For(n, x, (x + y,)))