本文整理汇总了C++中MIP::CalcHesse方法的典型用法代码示例。如果您正苦于以下问题:C++ MIP::CalcHesse方法的具体用法?C++ MIP::CalcHesse怎么用?C++ MIP::CalcHesse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MIP
的用法示例。
在下文中一共展示了MIP::CalcHesse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateMatrix
static void GenerateMatrix (const AFEL & bfel, const MIP & sip,
MAT & mat, LocalHeap & lh)
{
const HDivDivFiniteElement<2> & fel =
dynamic_cast<const HDivDivFiniteElement<2>&> (bfel);
int nd = fel.GetNDof();
FlatMatrix<> div_shape(nd, 2, lh);
fel.CalcDivShape (sip.IP(), div_shape);
FlatMatrix<> shape(nd, 3, lh);
fel.CalcShape (sip.IP(), shape);
Mat<3,2> jac = sip.GetJacobian();
double det = fabs (sip.GetJacobiDet());
Mat<3,2> sjac = (1.0/(det*det)) * jac;
mat = (sjac) * Trans (div_shape);
//for non-curved elements, divergence transformation is finished, otherwise derivatives of Jacobian have to be computed...
if (!sip.GetTransformation().IsCurvedElement()) return;
Mat<2,2> hesse[3];
sip.CalcHesse (hesse[0], hesse[1], hesse[2]);
Mat<3,2,AutoDiff<2> > fad;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 2; j++)
{
fad(i,j).Value() = jac(i,j);
for (int k = 0; k < 2; k++)
fad(i,j).DValue(k) = hesse[i](j,k);
}
}
Vec<3, AutoDiff<2>> n = Cross(Vec<3,AutoDiff<2>>(fad.Col(0)),Vec<3,AutoDiff<2>>(fad.Col(1)));
AutoDiff<2> iad_det = 1.0/sqrt(n(0)*n(0)+n(1)*n(1)+n(2)*n(2));
fad *= iad_det;
Vec<3> hv2;
Mat<2> sigma_ref;
for (int i = 0; i < nd; i++)
{
sigma_ref(0,0) = shape(i, 0);
sigma_ref(1,1) = shape(i, 1);
sigma_ref(0,1) = sigma_ref(1,0) = shape(i, 2);
hv2 = 0.0;
for (int j = 0; j < 2; j++)
for (int k = 0; k < 3; k++)
for (int l = 0; l < 2; l++)
hv2(k) += fad(k,l).DValue(j) * sigma_ref(l,j);
hv2 *= iad_det.Value();
/*
//Mat<D> inv_jac = sip.GetJacobianInverse();
// this term is zero !!!
Vec<3> hv2b = 0.0;
for ( int j = 0; j < 2; j++ )
for ( int k = 0; k < 3; k++ )
for ( int l = 0; l < 2; l++ )
for ( int m = 0; m < 2; m++ )
for ( int n = 0; n < 3; n++ )
hv2b(n) += inv_jac(m,k) *fad(n,j).Value() * sigma_ref(j,l) * fad(k,l).DValue(m);
*/
for ( int j = 0; j < 3; j++)
mat(j,i) += hv2(j);
}
}