52 : m_variables{std::
move(variables)}, m_wrt{std::
move(
wrt)} {
53 slp_assert(m_variables.cols() == 1);
54 slp_assert(m_wrt.cols() == 1);
57 m_top_lists.emplace_back(detail::topological_sort(
variable.expr));
61 for (
size_t col = 0; col < m_wrt.size(); ++col) {
62 m_wrt[col].expr->scratch = col;
67 m_output_lists.emplace_back();
69 if (
node->scratch != -1) {
70 m_output_lists.back().emplace_back(
node->scratch,
node);
76 for (
auto&
node : m_wrt) {
77 node.expr->scratch = -1;
80 for (
int row = 0; row < m_variables.rows(); ++row) {
81 if (m_variables[row].expr ==
nullptr) {
85 if (m_variables[row].type() == ExpressionType::LINEAR) {
89 detail::append_triplets(m_top_lists[row], m_output_lists[row],
90 m_cached_triplets, row);
91 }
else if (m_variables[row].type() > ExpressionType::LINEAR) {
94 m_nonlinear_rows.emplace_back(row);
98 if (m_nonlinear_rows.empty()) {
99 m_J.setFromTriplets(m_cached_triplets.begin(), m_cached_triplets.end());