You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am creating an R package in which the core computation is to minimize a scalar loss function whose evaluation requires a lot of sparse matrix operations, including the solution of sparse linear systems. I'm using autodiff to compute the gradient and potentially the Hessian, both of which are dense.
Made this work by adding this to the top of autodiff/common/eigen.hpp:
template<typename Scalar, int Options, typename StorageIndex>
structVectorTraits<Eigen::SparseMatrix<Scalar, Options, StorageIndex>>
{
using ValueType = Scalar;
template<typename NewValueType>
using ReplaceValueType = Eigen::SparseMatrix<NewValueType, Options, StorageIndex>;
};
I can then define sparse matrices with dual values with something like this:
using llt = Eigen::SimplicialLLT<Eigen::SparseMatrix<dual2nd> >;
using dspmat = Eigen::SparseMatrix<dual2nd>;
using ddiag = Eigen::DiagonalMatrix<dual2nd, Eigen::Dynamic>;
Would it be of interest to include something like this in autodiff itself? I realize things might be harder if the results of differentation are also supposed to be sparse, but when these are dense, it seems quite straightforward.
The text was updated successfully, but these errors were encountered:
I am creating an R package in which the core computation is to minimize a scalar loss function whose evaluation requires a lot of sparse matrix operations, including the solution of sparse linear systems. I'm using autodiff to compute the gradient and potentially the Hessian, both of which are dense.
Made this work by adding this to the top of
autodiff/common/eigen.hpp
:and then this
I can then define sparse matrices with dual values with something like this:
Would it be of interest to include something like this in autodiff itself? I realize things might be harder if the results of differentation are also supposed to be sparse, but when these are dense, it seems quite straightforward.
The text was updated successfully, but these errors were encountered: