[FR] make nbColsAtOnce a template parameter
Describe the feature you would like to be implemented.
The function solve_sparse_through_dense_panels()
in SparseCore/SparseSolverBase.h
(starting at line 21) has an integer variable nbColsAtOnce
defined as a static const with value 4. This variable controls the maximum amount of columns in an RHS sparse matrix that is to be transformed at a time into a dense panel for the solution of an already factorized linear system. I'd like this variable to have its value determined by a template parameter.
Would such a feature be useful for other users? Why?
The cost of copying entries of the RHS sparse matrix to a dense panel is high and proportional to the number of dense panels that need to be generated. Increasing the value of nbColsAtOnce
considerably reduces the cost of such copies. However, it also increases the amount of memory to be allocated per panel, because of the zero-valued entries. Allowing such value to be parameterized would empower Eigen users with the choice of adequate values for their specific problems.
Any hints on how to implement the requested feature?
A declaration such as:
template<typename Decomposition, typename Rhs, typename Dest, int ColsAtOnce>
typename enable_if<Rhs::ColsAtCompileTime!=1 && Dest::ColsAtCompileTime!=1>::type
solve_sparse_through_dense_panels(const Decomposition &dec, const Rhs& rhs, Dest &dest)
would do, but the introduction of the template parameter ColsAtOnce
may propagate to all linear solvers that accept sparse matrices at the RHS. A default template parameter of value 4 may be adopted to keep the behavior unchanged for the classical use of these classes.