8 bool delta(
int i,
int j)
10 return (i == j) ? true :
false;
13 double dot(
const Eigen::MatrixXd &A,
const Eigen::MatrixXd &B) {
return (A.array() * B.array()).sum(); }
18 T homo_stress_aux(
const Eigen::Matrix<T, Eigen::Dynamic, 1> &
F)
20 T val1 =
F(0) *
F(0) +
F(1) *
F(1) +
F(2) *
F(2);
23 return sqrt(val1 / (val2 + val1));
26 Eigen::VectorXd homo_stress_aux_grad(
const Eigen::VectorXd &
F)
29 Eigen::Matrix<Diff, Eigen::Dynamic, 1> full_diff(
F.size());
30 for (
int i = 0; i <
F.size(); i++)
31 full_diff(i) =
Diff(i,
F(i));
32 auto reduced_diff = homo_stress_aux(full_diff);
34 Eigen::VectorXd
grad(
F.size());
35 for (
int i = 0; i <
F.size(); ++i)
36 grad(i) = reduced_diff.getGradient()(i);
44 if (inputs.size() != 4)
45 throw std::runtime_error(
"Invalid input size for HomoCompositeForm!");
46 return homo_stress_aux(inputs);
51 return homo_stress_aux_grad(inputs);
61 if (inputs.size() != 1)
62 throw std::runtime_error(
"Invalid input size for InequalityConstraintForm!");
69 Eigen::VectorXd grad(1);
DScalar1< double, Eigen::Matrix< double, Eigen::Dynamic, 1 > > Diff
Automatic differentiation scalar with first-order derivatives.
static void setVariableCount(size_t value)
Set the independent variable count used by the automatic differentiation layer.