Misuse of `M_chm_sparse_to_SEXP` by `tmb_invQ_tril_halfdiag`
jaganmn opened this issue · comments
Forthcoming improvements to subscript methods in Matrix have uncovered that you are misusing M_chm_sparse_to_SEXP
in tmb_invQ_tril_halfdiag
:
Line 318 in bb2e143
Here, the fifth argument is used to set the diag
slot of the resulting dtCMatrix
and so must be "N"
(non-unit triangular) or "U"
(unit triangular) but never ""
. Please correct, then test your patch against Matrix-devel:
$ svn checkout svn://svn.r-forge.r-project.org/svnroot/matrix/pkg/Matrix
$ R CMD build Matrix
$ R CMD INSTALL Matrix_1.5-5.tar.gz
Trouble with the invalid ihessian
(having diag = ""
) seems to start inside of this lookup
call and result in a gradient with NA
in the "simple" example (and for several packages depending on TMB):
Line 767 in bb2e143
BTW, going forward the subscript method for CsparseMatrix
will not construct an intermediate dgCMatrix
for <dsCMatrix>[i, i]
when i
is strictly increasing or strictly decreasing. So lookup
can in principle be made faster if you know that r
is monotone.
Somehow, I didn't notice that the bug appears twice, i.e., also here:
Line 297 in 5de4200