diff --git a/base/SPQRUtil.cpp b/base/SPQRUtil.cpp index 52180afc6..3552009ce 100644 --- a/base/SPQRUtil.cpp +++ b/base/SPQRUtil.cpp @@ -94,8 +94,17 @@ namespace gtsam { Stair[j] = m; } + + // YDJ: allocate buffer if m*n grows more than 2M bytes + const int sz = 250000; // the stack is limited to 2M, o + const int mn = m*n ; + double buf[sz] ; + double *a ; + if ( mn > sz ) a = new double [mn] ; + else a = buf ; + // convert from row major to column major - double a[m*n]; int k = 0; + int k = 0; for(int j=0; j sz ) delete [] a; + delete []Stair; cholmod_l_finish(&cc); }