forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
evaluator_base.cc
38 lines (33 loc) · 1.11 KB
/
evaluator_base.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "drake/solvers/evaluator_base.h"
using std::make_shared;
using std::shared_ptr;
using Eigen::MatrixXd;
using Eigen::VectorXd;
namespace drake {
namespace solvers {
void PolynomialEvaluator::DoEval(const Eigen::Ref<const Eigen::VectorXd>& x,
Eigen::VectorXd* y) const {
double_evaluation_point_temp_.clear();
for (size_t i = 0; i < poly_vars_.size(); i++) {
double_evaluation_point_temp_[poly_vars_[i]] = x[i];
}
y->resize(num_outputs());
for (int i = 0; i < num_outputs(); i++) {
(*y)[i] =
polynomials_[i].EvaluateMultivariate(double_evaluation_point_temp_);
}
}
void PolynomialEvaluator::DoEval(const Eigen::Ref<const AutoDiffVecXd>& x,
AutoDiffVecXd* y) const {
taylor_evaluation_point_temp_.clear();
for (size_t i = 0; i < poly_vars_.size(); i++) {
taylor_evaluation_point_temp_[poly_vars_[i]] = x[i];
}
y->resize(num_outputs());
for (int i = 0; i < num_outputs(); i++) {
(*y)[i] =
polynomials_[i].EvaluateMultivariate(taylor_evaluation_point_temp_);
}
}
} // namespace solvers
} // namespace drake