in spqr_householder, use heap when the expected array size is greater than 2M bytes, otherwise, use local stack. Could have a better fix globally

release/4.3a0
Yong-Dian Jian 2010-09-25 13:46:16 +00:00
parent 5745226452
commit c1fee1ab88
1 changed files with 12 additions and 1 deletions

View File

@ -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<n; j++)
for(int i=0; i<m; i++, k++)
a[k] = A(i,j);
@ -126,6 +135,8 @@ namespace gtsam {
A(i,j) = a[k];
}
if ( mn > sz ) delete [] a;
delete []Stair;
cholmod_l_finish(&cc);
}