98 Eigen::Ref<Eigen::VectorXd> AOvalues,
102 const Eigen::Vector3d center = (grid_pos -
pos_);
103 const double distsq = center.squaredNorm();
108 const double alpha = gaussian.getDecay();
109 const double contraction = gaussian.getContraction();
111 const double expofactor =
112 gaussian.getPowfactor() * std::exp(-alpha * distsq);
113 const Eigen::Vector3d second_term = -2.0 * alpha * center;
117 double AOvalue = contraction * expofactor;
118 AOvalues(0) += AOvalue;
119 gradAOvalues.row(0) += second_term * AOvalue;
122 const double factor = 2. * sqrt(alpha) * contraction * expofactor;
124 double AOvalue = factor * center.y();
125 AOvalues(0) += AOvalue;
126 gradAOvalues.row(0) += second_term * AOvalue;
127 gradAOvalues(0, 1) += factor;
129 AOvalue = factor * center.z();
130 AOvalues(1) += AOvalue;
131 gradAOvalues.row(1) += second_term * AOvalue;
132 gradAOvalues(1, 2) += factor;
134 AOvalue = factor * center.x();
135 AOvalues(2) += AOvalue;
136 gradAOvalues(2, 0) += factor;
137 gradAOvalues.row(2) += second_term * AOvalue;
140 const double factor = 2. * alpha * contraction * expofactor;
141 const double factor_1 = factor / sqrt(3.);
143 double AOvalue = 2. * factor * (center.x() * center.y());
144 AOvalues(0) += AOvalue;
145 Eigen::Array3d coeff = {2 * center.y(), 2 * center.x(), 0};
146 gradAOvalues.row(0) += factor * coeff.matrix() + second_term * AOvalue;
148 AOvalue = 2. * factor * (center.y() * center.z());
149 AOvalues(1) += AOvalue;
150 coeff = {0, 2 * center.z(), 2 * center.y()};
151 gradAOvalues.row(1) += factor * coeff.matrix() + second_term * AOvalue;
153 AOvalue = factor_1 * (3. * center.z() * center.z() - distsq);
154 AOvalues(2) += AOvalue;
156 gradAOvalues.row(2) += (factor_1 * coeff * center.array()).matrix() +
157 second_term * AOvalue;
159 AOvalue = 2. * factor * (center.x() * center.z());
160 AOvalues(3) += AOvalue;
161 coeff = {2 * center.z(), 0, 2 * center.x()};
162 gradAOvalues.row(3) += factor * coeff.matrix() + second_term * AOvalue;
165 (center.x() * center.x() - center.y() * center.y());
166 AOvalues(4) += AOvalue;
167 coeff = {2 * center.x(), -2 * center.y(), 0};
168 gradAOvalues.row(4) += factor * coeff.matrix() + second_term * AOvalue;
171 const double factor = 2. * pow(alpha, 1.5) * contraction * expofactor;
172 const double factor_1 = factor * 2. / sqrt(15.);
173 const double factor_2 = factor * sqrt(2.) / sqrt(5.);
174 const double factor_3 = factor * sqrt(2.) / sqrt(3.);
178 factor_3 * center.y() * (3. * c.
xx() - c.
yy());
179 AOvalues(0) += AOvalue;
180 Eigen::Array3d coeff = {6. * c.
xy(), 3. * (c.
xx() - c.
yy()), 0};
181 gradAOvalues.row(0) +=
182 factor_3 * coeff.matrix() + second_term * AOvalue;
184 AOvalue = 4. * factor * center.x() * center.y() * center.z();
185 AOvalues(1) += AOvalue;
186 coeff = {c.
yz(), c.
xz(), c.
xy()};
187 gradAOvalues.row(1) +=
188 4 * factor * coeff.matrix() + second_term * AOvalue;
190 AOvalue = factor_2 * center.y() * (5. * c.
zz() - distsq);
191 AOvalues(2) += AOvalue;
192 coeff = {-2. * c.
xy(), 4. * c.
zz() - c.
xx() - 3. * c.
yy(), 8. * c.
yz()};
193 gradAOvalues.row(2) +=
194 factor_2 * coeff.matrix() + second_term * AOvalue;
196 AOvalue = factor_1 * center.z() * (5. * c.
zz() - 3. * distsq);
197 AOvalues(3) += AOvalue;
198 coeff = {-6. * c.
xz(), -6. * c.
yz(), 3. * (3. * c.
zz() - distsq)};
199 gradAOvalues.row(3) +=
200 factor_1 * coeff.matrix() + second_term * AOvalue;
202 AOvalue = factor_2 * center.x() * (5. * c.
zz() - distsq);
203 AOvalues(4) += AOvalue;
204 coeff = {4. * c.
zz() - c.
yy() - 3. * c.
xx(), -2. * c.
xy(), 8. * c.
xz()};
205 gradAOvalues.row(4) +=
206 factor_2 * coeff.matrix() + second_term * AOvalue;
208 AOvalue = 2. * factor * center.z() * (c.
xx() - c.
yy());
209 AOvalues(5) += AOvalue;
210 coeff = {2. * c.
xz(), -2. * c.
yz(), c.
xx() - c.
yy()};
211 gradAOvalues.row(5) +=
212 2 * factor * coeff.matrix() + second_term * AOvalue;
214 AOvalue = factor_3 * center.x() * (c.
xx() - 3. * c.
yy());
215 AOvalues(6) += AOvalue;
216 coeff = {3. * (c.
xx() - c.
yy()), -6. * c.
xy(), 0};
217 gradAOvalues.row(6) +=
218 factor_3 * coeff.matrix() + second_term * AOvalue;
221 const double factor =
222 2. / sqrt(3.) * alpha * alpha * contraction * expofactor;
223 const double factor_1 = factor / sqrt(35.);
224 const double factor_2 = factor * 4. / sqrt(14.);
225 const double factor_3 = factor * 2. / sqrt(7.);
226 const double factor_4 = factor * 2. * sqrt(2.);
229 double AOvalue = 4. * factor * c.
xy() * (c.
xx() - c.
yy());
230 AOvalues(0) += AOvalue;
231 Eigen::Array3d coeff = {center.y() * (3. * c.
xx() - c.
yy()),
232 center.x() * (c.
xx() - 3. * c.
yy()), 0};
233 gradAOvalues.row(0) +=
234 4 * factor * coeff.matrix() + second_term * AOvalue;
236 AOvalue = factor_4 * c.
yz() * (3. * c.
xx() - c.
yy());
237 AOvalues(1) += AOvalue;
238 coeff = {6. * center.x() * c.
yz(), 3. * center.z() * (c.
xx() - c.
yy()),
239 center.y() * (3. * c.
xx() - c.
yy())};
240 gradAOvalues.row(1) +=
241 factor_4 * coeff.matrix() + second_term * AOvalue;
243 AOvalue = 2. * factor_3 * c.
xy() * (7. * c.
zz() - distsq);
244 AOvalues(2) += AOvalue;
245 coeff = {center.y() * (6. * c.
zz() - 3. * c.
xx() - c.
yy()),
246 center.x() * (6. * c.
zz() - c.
xx() - 3. * c.
yy()),
247 12. * center.z() * c.
xy()};
248 gradAOvalues.row(2) +=
249 2 * factor_3 * coeff.matrix() + second_term * AOvalue;
251 AOvalue = factor_2 * c.
yz() * (7. * c.
zz() - 3. * distsq);
252 AOvalues(3) += AOvalue;
253 coeff = {(-6. * center.x() * c.
yz()),
254 center.z() * (4. * c.
zz() - 3. * c.
xx() - 9. * c.
yy()),
255 3. * center.y() * (5. * c.
zz() - distsq)};
256 gradAOvalues.row(3) +=
257 factor_2 * coeff.matrix() + second_term * AOvalue;
259 AOvalue = factor_1 * (35. * c.
zz() * c.
zz() - 30. * c.
zz() * distsq +
260 3. * distsq * distsq);
261 AOvalues(4) += AOvalue;
262 coeff = {12. * center.x() * (distsq - 5. * c.
zz()),
263 12. * center.y() * (distsq - 5. * c.
zz()),
264 16. * center.z() * (5. * c.
zz() - 3. * distsq)};
266 gradAOvalues.row(4) +=
267 factor_1 * coeff.matrix() + second_term * AOvalue;
269 AOvalue = factor_2 * c.
xz() * (7. * c.
zz() - 3. * distsq);
270 AOvalues(5) += AOvalue;
271 coeff = {center.z() * (4. * c.
zz() - 9. * c.
xx() - 3. * c.
yy()),
272 (-6. * center.y() * c.
xz()),
273 3. * center.x() * (5. * c.
zz() - distsq)};
274 gradAOvalues.row(5) +=
275 factor_2 * coeff.matrix() + second_term * AOvalue;
278 factor_3 * (c.
xx() - c.
yy()) * (7. * c.
zz() - distsq);
279 AOvalues(6) += AOvalue;
280 coeff = {4. * center.x() * (3. * c.
zz() - c.
xx()),
281 4. * center.y() * (c.
yy() - 3. * c.
zz()),
282 12. * center.z() * (c.
xx() - c.
yy())};
283 gradAOvalues.row(6) +=
284 factor_3 * coeff.matrix() + second_term * AOvalue;
286 AOvalue = factor_4 * c.
xz() * (c.
xx() - 3. * c.
yy());
287 AOvalues(7) += AOvalue;
288 coeff = {3. * center.z() * (c.
xx() - c.
yy()),
289 (-6. * center.y() * c.
xz()),
290 center.x() * (c.
xx() - 3. * c.
yy())};
291 gradAOvalues.row(7) +=
292 factor_4 * coeff.matrix() + second_term * AOvalue;
294 AOvalue = factor * (c.
xx() * c.
xx() - 6. * c.
xx() * c.
yy() +
296 AOvalues(8) += AOvalue;
297 coeff = {center.x() * (c.
xx() - 3. * c.
yy()),
298 center.y() * (c.
yy() - 3. * c.
xx()), 0};
299 gradAOvalues.row(8) +=
300 4 * factor * coeff.matrix() + second_term * AOvalue;
311 const Eigen::Vector3d& grid_pos)
const {
313 const Eigen::Vector3d center = (grid_pos -
pos_);
314 const double distsq = center.squaredNorm();
316 Eigen::VectorXd& AOvalues = AO.
values;
318 std::vector<Eigen::Matrix3d>& hessians = AO.
hessians;
329 auto addHessianContribution = [&](
Index k,
double prefactor,
double P_val,
330 const Eigen::Vector3d& dP_vec,
331 const Eigen::Matrix3d& d2P_mat,
333 double AOvalue_local = prefactor * P_val;
334 Eigen::Vector3d second_term_local = -2.0 * alpha * center;
335 Eigen::Vector3d grad_local =
336 prefactor * dP_vec + second_term_local * AOvalue_local;
337 Eigen::Matrix3d
H = Eigen::Matrix3d::Zero();
338 for (
Index i = 0; i < 3; ++i) {
339 for (
Index j = 0; j < 3; ++j) {
340 double delta_ij = (i == j) ? 1.0 : 0.0;
341 H(i, j) = prefactor * d2P_mat(i, j) -
342 2.0 * alpha * delta_ij * AOvalue_local -
343 2.0 * alpha * center(i) * grad_local(j) -
344 2.0 * alpha * center(j) * grad_local(i) -
345 4.0 * alpha * alpha * center(i) * center(j) * AOvalue_local;
353 const double alpha = gaussian.getDecay();
354 const double contraction = gaussian.getContraction();
356 const double expofactor =
357 gaussian.getPowfactor() * std::exp(-alpha * distsq);
358 const Eigen::Vector3d second_term = -2.0 * alpha * center;
362 double AOvalue = contraction * expofactor;
363 AOvalues(0) += AOvalue;
364 gradAOvalues.row(0) += second_term * AOvalue;
366 addHessianContribution(0, contraction * expofactor, 1.0,
367 Eigen::Vector3d::Zero(), Eigen::Matrix3d::Zero(),
371 const double factor = 2. * sqrt(alpha) * contraction * expofactor;
372 Eigen::Matrix3d zero3 = Eigen::Matrix3d::Zero();
374 double AOvalue = factor * center.y();
375 AOvalues(0) += AOvalue;
376 gradAOvalues.row(0) += second_term * AOvalue;
377 gradAOvalues(0, 1) += factor;
378 addHessianContribution(0, factor, center.y(), Eigen::Vector3d(0, 1, 0),
381 AOvalue = factor * center.z();
382 AOvalues(1) += AOvalue;
383 gradAOvalues.row(1) += second_term * AOvalue;
384 gradAOvalues(1, 2) += factor;
385 addHessianContribution(1, factor, center.z(), Eigen::Vector3d(0, 0, 1),
388 AOvalue = factor * center.x();
389 AOvalues(2) += AOvalue;
390 gradAOvalues(2, 0) += factor;
391 gradAOvalues.row(2) += second_term * AOvalue;
392 addHessianContribution(2, factor, center.x(), Eigen::Vector3d(1, 0, 0),
396 const double factor = 2. * alpha * contraction * expofactor;
397 const double factor_1 = factor / sqrt(3.);
400 double AOvalue = 2. * factor * (center.x() * center.y());
401 AOvalues(0) += AOvalue;
402 Eigen::Array3d coeff = {2 * center.y(), 2 * center.x(), 0};
403 gradAOvalues.row(0) += factor * coeff.matrix() + second_term * AOvalue;
404 d2P << 0, 2, 0, 2, 0, 0, 0, 0, 0;
405 addHessianContribution(0, factor, 2. * center.x() * center.y(),
406 coeff.matrix(), d2P, alpha);
408 AOvalue = 2. * factor * (center.y() * center.z());
409 AOvalues(1) += AOvalue;
410 coeff = {0, 2 * center.z(), 2 * center.y()};
411 gradAOvalues.row(1) += factor * coeff.matrix() + second_term * AOvalue;
412 d2P << 0, 0, 0, 0, 0, 2, 0, 2, 0;
413 addHessianContribution(1, factor, 2. * center.y() * center.z(),
414 coeff.matrix(), d2P, alpha);
416 AOvalue = factor_1 * (3. * center.z() * center.z() - distsq);
417 AOvalues(2) += AOvalue;
419 gradAOvalues.row(2) += (factor_1 * coeff * center.array()).matrix() +
420 second_term * AOvalue;
421 d2P << -2, 0, 0, 0, -2, 0, 0, 0, 4;
422 addHessianContribution(2, factor_1,
423 3. * center.z() * center.z() - distsq,
424 (coeff * center.array()).matrix(), d2P, alpha);
426 AOvalue = 2. * factor * (center.x() * center.z());
427 AOvalues(3) += AOvalue;
428 coeff = {2 * center.z(), 0, 2 * center.x()};
429 gradAOvalues.row(3) += factor * coeff.matrix() + second_term * AOvalue;
430 d2P << 0, 0, 2, 0, 0, 0, 2, 0, 0;
431 addHessianContribution(3, factor, 2. * center.x() * center.z(),
432 coeff.matrix(), d2P, alpha);
435 (center.x() * center.x() - center.y() * center.y());
436 AOvalues(4) += AOvalue;
437 coeff = {2 * center.x(), -2 * center.y(), 0};
438 gradAOvalues.row(4) += factor * coeff.matrix() + second_term * AOvalue;
439 d2P << 2, 0, 0, 0, -2, 0, 0, 0, 0;
440 addHessianContribution(
441 4, factor, center.x() * center.x() - center.y() * center.y(),
442 coeff.matrix(), d2P, alpha);
445 const double factor = 2. * pow(alpha, 1.5) * contraction * expofactor;
446 const double factor_1 = factor * 2. / sqrt(15.);
447 const double factor_2 = factor * sqrt(2.) / sqrt(5.);
448 const double factor_3 = factor * sqrt(2.) / sqrt(3.);
451 double x = center.x(), y = center.y(), z = center.z();
454 factor_3 * center.y() * (3. * c.
xx() - c.
yy());
455 AOvalues(0) += AOvalue;
456 Eigen::Array3d coeff = {6. * c.
xy(), 3. * (c.
xx() - c.
yy()), 0};
457 gradAOvalues.row(0) +=
458 factor_3 * coeff.matrix() + second_term * AOvalue;
459 d2P << 6 * y, 6 * x, 0, 6 * x, -6 * y, 0, 0, 0, 0;
460 addHessianContribution(0, factor_3, y * (3. * c.
xx() - c.
yy()),
461 coeff.matrix(), d2P, alpha);
463 AOvalue = 4. * factor * center.x() * center.y() * center.z();
464 AOvalues(1) += AOvalue;
465 coeff = {c.
yz(), c.
xz(), c.
xy()};
466 gradAOvalues.row(1) +=
467 4 * factor * coeff.matrix() + second_term * AOvalue;
468 d2P << 0, z, y, z, 0, x, y, x, 0;
469 addHessianContribution(1, 4. * factor, x * y * z, coeff.matrix(), d2P,
472 AOvalue = factor_2 * center.y() * (5. * c.
zz() - distsq);
473 AOvalues(2) += AOvalue;
474 coeff = {-2. * c.
xy(), 4. * c.
zz() - c.
xx() - 3. * c.
yy(), 8. * c.
yz()};
475 gradAOvalues.row(2) +=
476 factor_2 * coeff.matrix() + second_term * AOvalue;
477 d2P << -2 * y, -2 * x, 0, -2 * x, -6 * y, 8 * z, 0, 8 * z, 8 * y;
478 addHessianContribution(2, factor_2, y * (5. * c.
zz() - distsq),
479 coeff.matrix(), d2P, alpha);
481 AOvalue = factor_1 * center.z() * (5. * c.
zz() - 3. * distsq);
482 AOvalues(3) += AOvalue;
483 coeff = {-6. * c.
xz(), -6. * c.
yz(), 3. * (3. * c.
zz() - distsq)};
484 gradAOvalues.row(3) +=
485 factor_1 * coeff.matrix() + second_term * AOvalue;
486 d2P << -6 * z, 0, -6 * x, 0, -6 * z, -6 * y, -6 * x, -6 * y, 12 * z;
487 addHessianContribution(3, factor_1, z * (5. * c.
zz() - 3. * distsq),
488 coeff.matrix(), d2P, alpha);
490 AOvalue = factor_2 * center.x() * (5. * c.
zz() - distsq);
491 AOvalues(4) += AOvalue;
492 coeff = {4. * c.
zz() - c.
yy() - 3. * c.
xx(), -2. * c.
xy(), 8. * c.
xz()};
493 gradAOvalues.row(4) +=
494 factor_2 * coeff.matrix() + second_term * AOvalue;
495 d2P << -6 * x, -2 * y, 8 * z, -2 * y, -2 * x, 0, 8 * z, 0, 8 * x;
496 addHessianContribution(4, factor_2, x * (5. * c.
zz() - distsq),
497 coeff.matrix(), d2P, alpha);
499 AOvalue = 2. * factor * center.z() * (c.
xx() - c.
yy());
500 AOvalues(5) += AOvalue;
501 coeff = {2. * c.
xz(), -2. * c.
yz(), c.
xx() - c.
yy()};
502 gradAOvalues.row(5) +=
503 2 * factor * coeff.matrix() + second_term * AOvalue;
504 d2P << 2 * z, 0, 2 * x, 0, -2 * z, -2 * y, 2 * x, -2 * y, 0;
505 addHessianContribution(5, 2. * factor, z * (c.
xx() - c.
yy()),
506 coeff.matrix(), d2P, alpha);
508 AOvalue = factor_3 * center.x() * (c.
xx() - 3. * c.
yy());
509 AOvalues(6) += AOvalue;
510 coeff = {3. * (c.
xx() - c.
yy()), -6. * c.
xy(), 0};
511 gradAOvalues.row(6) +=
512 factor_3 * coeff.matrix() + second_term * AOvalue;
513 d2P << 6 * x, -6 * y, 0, -6 * y, -6 * x, 0, 0, 0, 0;
514 addHessianContribution(6, factor_3, x * (c.
xx() - 3. * c.
yy()),
515 coeff.matrix(), d2P, alpha);
518 const double factor =
519 2. / sqrt(3.) * alpha * alpha * contraction * expofactor;
520 const double factor_1 = factor / sqrt(35.);
521 const double factor_2 = factor * 4. / sqrt(14.);
522 const double factor_3 = factor * 2. / sqrt(7.);
523 const double factor_4 = factor * 2. * sqrt(2.);
526 double x = center.x(), y = center.y(), z = center.z();
528 double AOvalue = 4. * factor * c.
xy() * (c.
xx() - c.
yy());
529 AOvalues(0) += AOvalue;
530 Eigen::Array3d coeff = {center.y() * (3. * c.
xx() - c.
yy()),
531 center.x() * (c.
xx() - 3. * c.
yy()), 0};
532 gradAOvalues.row(0) +=
533 4 * factor * coeff.matrix() + second_term * AOvalue;
534 d2P << 6 * x * y, 3 * x * x - 3 * y * y, 0, 3 * x * x - 3 * y * y,
535 -6 * x * y, 0, 0, 0, 0;
536 addHessianContribution(0, 4. * factor, x * y * (c.
xx() - c.
yy()),
537 coeff.matrix(), d2P, alpha);
539 AOvalue = factor_4 * c.
yz() * (3. * c.
xx() - c.
yy());
540 AOvalues(1) += AOvalue;
541 coeff = {6. * center.x() * c.
yz(), 3. * center.z() * (c.
xx() - c.
yy()),
542 center.y() * (3. * c.
xx() - c.
yy())};
543 gradAOvalues.row(1) +=
544 factor_4 * coeff.matrix() + second_term * AOvalue;
545 d2P << 6 * y * z, 6 * x * z, 6 * x * y, 6 * x * z, -6 * y * z,
546 3 * x * x - 3 * y * y, 6 * x * y, 3 * x * x - 3 * y * y, 0;
547 addHessianContribution(1, factor_4, y * z * (3. * c.
xx() - c.
yy()),
548 coeff.matrix(), d2P, alpha);
550 AOvalue = 2. * factor_3 * c.
xy() * (7. * c.
zz() - distsq);
551 AOvalues(2) += AOvalue;
552 coeff = {center.y() * (6. * c.
zz() - 3. * c.
xx() - c.
yy()),
553 center.x() * (6. * c.
zz() - c.
xx() - 3. * c.
yy()),
554 12. * center.z() * c.
xy()};
555 gradAOvalues.row(2) +=
556 2 * factor_3 * coeff.matrix() + second_term * AOvalue;
557 d2P << -6 * x * y, -3 * x * x - 3 * y * y + 6 * z * z, 12 * y * z,
558 -3 * x * x - 3 * y * y + 6 * z * z, -6 * x * y, 12 * x * z,
559 12 * y * z, 12 * x * z, 12 * x * y;
560 addHessianContribution(2, 2. * factor_3, x * y * (7. * c.
zz() - distsq),
561 coeff.matrix(), d2P, alpha);
563 AOvalue = factor_2 * c.
yz() * (7. * c.
zz() - 3. * distsq);
564 AOvalues(3) += AOvalue;
565 coeff = {(-6. * center.x() * c.
yz()),
566 center.z() * (4. * c.
zz() - 3. * c.
xx() - 9. * c.
yy()),
567 3. * center.y() * (5. * c.
zz() - distsq)};
568 gradAOvalues.row(3) +=
569 factor_2 * coeff.matrix() + second_term * AOvalue;
570 d2P << -6 * y * z, -6 * x * z, -6 * x * y, -6 * x * z, -18 * y * z,
571 -3 * x * x - 9 * y * y + 12 * z * z, -6 * x * y,
572 -3 * x * x - 9 * y * y + 12 * z * z, 24 * y * z;
573 addHessianContribution(3, factor_2, y * z * (7. * c.
zz() - 3. * distsq),
574 coeff.matrix(), d2P, alpha);
576 AOvalue = factor_1 * (35. * c.
zz() * c.
zz() - 30. * c.
zz() * distsq +
577 3. * distsq * distsq);
578 AOvalues(4) += AOvalue;
579 coeff = {12. * center.x() * (distsq - 5. * c.
zz()),
580 12. * center.y() * (distsq - 5. * c.
zz()),
581 16. * center.z() * (5. * c.
zz() - 3. * distsq)};
582 gradAOvalues.row(4) +=
583 factor_1 * coeff.matrix() + second_term * AOvalue;
584 d2P << 36 * x * x + 12 * y * y - 48 * z * z, 24 * x * y, -96 * x * z,
585 24 * x * y, 12 * x * x + 36 * y * y - 48 * z * z, -96 * y * z,
586 -96 * x * z, -96 * y * z, -48 * x * x - 48 * y * y + 96 * z * z;
587 addHessianContribution(4, factor_1,
588 35. * c.
zz() * c.
zz() - 30. * c.
zz() * distsq +
589 3. * distsq * distsq,
590 coeff.matrix(), d2P, alpha);
592 AOvalue = factor_2 * c.
xz() * (7. * c.
zz() - 3. * distsq);
593 AOvalues(5) += AOvalue;
594 coeff = {center.z() * (4. * c.
zz() - 9. * c.
xx() - 3. * c.
yy()),
595 (-6. * center.y() * c.
xz()),
596 3. * center.x() * (5. * c.
zz() - distsq)};
597 gradAOvalues.row(5) +=
598 factor_2 * coeff.matrix() + second_term * AOvalue;
599 d2P << -18 * x * z, -6 * y * z, -9 * x * x - 3 * y * y + 12 * z * z,
600 -6 * y * z, -6 * x * z, -6 * x * y,
601 -9 * x * x - 3 * y * y + 12 * z * z, -6 * x * y, 24 * x * z;
602 addHessianContribution(5, factor_2, x * z * (7. * c.
zz() - 3. * distsq),
603 coeff.matrix(), d2P, alpha);
606 factor_3 * (c.
xx() - c.
yy()) * (7. * c.
zz() - distsq);
607 AOvalues(6) += AOvalue;
608 coeff = {4. * center.x() * (3. * c.
zz() - c.
xx()),
609 4. * center.y() * (c.
yy() - 3. * c.
zz()),
610 12. * center.z() * (c.
xx() - c.
yy())};
611 gradAOvalues.row(6) +=
612 factor_3 * coeff.matrix() + second_term * AOvalue;
613 d2P << -12 * x * x + 12 * z * z, 0, 24 * x * z, 0,
614 12 * y * y - 12 * z * z, -24 * y * z, 24 * x * z, -24 * y * z,
615 12 * x * x - 12 * y * y;
616 addHessianContribution(6, factor_3,
617 (c.
xx() - c.
yy()) * (7. * c.
zz() - distsq),
618 coeff.matrix(), d2P, alpha);
620 AOvalue = factor_4 * c.
xz() * (c.
xx() - 3. * c.
yy());
621 AOvalues(7) += AOvalue;
622 coeff = {3. * center.z() * (c.
xx() - c.
yy()),
623 (-6. * center.y() * c.
xz()),
624 center.x() * (c.
xx() - 3. * c.
yy())};
625 gradAOvalues.row(7) +=
626 factor_4 * coeff.matrix() + second_term * AOvalue;
627 d2P << 6 * x * z, -6 * y * z, 3 * x * x - 3 * y * y, -6 * y * z,
628 -6 * x * z, -6 * x * y, 3 * x * x - 3 * y * y, -6 * x * y, 0;
629 addHessianContribution(7, factor_4, x * z * (c.
xx() - 3. * c.
yy()),
630 coeff.matrix(), d2P, alpha);
632 AOvalue = factor * (c.
xx() * c.
xx() - 6. * c.
xx() * c.
yy() +
634 AOvalues(8) += AOvalue;
635 coeff = {center.x() * (c.
xx() - 3. * c.
yy()),
636 center.y() * (c.
yy() - 3. * c.
xx()), 0};
637 gradAOvalues.row(8) +=
638 4 * factor * coeff.matrix() + second_term * AOvalue;
639 d2P << 12 * x * x - 12 * y * y, -24 * x * y, 0, -24 * x * y,
640 -12 * x * x + 12 * y * y, 0, 0, 0, 0;
655 addHessianContribution(
656 8, factor, c.
xx() * c.
xx() - 6. * c.
xx() * c.
yy() + c.
yy() * c.
yy(),
657 4.0 * coeff.matrix(), d2P, alpha);
661 " not known (Hessian evaluation)");