C99 VLA are not dynamically allocated, they exhaust the static stack rather 
quickly. If you are writing the C part of the code yourself it is in the 
long run almost certainly better to put matrices on the heap. If you have a 
maximal size for arrays you could use that as static bound. Or replace them 
with a C++ matrix class that does the dynamic allocation (e.g. 
boost::numeric::ublas::matrix)




On Thursday, October 16, 2014 12:28:21 PM UTC+1, Dima Pasechnik wrote:
>
> In C99 it's possible to do dynamic allocation of multidimensional arrays: 
>
> void blah(int n) { 
>      int a[n][n]; 
> ...} 
>
> but this does not seem to be supported in Cython. If I try 
> sage -cython on 
>
> def t(int n): 
>    cdef int a[n][n] 
>    cdef int i, j 
>    for i in range(n): 
>        for j in range(n): 
>            a[i][j]=i+j 
>    return a[0][n-1] 
>
> I get 
>
> Error compiling Cython file: 
> ------------------------------------------------------------ 
> ... 
> def t(int n): 
>    cdef int i, j 
>    cdef int a[n][n] 
>                  ^ 
> ------------------------------------------------------------ 
>
> m.pyx:3:18: Not allowed in a constant expression 
>
> As I have C99 code I'd like to hook up to Sage, I'd really 
> like to know how to get around this limitation (with as little overhead 
> as possible) 
>
> Thanks, 
> Dima 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to