Ask Your Question

Revision history [back]

click to hide/show revision 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)