48 const std::vector<double>& derivative_costs,
double ridge_factor)
51 int num_vars_free = num_vars_all - 2 * (DIFF_RULE_LENGTH - 1);
52 MatrixXd diff_matrix = MatrixXd::Zero(num_vars_all, num_vars_all);
53 quad_cost_full_ = MatrixXd::Zero(num_vars_all, num_vars_all);
56 double multiplier = 1.0;
57 for (
unsigned int i = 0; i < derivative_costs.size(); ++i)
60 diff_matrix = getDiffMatrix(num_vars_all, &DIFF_RULES[i][0]);
61 quad_cost_full_ += (derivative_costs[i] * multiplier) * (diff_matrix.transpose() * diff_matrix);
63 quad_cost_full_ += MatrixXd::Identity(num_vars_all, num_vars_all) * ridge_factor;
66 quad_cost_ = quad_cost_full_.block(DIFF_RULE_LENGTH - 1, DIFF_RULE_LENGTH - 1, num_vars_free, num_vars_free);
69 quad_cost_inv_ = quad_cost_.inverse();