[CppAD] Format for sparse Jacobians/Hessians

Jason Roos jason.roos at duke.edu
Tue Jan 10 14:19:25 EST 2012


Bob,

You make a good point about delegation of responsibility between CppAD and
the calling code. Regarding triplets -- if the triplet format takes less
time to fill because its entries can be unsorted, but most callers will need
to sort the triplets anyway, then it would make sense to take such usage
into account. (I'm not sure which of those conditions actually hold, by the
way.) It might be the case that triples are the quickest format for CppAD to
fill, but not the quickest overall under typical use -- maybe one of the
compressed formats (e.g. CSC, which I think is what Matlab uses) would be
faster?
 
Also, to Michael's point:

> I really envisioned two functions [...]

ADOL-C's interface is more or less set up this way: one function computes
the sparsity pattern, another takes that pattern as an input.

Jason

----------------------------------
From: cppad-bounces at list.coin-or.org [mailto:cppad-bounces at list.coin-or.org]
On Behalf Of Michael Braun
Sent: Tuesday, January 10, 2012 12:22 PM
To: cppad at list.coin-or.org
Subject: Re: [CppAD] Format for sparse Jacobians/Hessians

Bob:

I apologize for not being more specific in my proposal.  Yes, sparse_hessian
would be a member function of the ADFun<Base> object.  I really envisioned
two functions:  one that would return the sparsity structure, and another
that would take that structure as input, and return the values.  One might
already know the structure, and certainly one might want to save the
structure from previous calls for the same matrix.  And of course, there
could be a single function that wraps together computing the structure and
the values.

As far as the output format goes, I had not considered which format might be
easiest to compute.  If triplets are the easiest, then that's fine with me,
as long as the output is sorted, and that the user has an option for row or
column ordering, and lower or upper triangle.  Converting from triplets to
CSC, or many other formats, is straightforward, although it would involve
some additional overhead.

The "big picture" objective is to avoid allocating or returning an NxN dense
matrix, even internally, when computing sparse Hessians, which is what CppAD
does now.

Michael







More information about the CppAD mailing list