8template <
class DataPo
int,
class _WFunctor,
int DiffType,
typename T>
14 m_d2Uc = Matrix::Zero(),
15 m_d2Uq = Matrix::Zero();
16 m_d2Ul = MatrixArray::Zero();
18 m_d2SumDotPN = Matrix::Zero();
19 m_d2SumDotPP = Matrix::Zero();
20 m_d2SumW = Matrix::Zero();
22 m_d2SumP = MatrixArray::Zero();
23 m_d2SumN = MatrixArray::Zero();
26template <
class DataPo
int,
class _WFunctor,
int DiffType,
typename T>
30 const DataPoint &attributes,
33 if( Base::addLocalNeighbor(w, localQ, attributes, dw) ) {
35 Matrix d2w = Matrix::Zero();
37 if (Base::isScaleDer())
38 d2w(0,0) = Base::m_w.scaled2w(attributes.pos(), attributes);
40 if (Base::isSpaceDer())
41 d2w.template bottomRightCorner<Dim,Dim>() = Base::m_w.spaced2w(attributes.pos(), attributes);
43 if (Base::isScaleDer() && Base::isSpaceDer())
45 d2w.template bottomLeftCorner<Dim,1>() = Base::m_w.scaleSpaced2w(attributes.pos(),attributes);
46 d2w.template topRightCorner<1,Dim>() = d2w.template bottomLeftCorner<Dim,1>().transpose();
49 m_d2SumDotPN += d2w * attributes.normal().dot(localQ);
50 m_d2SumDotPP += d2w * localQ.squaredNorm();
53 for(
int i=0; i<Dim; ++i)
55 m_d2SumP.template block<DerDim,DerDim>(0,i*DerDim) += d2w * localQ[i];
56 m_d2SumN.template block<DerDim,DerDim>(0,i*DerDim) += d2w * attributes.normal()[i];
64template <
class DataPo
int,
class _WFunctor,
int DiffType,
typename T>
72 Matrix sumdSumPdSumN = Matrix::Zero();
73 Matrix sumd2SumPdSumN = Matrix::Zero();
74 Matrix sumd2SumNdSumP = Matrix::Zero();
75 Matrix sumdSumPdSumP = Matrix::Zero();
76 Matrix sumd2SumPdSumP = Matrix::Zero();
78 for(
int i=0; i<Dim; ++i)
80 sumdSumPdSumN += Base::m_dSumN.row(i).transpose()*Base::m_dSumP.row(i);
81 sumd2SumPdSumN += m_d2SumP.template block<DerDim,DerDim>(0,i*DerDim)*Base::m_sumN(i);
82 sumd2SumNdSumP += m_d2SumN.template block<DerDim,DerDim>(0,i*DerDim)*Base::m_sumP(i);
83 sumdSumPdSumP += Base::m_dSumP.row(i).transpose()*Base::m_dSumP.row(i);
84 sumd2SumPdSumP += m_d2SumP.template block<DerDim,DerDim>(0,i*DerDim)*Base::m_sumP(i);
89 Matrix d2Nume = m_d2SumDotPN
90 - invSumW*invSumW*invSumW*invSumW*(
91 Base::getWeightSum()*Base::getWeightSum()*( Base::getWeightSum()*(sumdSumPdSumN+sumdSumPdSumN.transpose()+sumd2SumPdSumN+sumd2SumNdSumP)
92 + Base::m_dSumW.transpose()*(Base::m_sumN.transpose()*Base::m_dSumP + Base::m_sumP.transpose()*Base::m_dSumN)
93 - (Base::m_sumP.transpose()*Base::m_sumN)*m_d2SumW.transpose()
94 - (Base::m_dSumN.transpose()*Base::m_sumP + Base::m_dSumP.transpose()*Base::m_sumN)*Base::m_dSumW)
95 -
Scalar(2.)*Base::getWeightSum()*Base::m_dSumW.transpose()*(Base::getWeightSum()*(Base::m_sumN.transpose()*Base::m_dSumP + Base::m_sumP.transpose()*Base::m_dSumN)
96 - (Base::m_sumP.transpose()*Base::m_sumN)*Base::m_dSumW));
98 Matrix d2Deno = m_d2SumDotPP
99 - invSumW*invSumW*invSumW*invSumW*(
100 Base::getWeightSum()*Base::getWeightSum()*(
Scalar(2.)*Base::getWeightSum()*(sumdSumPdSumP+sumd2SumPdSumP)
101 +
Scalar(2.)*Base::m_dSumW.transpose()*(Base::m_sumP.transpose()*Base::m_dSumP)
102 - (Base::m_sumP.transpose()*Base::m_sumP)*m_d2SumW.transpose()
103 -
Scalar(2.)*(Base::m_dSumP.transpose()*Base::m_sumP)*Base::m_dSumW)
104 -
Scalar(2.)*Base::getWeightSum()*Base::m_dSumW.transpose()*(
Scalar(2.)*Base::getWeightSum()*Base::m_sumP.transpose()*Base::m_dSumP
105 - (Base::m_sumP.transpose()*Base::m_sumP)*Base::m_dSumW));
107 Scalar deno2 = Base::m_deno*Base::m_deno;
109 m_d2Uq =
Scalar(.5)/(deno2*deno2)*(deno2*( Base::m_dDeno.transpose()*Base::m_dNume
110 + Base::m_deno*d2Nume
111 - Base::m_dNume.transpose()*Base::m_dDeno
112 - Base::m_nume*d2Deno)
113 -
Scalar(2.)*Base::m_deno*Base::m_dDeno.transpose()*(Base::m_deno*Base::m_dNume - Base::m_nume*Base::m_dDeno));
115 for(
int i=0; i<Dim; ++i)
117 m_d2Ul.template block<DerDim,DerDim>(0,i*DerDim) = invSumW*(
118 m_d2SumN.template block<DerDim,DerDim>(0,i*DerDim)
119 -
Scalar(2.)*( m_d2Uq*Base::m_sumP[i]
120 + Base::m_dSumP.row(i).transpose()*Base::m_dUq
121 + Base::m_uq*m_d2SumP.template block<DerDim,DerDim>(0,i*DerDim)
122 + Base::m_dUq.transpose()*Base::m_dSumP.row(i))
123 - Base::m_ul[i]*m_d2SumW
124 - Base::m_dUl.row(i).transpose()*Base::m_dSumW
125 - Base::m_dSumW.transpose()*Base::m_dUl.row(i));
128 Matrix sumdUldSumP = Matrix::Zero();
129 Matrix sumUld2SumP = Matrix::Zero();
130 Matrix sumd2UlsumP = Matrix::Zero();
131 Matrix sumdSumPdUl = Matrix::Zero();
133 for(
int i=0; i<Dim; ++i)
135 sumdUldSumP += Base::m_dUl.row(i).transpose()*Base::m_dSumP.row(i);
136 sumUld2SumP += Base::m_ul[i]*m_d2SumP.template block<DerDim,DerDim>(0,i*DerDim);
137 sumd2UlsumP += m_d2Ul.template block<DerDim,DerDim>(0,i*DerDim)*Base::m_sumP[i];
138 sumdSumPdUl += Base::m_dSumP.row(i).transpose()*Base::m_dUl.row(i);
146 + Base::m_dUq.transpose()*Base::m_dSumDotPP
147 + Base::m_uq*m_d2SumDotPP
148 + Base::m_dSumDotPP.transpose()*Base::m_dUq
149 + m_d2Uq*Base::m_sumDotPP
150 + Base::m_uc*m_d2SumW
151 + Base::m_dUc.transpose()*Base::m_dSumW
152 + Base::m_dSumW.transpose()*Base::m_dUc);
155 return Base::m_eCurrentState;
158template <
class DataPo
int,
class _WFunctor,
int DiffType,
typename T>
168 if(Base::isSpaceDer())
169 result.template tail<Dim>() += Base::m_ul;
174template <
class DataPo
int,
class _WFunctor,
int DiffType,
typename T>
179 VectorType grad = Base::m_dUc.template tail<Dim>().transpose() + Base::m_ul;
180 return grad.normalized();
183template <
class DataPo
int,
class _WFunctor,
int DiffType,
typename T>
196 VectorType grad = Base::m_dUc.template tail<Dim>().transpose() + Base::m_ul;
197 Scalar gradNorm = grad.norm();
199 if(Base::isScaleDer())
200 result.col(0) = m_d2Uc.template topRightCorner<1,Dim>().transpose() + Base::m_dUl.col(0);
202 if(Base::isSpaceDer())
204 result.template rightCols<Dim>() = m_d2Uc.template bottomRightCorner<Dim,Dim>().transpose()
205 + Base::m_dUl.template rightCols<Dim>().transpose()
206 + Base::m_dUl.template rightCols<Dim>();
207 result.template rightCols<Dim>().diagonal().array() +=
Scalar(2.)*Base::m_uq;
210 return result/gradNorm - grad*grad.transpose()/(gradNorm*gradNorm)*result;
Extension performing derivation of the mls surface.
Eigen::Matrix< Scalar, DerDim, DerDim > Matrix
Static squared matrix of scalars with a size adapted to the differentiation type.
typename Base::VectorType VectorType
Alias to vector type.
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
typename Base::ScalarArray ScalarArray
Alias to scalar derivatives array.
typename DataPoint::Scalar Scalar
Alias to scalar type.
FIT_RESULT
Enum corresponding to the state of a fitting method (and what the finalize function returns)