Mercurial > forge
changeset 885:1ea43ea20fcb octave-forge
sparse create bug - need to use heap for large temp vars
author | aadler |
---|---|
date | Thu, 03 Apr 2003 22:06:41 +0000 |
parents | 1eb91fa57b97 |
children | e3279553e6df |
files | main/sparse/make_sparse.cc main/sparse/sp_test.m main/sparse/sparse_ops.h |
diffstat | 3 files changed, 40 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/main/sparse/make_sparse.cc Tue Apr 01 19:37:15 2003 +0000 +++ b/main/sparse/make_sparse.cc Thu Apr 03 22:06:41 2003 +0000 @@ -257,12 +257,24 @@ // // I use this clumsy construction so that we can use // any orientation of args - { ColumnVector x( args(0).vector_value(false,true) ); if (error_state) return retval; ridxA= x; } - { ColumnVector x( args(1).vector_value(false,true) ); if (error_state) return retval; cidxA= x; } - if (use_complex) - { ComplexColumnVector x( args(2).complex_vector_value(false,true) ); coefAC= x; } - else - { ColumnVector x( args(2).vector_value(false,true) ); coefA= x; } + { + ColumnVector x( args(0).vector_value(false,true) ); + if (error_state) return retval; + ridxA= x; + } + { + ColumnVector x( args(1).vector_value(false,true) ); + if (error_state) return retval; + cidxA= x; + } + if (use_complex) { + ComplexColumnVector x( args(2).complex_vector_value(false,true) ); + coefAC= x; + } + else { + ColumnVector x( args(2).vector_value(false,true) ); + coefA= x; + } if (error_state) return retval; // Confirm that i,j,s all have the same number of elements @@ -275,8 +287,9 @@ int ni = ridxA.length(); int nj = cidxA.length(); int nnz = MAX(ni,nj); - if ( ( ns != 1 && ns != nnz ) || ( ni != 1 && ni != nnz ) - || ( nj != 1 && nj != nnz ) ) + if ( ( ns != 1 && ns != nnz ) || + ( ni != 1 && ni != nnz ) || + ( nj != 1 && nj != nnz ) ) SP_FATAL_ERR ("i, j and s must have the same length"); if (nargin == 3) { @@ -329,6 +342,9 @@ DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_complex_sparse, "complex_sparse"); /* * $Log$ + * Revision 1.10 2003/04/03 22:06:39 aadler + * sparse create bug - need to use heap for large temp vars + * * Revision 1.9 2003/02/14 03:50:34 aadler * mods to make 'sum' the default *
--- a/main/sparse/sp_test.m Tue Apr 01 19:37:15 2003 +0000 +++ b/main/sparse/sp_test.m Thu Apr 03 22:06:41 2003 +0000 @@ -792,12 +792,18 @@ i, 100*(1 - res(i)/NTRIES) ); end +% segfault test from edd@debian.org +n = 510; sparse(kron((1:n)', ones(n,1)), kron(ones(n,1), (1:n)'), ones(n)); + % clear up variables - so dmalloc works #clear L* U* a* b* c* d* e* P* % % $Log$ +% Revision 1.11 2003/04/03 22:06:40 aadler +% sparse create bug - need to use heap for large temp vars +% % Revision 1.10 2003/02/20 22:51:45 pkienzle % Default to 'sum' rather than 'unique' assembly %
--- a/main/sparse/sparse_ops.h Tue Apr 01 19:37:15 2003 +0000 +++ b/main/sparse/sparse_ops.h Thu Apr 03 22:06:41 2003 +0000 @@ -19,6 +19,9 @@ $Id$ $Log$ +Revision 1.9 2003/04/03 22:06:41 aadler +sparse create bug - need to use heap for large temp vars + Revision 1.8 2003/02/20 23:03:59 pkienzle Use of "T x[n]" where n is not constant is a g++ extension so replace it with OCTAVE_LOCAL_BUFFER(T,x,n), and other things to keep the picky MipsPRO CC @@ -255,6 +258,10 @@ // // NOTE2: be careful about when we convert ri to int, // otherwise the maximum matrix size will be m*n < maxint/2 +// +// The OCTAVE_LOCAL_BUFFER can't be used for the sort index +// when the requested size is too big. we need to put it on the +// heap. #define ASSEMBLE_SPARSE( TYPX ) \ int nnz= MAX( ridxA.length(), cidxA.length() ); \ TYPX* coefX= (TYPX*)oct_sparse_malloc( nnz * sizeof(TYPX)); \ @@ -265,7 +272,7 @@ bool ci_scalar = (cidxA.length() == 1); \ bool cf_scalar = (coefA.length() == 1); \ \ - OCTAVE_LOCAL_BUFFER (sort_idxl, sidx, nnz ); \ + sort_idxl* sidx = (sort_idxl *)oct_sparse_malloc( nnz* sizeof(sort_idxl) );\ int actual_nnz=0; \ OCTAVE_QUIT; \ for (int i=0; i<nnz; i++) { \ @@ -309,7 +316,8 @@ maybe_shrink( ii+1, actual_nnz, ridxX, coefX ); \ \ OCTAVE_QUIT; \ - SuperMatrix X= create_SuperMatrix( m, n, ii+1, coefX, ridxX, cidxX ); + SuperMatrix X= create_SuperMatrix( m, n, ii+1, coefX, ridxX, cidxX ); \ + oct_sparse_free( sidx ); // assemble a sparse matrix from full // called by one arg for sparse