def access_to_sympy(self, var_name, access):
base_sizes = self.variables[var_name][<NUM_LIT:1>]<EOL>expr = sympy.Number(<NUM_LIT:0>)<EOL>for dimension, a in enumerate(access):<EOL><INDENT>base_size = reduce(operator.mul, base_sizes[dimension+<NUM_LIT:1>:], sympy.Integer(<NUM_LIT:1>))<EOL>expr += base_size*a<EOL><DEDENT>return expr<EOL>
Transform a (multidimensional) variable access to a flattend sympy expression.

Also works with flat array accesses.