44 #ifndef GLOBIPACK_TEST_LAGR_POLY_MERIT_FUNC_1D_DEF_HPP
45 #define GLOBIPACK_TEST_LAGR_POLY_MERIT_FUNC_1D_DEF_HPP
56 template<
typename Scalar>
61 : alpha_(alpha), phi_(phi)
70 template<
typename Scalar>
77 template<
typename Scalar>
86 const int n = alpha_.size();
88 Scalar phi = ST::zero();
89 Scalar Dphi = ST::zero();
91 for (
int k = 0; k < n; ++k) {
95 Scalar Lp_k = ST::one();
96 for (
int i = 0; i < n; ++i) {
98 Lp_k *= (alpha-alpha_[i])/(alpha_[k]-alpha_[i]);
102 phi += phi_[k] * Lp_k;
108 Scalar DLp_k = ST::zero();
109 for (
int j = 0; j < n; ++j) {
111 Scalar DLp_k_j_prod = ST::one();
112 for (
int i = 0; i < n; ++i) {
114 DLp_k_j_prod *= (alpha-alpha_[i])/(alpha_[k]-alpha_[i]);
117 DLp_k += DLp_k_j_prod / (alpha_[k]-alpha_[j]);
121 Dphi += phi_[k] * DLp_k;
141 #endif // GLOBIPACK_TEST_LAGR_POLY_MERIT_FUNC_1D_DEF_HPP
bool is_null(const boost::shared_ptr< T > &p)
TestLagrPolyMeritFunc1D(const ArrayView< const Scalar > &alpha, const ArrayView< const Scalar > &phi)
Constructor.
virtual void eval(const Scalar &alpha, const Ptr< Scalar > &phi, const Ptr< Scalar > &Dphi) const
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
virtual bool supportsDerivEvals() const