// like the author, you'll be doing the opposite and will rather verify
// that your implementation of the analytical solution is correct!)
AssertThrow(std::abs(f(x, y) - computed_f) < tol,
- ExcMessage(std::string("Incorrect value computed for f. ") +
- std::string("Hand-calculated value: ") +
+ ExcMessage("Incorrect value computed for f. "
+ "Hand-calculated value: " +
Utilities::to_string(f(x, y)) +
- std::string(" ; ") +
- std::string("Value computed by AD: ") +
+ " ; "
+ "Value computed by AD: " +
Utilities::to_string(computed_f)));
// Because we know the ordering of the independent variables, we know
const double computed_df_dy = Df[1];
AssertThrow(std::abs(df_dx(x, y) - computed_df_dx) < tol,
- ExcMessage(
- std::string("Incorrect value computed for df/dx. ") +
- std::string("Hand-calculated value: ") +
- Utilities::to_string(df_dx(x, y)) + std::string(" ; ") +
- std::string("Value computed by AD: ") +
- Utilities::to_string(computed_df_dx)));
+ ExcMessage("Incorrect value computed for df/dx. "
+ "Hand-calculated value: " +
+ Utilities::to_string(df_dx(x, y)) +
+ " ; "
+ "Value computed by AD: " +
+ Utilities::to_string(computed_df_dx)));
AssertThrow(std::abs(df_dy(x, y) - computed_df_dy) < tol,
- ExcMessage(
- std::string("Incorrect value computed for df/dy. ") +
- std::string("Hand-calculated value: ") +
- Utilities::to_string(df_dy(x, y)) + std::string(" ; ") +
- std::string("Value computed by AD: ") +
- Utilities::to_string(computed_df_dy)));
+ ExcMessage("Incorrect value computed for df/dy. "
+ "Hand-calculated value: " +
+ Utilities::to_string(df_dy(x, y)) +
+ " ; "
+ "Value computed by AD: " +
+ Utilities::to_string(computed_df_dy)));
// ... and similar for the Hessian.
const double computed_d2f_dx_dx = D2f[0][0];
const double computed_d2f_dy_dy = D2f[1][1];
AssertThrow(std::abs(d2f_dx_dx(x, y) - computed_d2f_dx_dx) < tol,
- ExcMessage(
- std::string("Incorrect value computed for d2f/dx_dx. ") +
- std::string("Hand-calculated value: ") +
- Utilities::to_string(d2f_dx_dx(x, y)) + std::string(" ; ") +
- std::string("Value computed by AD: ") +
- Utilities::to_string(computed_d2f_dx_dx)));
+ ExcMessage("Incorrect value computed for d2f/dx_dx. "
+ "Hand-calculated value: " +
+ Utilities::to_string(d2f_dx_dx(x, y)) +
+ " ; "
+ "Value computed by AD: " +
+ Utilities::to_string(computed_d2f_dx_dx)));
AssertThrow(std::abs(d2f_dx_dy(x, y) - computed_d2f_dx_dy) < tol,
- ExcMessage(
- std::string("Incorrect value computed for d2f/dx_dy. ") +
- std::string("Hand-calculated value: ") +
- Utilities::to_string(d2f_dx_dy(x, y)) + std::string(" ; ") +
- std::string("Value computed by AD: ") +
- Utilities::to_string(computed_d2f_dx_dy)));
+ ExcMessage("Incorrect value computed for d2f/dx_dy. "
+ "Hand-calculated value: " +
+ Utilities::to_string(d2f_dx_dy(x, y)) +
+ " ; "
+ "Value computed by AD: " +
+ Utilities::to_string(computed_d2f_dx_dy)));
AssertThrow(std::abs(d2f_dy_dx(x, y) - computed_d2f_dy_dx) < tol,
- ExcMessage(
- std::string("Incorrect value computed for d2f/dy_dx. ") +
- std::string("Hand-calculated value: ") +
- Utilities::to_string(d2f_dy_dx(x, y)) + std::string(" ; ") +
- std::string("Value computed by AD: ") +
- Utilities::to_string(computed_d2f_dy_dx)));
+ ExcMessage("Incorrect value computed for d2f/dy_dx. "
+ "Hand-calculated value: " +
+ Utilities::to_string(d2f_dy_dx(x, y)) +
+ " ; "
+ "Value computed by AD: " +
+ Utilities::to_string(computed_d2f_dy_dx)));
AssertThrow(std::abs(d2f_dy_dy(x, y) - computed_d2f_dy_dy) < tol,
- ExcMessage(
- std::string("Incorrect value computed for d2f/dy_dy. ") +
- std::string("Hand-calculated value: ") +
- Utilities::to_string(d2f_dy_dy(x, y)) + std::string(" ; ") +
- std::string("Value computed by AD: ") +
- Utilities::to_string(computed_d2f_dy_dy)));
+ ExcMessage("Incorrect value computed for d2f/dy_dy. "
+ "Hand-calculated value: " +
+ Utilities::to_string(d2f_dy_dy(x, y)) +
+ " ; "
+ "Value computed by AD: " +
+ Utilities::to_string(computed_d2f_dy_dy)));
}
// That's pretty great. There wasn't too much work involved in computing
f_sd.substitute_and_evaluate<double>(substitution_map);
AssertThrow(std::abs(f(x, y) - computed_f) < tol,
- ExcMessage(std::string("Incorrect value computed for f. ") +
- std::string("Hand-calculated value: ") +
+ ExcMessage("Incorrect value computed for f. "
+ "Hand-calculated value: " +
Utilities::to_string(f(x, y)) +
- std::string(" ; ") +
- std::string("Value computed by AD: ") +
+ " ; "
+ "Value computed by AD: " +
Utilities::to_string(computed_f)));
// We can do the same for the first derivatives...
df_dy_sd.substitute_and_evaluate<double>(substitution_map);
AssertThrow(std::abs(df_dx(x, y) - computed_df_dx) < tol,
- ExcMessage(
- std::string("Incorrect value computed for df/dx. ") +
- std::string("Hand-calculated value: ") +
- Utilities::to_string(df_dx(x, y)) + std::string(" ; ") +
- std::string("Value computed by AD: ") +
- Utilities::to_string(computed_df_dx)));
+ ExcMessage("Incorrect value computed for df/dx. "
+ "Hand-calculated value: " +
+ Utilities::to_string(df_dx(x, y)) +
+ " ; "
+ "Value computed by AD: " +
+ Utilities::to_string(computed_df_dx)));
AssertThrow(std::abs(df_dy(x, y) - computed_df_dy) < tol,
- ExcMessage(
- std::string("Incorrect value computed for df/dy. ") +
- std::string("Hand-calculated value: ") +
- Utilities::to_string(df_dy(x, y)) + std::string(" ; ") +
- std::string("Value computed by AD: ") +
- Utilities::to_string(computed_df_dy)));
+ ExcMessage("Incorrect value computed for df/dy. "
+ "Hand-calculated value: " +
+ Utilities::to_string(df_dy(x, y)) +
+ " ; "
+ "Value computed by AD: " +
+ Utilities::to_string(computed_df_dy)));
// ... and the second derivatives.
// Notice that we can reuse the same substitution map for each of these
d2f_dy_dy_sd.substitute_and_evaluate<double>(substitution_map);
AssertThrow(std::abs(d2f_dx_dx(x, y) - computed_d2f_dx_dx) < tol,
- ExcMessage(
- std::string("Incorrect value computed for d2f/dx_dx. ") +
- std::string("Hand-calculated value: ") +
- Utilities::to_string(d2f_dx_dx(x, y)) + std::string(" ; ") +
- std::string("Value computed by SD: ") +
- Utilities::to_string(computed_d2f_dx_dx)));
+ ExcMessage("Incorrect value computed for d2f/dx_dx. "
+ "Hand-calculated value: " +
+ Utilities::to_string(d2f_dx_dx(x, y)) +
+ " ; "
+ "Value computed by SD: " +
+ Utilities::to_string(computed_d2f_dx_dx)));
AssertThrow(std::abs(d2f_dx_dy(x, y) - computed_d2f_dx_dy) < tol,
- ExcMessage(
- std::string("Incorrect value computed for d2f/dx_dy. ") +
- std::string("Hand-calculated value: ") +
- Utilities::to_string(d2f_dx_dy(x, y)) + std::string(" ; ") +
- std::string("Value computed by SD: ") +
- Utilities::to_string(computed_d2f_dx_dy)));
+ ExcMessage("Incorrect value computed for d2f/dx_dy. "
+ "Hand-calculated value: " +
+ Utilities::to_string(d2f_dx_dy(x, y)) +
+ " ; "
+ "Value computed by SD: " +
+ Utilities::to_string(computed_d2f_dx_dy)));
AssertThrow(std::abs(d2f_dy_dx(x, y) - computed_d2f_dy_dx) < tol,
- ExcMessage(
- std::string("Incorrect value computed for d2f/dy_dx. ") +
- std::string("Hand-calculated value: ") +
- Utilities::to_string(d2f_dy_dx(x, y)) + std::string(" ; ") +
- std::string("Value computed by SD: ") +
- Utilities::to_string(computed_d2f_dy_dx)));
+ ExcMessage("Incorrect value computed for d2f/dy_dx. "
+ "Hand-calculated value: " +
+ Utilities::to_string(d2f_dy_dx(x, y)) +
+ " ; "
+ "Value computed by SD: " +
+ Utilities::to_string(computed_d2f_dy_dx)));
AssertThrow(std::abs(d2f_dy_dy(x, y) - computed_d2f_dy_dy) < tol,
- ExcMessage(
- std::string("Incorrect value computed for d2f/dy_dy. ") +
- std::string("Hand-calculated value: ") +
- Utilities::to_string(d2f_dy_dy(x, y)) + std::string(" ; ") +
- std::string("Value computed by SD: ") +
- Utilities::to_string(computed_d2f_dy_dy)));
+ ExcMessage("Incorrect value computed for d2f/dy_dy. "
+ "Hand-calculated value: " +
+ Utilities::to_string(d2f_dy_dy(x, y)) +
+ " ; "
+ "Value computed by SD: " +
+ Utilities::to_string(computed_d2f_dy_dy)));
}