sympy autowrap (cython): limit of # of arguments, arguments in array form?

后端 未结 1 1600
有刺的猬
有刺的猬 2021-01-25 18:48

I have the following issue:

I want to use autowrap to generate a compiled version of a sympy matrix, with cells containing sympy expressions. Depending on the specificat

相关标签:
1条回答
  • 2021-01-25 19:17

    Passing the argument as an array seems to work OK

    x = sympy.MatrixSymbol('x', 520, 1)
    
    exp = 0
    for i in range(x.shape[0]):
        exp += x[i]
    
    cyt = autowrap(exp, backend='cython')
    
    arr = np.random.randn(520, 1)
    cyt(arr)
    Out[48]: -42.59735861021934
    
    arr.sum()
    Out[49]: -42.597358610219345
    
    0 讨论(0)
提交回复
热议问题