50 : m_variables{detail::gradient_tree(
53 slp_assert(m_wrt.cols() == 1);
56 m_top_lists.emplace_back(detail::topological_sort(
variable.expr));
60 for (
size_t col = 0; col < m_wrt.size(); ++col) {
61 m_wrt[col].expr->scratch = col;
66 m_output_lists.emplace_back();
68 if (
node->scratch != -1) {
69 m_output_lists.back().emplace_back(
node->scratch,
node);
75 for (
auto&
node : m_wrt) {
76 node.expr->scratch = -1;
79 for (
int row = 0; row < m_variables.rows(); ++row) {
80 if (m_variables[row].expr ==
nullptr) {
84 if (m_variables[row].type() == ExpressionType::LINEAR) {
88 detail::append_triplets(m_top_lists[row], m_output_lists[row],
89 m_cached_triplets, row);
90 }
else if (m_variables[row].type() > ExpressionType::LINEAR) {
93 m_nonlinear_rows.emplace_back(row);
97 if (m_nonlinear_rows.empty()) {
98 m_H.setFromTriplets(m_cached_triplets.begin(), m_cached_triplets.end());
99 if constexpr (
UpLo == Eigen::Lower) {