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.
PS! I originally created this as issue #237, but realize it probably belongs in Discussions.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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.
PS! I originally created this as issue #237, but realize it probably belongs in Discussions.
Beta Was this translation helpful? Give feedback.
All reactions