3 #error "MoFEM need to be compiled with ADOL-C"
8 #include <adolc/adolc.h>
13 #define BOOST_UBLAS_SHALLOW_ARRAY_ADAPTOR
15 #include <boost/numeric/ublas/storage.hpp>
16 #include <boost/numeric/ublas/matrix.hpp>
17 #include <boost/numeric/ublas/matrix_proxy.hpp>
18 #include <boost/numeric/ublas/io.hpp>
20 int main(
int argc,
char *argv[]) {
24 boost::numeric::ublas::vector<double> input(3);
32 one(0, 0) = one(1, 1) = 1;
33 one(1, 0) = one(0, 1) = 1;
35 for (
int ii = 0; ii != 2; ii++) {
36 for (
int jj = 0; jj != 2; jj++) {
37 std::cout << t2(ii, jj) <<
" ";
39 std::cout << std::endl;
41 std::cout << std::endl;
51 a_t2(
I,
J) <<= t2(
I,
J);
58 for (
int ii = 0; ii != 2; ii++) {
59 for (
int jj = 0; jj != 2; jj++) {
60 std::cout << a_t2(ii, jj) <<
" ";
62 std::cout << std::endl;
64 std::cout << std::endl;
66 std::cout << a_r <<
" " <<
r << std::endl << std::endl;
68 boost::numeric::ublas::vector<double> output(3);
72 ::gradient(tag, 3, &input[0], &output[0]);
74 std::cout << input << std::endl;
75 std::cout << output << std::endl;
77 for (
int ii = 0; ii != 2; ii++) {
78 for (
int jj = 0; jj != 2; jj++) {
79 std::cout << jac_t2(ii, jj) <<
" ";
80 if (jac_t2(ii, jj) != 2) {
81 std::cerr <<
"Wrong value should be 2\n" << std::endl;
85 std::cout << std::endl;
87 std::cout << std::endl;
89 boost::numeric::ublas::matrix<double> Hessian(3, 3);
92 for (
int nn = 0; nn != 3; nn++) {
93 H[nn] = &Hessian(nn, 0);
95 ::hessian(tag, 3, &input[0],
H);
96 std::cout << Hessian << std::endl;
99 &Hessian(0, 0), &Hessian(0, 1), &Hessian(0, 2), &Hessian(1, 0),
100 &Hessian(1, 1), &Hessian(1, 2), &Hessian(2, 0), &Hessian(2, 1),
102 for (
int ii = 0; ii != 2; ii++) {
103 for (
int jj = 0; jj != 2; jj++) {
104 for (
int II = 0; II != 2; II++) {
105 for (
int JJ = 0; JJ != 2; JJ++) {
106 std::cout <<
"(" << ii <<
"," << jj <<
"," << II <<
"," << JJ <<
") "
107 << t4(ii, jj, II, JJ) << std::endl;
112 std::cout << std::endl;
114 if (t4(0, 0, 0, 0) != 2 || t4(1, 1, 1, 1) != 2 || t4(1, 0, 1, 0) != 4 ||
115 t4(0, 1, 0, 1) != 4 || t4(0, 1, 1, 0) != 4 || t4(1, 0, 0, 1) != 4) {
116 std::cerr <<
"Wrong value\n" << std::endl;