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
parent
5745226452
commit
c1fee1ab88
|
@ -94,8 +94,17 @@ namespace gtsam {
|
||||||
Stair[j] = m;
|
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
|
// 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 j=0; j<n; j++)
|
||||||
for(int i=0; i<m; i++, k++)
|
for(int i=0; i<m; i++, k++)
|
||||||
a[k] = A(i,j);
|
a[k] = A(i,j);
|
||||||
|
@ -126,6 +135,8 @@ namespace gtsam {
|
||||||
A(i,j) = a[k];
|
A(i,j) = a[k];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( mn > sz ) delete [] a;
|
||||||
|
|
||||||
delete []Stair;
|
delete []Stair;
|
||||||
cholmod_l_finish(&cc);
|
cholmod_l_finish(&cc);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue