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