56 : m_variables{std::
move(variables)}, m_wrt{std::
move(
wrt)} {
57 slp_assert(m_variables.cols() == 1);
58 slp_assert(m_wrt.cols() == 1);
61 m_top_lists.emplace_back(detail::topological_sort(
variable.expr));
65 for (
size_t col = 0; col < m_wrt.size(); ++col) {
66 m_wrt[col].expr->scratch = col;
71 m_output_lists.emplace_back();
73 if (
node->scratch != -1) {
74 m_output_lists.back().emplace_back(
node->scratch,
node);
80 for (
auto&
node : m_wrt) {
81 node.expr->scratch = -1;
84 for (
int row = 0; row < m_variables.rows(); ++row) {
85 if (m_variables[row].expr ==
nullptr) {
89 if (m_variables[row].type() == ExpressionType::LINEAR) {
93 detail::append_triplets(m_top_lists[row], m_output_lists[row],
94 m_cached_triplets, row);
95 }
else if (m_variables[row].type() > ExpressionType::LINEAR) {
98 m_nonlinear_rows.emplace_back(row);
102 if (m_nonlinear_rows.empty()) {
103 m_J.setFromTriplets(m_cached_triplets.begin(), m_cached_triplets.end());