Loading [MathJax]/extensions/tex2jax.js
PolyFEM
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
QuadraticPenaltyForm.cpp
Go to the documentation of this file.
2
4
5namespace polyfem::solver
6{
7
9 const Eigen::MatrixXd &b,
10 const double weight)
11 : penalty_weight_(weight), A_(A), b_(b)
12 {
13 assert(A.rows() == b.rows());
14
15 AtA_ = A_.transpose() * A_;
16 Atb_ = A_.transpose() * b_;
17 }
18
19 double QuadraticPenaltyForm::value_unweighted(const Eigen::VectorXd &x) const
20 {
21 const Eigen::VectorXd val = A_ * x - b_;
22 return val.squaredNorm() / 2;
23 }
24
25 void QuadraticPenaltyForm::first_derivative_unweighted(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const
26 {
27 gradv = (AtA_ * x - Atb_);
28 }
29
30 void QuadraticPenaltyForm::second_derivative_unweighted(const Eigen::VectorXd &x, StiffnessMatrix &hessian) const
31 {
32 hessian = AtA_;
33 }
34} // namespace polyfem::solver
double val
Definition Assembler.cpp:86
int x
void first_derivative_unweighted(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
Compute the first derivative of the value wrt x.
void second_derivative_unweighted(const Eigen::VectorXd &x, StiffnessMatrix &hessian) const override
Compute the second derivative of the value wrt x.
Eigen::MatrixXd b_
Constraints value.
double value_unweighted(const Eigen::VectorXd &x) const override
Compute the value of the form.
StiffnessMatrix A_
Constraints matrix.
QuadraticPenaltyForm(const StiffnessMatrix &A, const Eigen::MatrixXd &b, const double weight)
Construct a new QuadraticPenaltyForm object for the constraints Ax = b.
Eigen::SparseMatrix< double, Eigen::ColMajor > StiffnessMatrix
Definition Types.hpp:22