[ADOL-C] problem with reusing sparsity pattern when calling "sparse_jac"

T virtpool at gmx.net
Mon Mar 14 08:23:19 EDT 2011

Hello everyone,

I don't seem to be able to reuse the sparse jacobian structure using the funcion "sparse_jac":
It always ends up at "ADOL-C error in sparse_jac(): Number of nonzeros not consistent, repeat call with repeat = 0".

So when I call it like that in my program

/* code snippet */
if( -3 == sparse_jac( 1, nMeasurements, nUnknowns, repeat, p,&nnz,&rind,&cind,&J_sparse, options ) )
		sparse_jac( 1, nMeasurements, nUnknowns, 0, p,&nnz,&rind,&cind,&J_sparse, options );
	repeat = 1;
/* end code snippet */

the if evaluation will always return true, and hence call it with repeat=0.

If I add this
/* code snippet */
  if (sJinfos.nnz_in != *nnz) {
         printf(" ADOL-C error in sparse_jac():"
                " Number of nonzeros not consistent,"
                " repeat call with repeat = 0 \n");
		// HACK
		printf( "sJinfos.nnz_in = %i, *nnz = %i\n, printing tag stats:\n", sJinfos.nnz_in, *nnz );
		printTapeStats(	stdout, tag );
         return -3;
/* end code snippet */
inside "sparsedrivers.cpp", it will always print '0' for sJinfos.nnz_in, and the correct number of non-zero elements for *nnz estimated in the previous iteration. "printTapeStats" also always prints the exact same numbers.

Am I missing something? Why is sJinfos.nnz_in 0, when it is correctly estimated when I call "sparse_jac" with repeat=0? The jacobian obtained with repeat=0 are correct, I just can't figure out why it can't reuse the sparsity pattern.

Thanks in advance,

More information about the ADOL-C mailing list