75 const T& lossC = T(1));
86 const T& lossC = T(1))
89 character.parameterTransform,
144 int& usedRows)
final;
219 std::array<VType, NumVec>& v,
220 std::array<DfdvType, NumVec>& dfdv)
const = 0;
Implementation of "A General and Adaptive Robust Loss Function" (https://arxiv.org/abs/1701....
static constexpr T kL2
Special-case alpha values that are either at a singularity in the general formula or simplify to a cl...
Vector< T, FuncDim > FuncType
virtual void evalFunction(size_t constrIndex, const JointStateT< T > &state, FuncType &f, std::array< VType, NumVec > &v, std::array< DfdvType, NumVec > &dfdv) const =0
Evaluate the constraint residual and derivatives for a single constraint.
JointErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt, const T &lossAlpha=GeneralizedLossT< T >::kL2, const T &lossC=T(1))
Constructor.
size_t getJacobianSize() const final
The number of rows in the jacobian is the dimension of f, FuncDim, times the number of constraints.
static constexpr size_t kNumPos
static constexpr size_t kNumVec
double getGradient(const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Ref< VectorX< T > > gradient) final
The gradient of the error function: dl/dq = dl/d[f^2] * 2f * df/dv * dv/dq.
std::vector< Data > constraints_
List of constraints.
void addConstraints(std::span< const Data > constrs)
Appends a list of constraints.
Eigen::Matrix< T, FuncDim, 3 > DfdvType
const GeneralizedLossT< T > loss_
The generalized loss function that transforms f^2.
const std::vector< Data > & getConstraints() const
Data & getConstraint(size_t index)
Mutable access to a constraint by index, for in-place updates.
size_t getNumConstraints() const
static constexpr size_t kFuncDim
JointErrorFunctionT(const Character &character, const T &lossAlpha=GeneralizedLossT< T >::kL2, const T &lossC=T(1))
A convenience constructor where character contains info of the skeleton and parameter transform.
double getError(const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState) final
Computes the error function value l = w * loss(f^2).
void addConstraint(const Data &constr)
Adds a constraint to the list.
void clearConstraints()
Clear the current list of constraints.
VectorX< T > jointGrad_
Intermediate storage of the gradient from this error function.
double getJacobian(const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Ref< MatrixX< T > > jacobian, Ref< VectorX< T > > residual, int &usedRows) final
For least-square problems, we assume l is the square of a vector function F.
void setConstraints(std::span< const Data > constrs)
Replace the current list of constraints with the input.
SkeletonErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt)
Shared types used across error function hierarchies.
SkeletonT< float > Skeleton
ParameterTransformT< float > ParameterTransform
Eigen::Matrix< T, Dynamic, Dynamic > MatrixX
Dynamic-size, column-major dense matrix.
Vector< T, Dynamic > VectorX
Dynamic-size column vector. Common return type for solver residuals and parameter vectors.
Eigen::Matrix< T, Dim, 1, Options > Vector
Column vector alias (an Nx1 Eigen matrix).
A character model with skeletal structure, mesh, and optional components.
Represents the state of a joint with local and global transformations.
Represents the complete state of a model's mesh.
A vector of size numModelParams holding the values of all model parameters for a character.
Represents the complete state of a skeleton.