35 #ifndef UTILITIES_NEKMESH_NODEOPTI_HESSIAN 36 #define UTILITIES_NEKMESH_NODEOPTI_HESSIAN 55 template <>
int NodeOpti::IsIndefinite<2>()
57 vector<NekDouble> eigR(2);
58 vector<NekDouble> eigI(2);
68 char jobvl =
'N', jobvr =
'N';
69 int worklen = 8 * nVel, info;
73 vector<NekDouble> vl(nVel * nVel);
74 vector<NekDouble> work(worklen);
75 vector<NekDouble> wi(nVel);
77 Lapack::Dgeev(jobvl, jobvr, nVel, H.GetRawPtr(), nVel, &(eval.GetPtr())[0],
78 &wi[0], &vl[0], nVel, &dum, nVel, &work[0], worklen, info);
82 if (eval(0, 0) < 0.0 || eval(1, 1) < 0.0)
84 if (eval(0, 0) < 0.0 && eval(1, 1) < 0.0)
97 template <>
int NodeOpti::IsIndefinite<3>()
99 vector<NekDouble> eigR(3);
100 vector<NekDouble> eigI(3);
113 char jobvl =
'N', jobvr =
'N';
114 int worklen = 8 * nVel, info;
118 vector<NekDouble> vl(nVel * nVel);
119 vector<NekDouble> work(worklen);
120 vector<NekDouble> wi(nVel);
122 Lapack::Dgeev(jobvl, jobvr, nVel, H.GetRawPtr(), nVel, &(eval.GetPtr())[0],
123 &wi[0], &vl[0], nVel, &dum, nVel, &work[0], worklen, info);
127 if (eval(0, 0) < 0.0 || eval(1, 1) < 0.0 || eval(2, 2) < 0.0)
129 if (eval(0, 0) < 0.0 && eval(1, 1) < 0.0 && eval(2, 2))
149 boost::ignore_unused(val);
161 NekDouble D = (H[0][0] - H[1][1]) * (H[0][0] - H[1][1]) + 4.0 * H[1][0] * H[1][0];
165 val = (H[0][0] + H[1][1] - Dsqrt ) / 2.0;
183 NekDouble p1 = H[0][1] * H[0][1] + H[0][2] * H[0][2] + H[1][2] * H[1][2];
187 if(H[0][0] < H[1][1])
189 if(H[0][0] < H[2][2])
200 if(H[1][1] < H[2][2])
212 NekDouble q = (H[0][0] + H[1][1] + H[2][2]) / 3.0;
213 NekDouble p2 = (H[0][0] - q)*(H[0][0] - q)
214 + (H[1][1] - q)*(H[1][1] - q)
215 + (H[2][2] - q)*(H[2][2] - q)
221 B[0][0] = pinv * (H[0][0] - q);
222 B[1][1] = pinv * (H[1][1] - q);
223 B[2][2] = pinv * (H[2][2] - q);
224 B[0][1] = pinv * H[0][1];
226 B[0][2] = pinv * H[0][2];
228 B[1][2] = pinv * H[1][2];
251 val = q + 2.0 * p * cos(phi + (2.0*M_PI/3.0));
#define ASSERTL0(condition, msg)
int IsIndefinite()
Returns 1 if Hessian matrix is indefinite and 0 otherwise.
void MinEigen(NekDouble &val)
Calculates minimum eigenvalue of Hessian matrix.
static void Dgeev(const char &uplo, const char &lrev, const int &n, const double *a, const int &lda, double *wr, double *wi, double *rev, const int &ldr, double *lev, const int &ldv, double *work, const int &lwork, int &info)
Solve general real matrix eigenproblem.
NekDouble Determinant< 3 >(NekDouble jac[][3])
std::vector< NekDouble > m_grad