1 | initial version |
Found the solution. We have to explicitly define index
from sympy.tensor import IndexedBase, Idx
from sympy import symbols
n,m = symbols('n m', integer=True)
A = IndexedBase('A')
x = IndexedBase('x')
y = IndexedBase('y')
i = Idx('i', m)
j = Idx('j', n)
codegen(('matrix_vector', Eq(y[i], A[i, j]*x[j])), "C","file", header=False, empty=False)