Closed kmaitreys closed 7 months ago
Hi kmaitreys,
This is indeed not the best example. The more correct one would be
colptrs = [0,2,5,7]
rowvals = [0, 1, 0, 1, 2, 0, 1]
data = [-0.04, 0.04, 1e4*y[2], -1e4*y[2]-6e7*y[1], 6e7*y[1], 1e4*y[1], -1e4*y[1]]
with exp_mod.jac_nnz = 7
.
While the point of the sparse format is to omit structural zeros, having them included is not wrong - just inefficient. Since one assumes that structural zeros are omitted, the jac_nnz
really is "number of elements in the sparse representation", which is 9 in this case. If you want to use the minimal jac_nnz = 7
, you'll also have to change the sparse representation as above.
I was going through this example and I'm having difficulty in understanding what does
exp_mod.jac_nnz
exactly mean. In thesundials.pyx
module,jac_nnz
is kind of defined though this exception:which makes sense, as
nnz
has mean the number of non-zero elements in the parlance of ODE solvers. But then I don't understand why in the example it is set asexp_mod.jac_nnz = 9
. Because if one calculates, the 2-D jacobian of that system, you will find that it only has at most 7 non-zero elements. So, I'm not sure how this 9 was calculated.I'm sorry if this is really a trivial question and I have made a very doltish mistake.