PolyFEM
Loading...
Searching...
No Matches
ParametrizedProductForm.hpp
Go to the documentation of this file.
1#pragma once
2
5
6namespace polyfem::solver
7{
8 // computes the product of a parametrized vector
10 {
11 public:
12 ParametrizedProductForm(CompositeParametrization &&parametrizations) : ParametrizationForm(std::move(parametrizations))
13 {
14 }
15
16 protected:
17 inline double value_unweighted_with_param(const Eigen::VectorXd &x) const override
18 {
19 return x.prod();
20 }
21
22 inline void compute_partial_gradient_with_param(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
23 {
24 gradv.setOnes(x.size());
25 for (int i = 0; i < x.size(); i++)
26 {
27 for (int j = 0; j < x.size(); j++)
28 {
29 if (j != i)
30 gradv(i) *= x(j);
31 }
32 }
33 gradv *= weight();
34 }
35 };
36} // namespace polyfem::solver
int x
virtual double weight() const
Get the form's multiplicative constant weight.
Definition Form.hpp:126
void compute_partial_gradient_with_param(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
double value_unweighted_with_param(const Eigen::VectorXd &x) const override
ParametrizedProductForm(CompositeParametrization &&parametrizations)