template <typename T1, typename T2, int DIM>
constexpr
double eps = 1e-4;
for (int ii = 0; ii != DIM; ++ii)
for (int jj = 0; jj != DIM; ++jj)
for (int kk = 0; kk != DIM; ++kk)
for (int ll = 0; ll != DIM; ++ll) {
if (std::abs(t_1(ii, jj, kk, ll) - t_2(ii, jj, kk, ll)) >
eps)
<< "Error " << ii << " " << jj << " " << kk << " " << ll << " "
<< t_1(ii, jj, kk, ll) << " " << t_2(ii, jj, kk, ll);
}
for (int ii = 0; ii != DIM; ++ii)
for (int jj = 0; jj != DIM; ++jj)
for (int kk = 0; kk != DIM; ++kk)
for (int ll = 0; ll != DIM; ++ll)
t_1(ii, jj, kk, ll) -= t_2(ii, jj, kk, ll);
};
template <typename T1, typename T2, int DIM>
for (int ii = 0; ii != DIM; ++ii)
for (int jj = 0; jj != DIM; ++jj)
for (int kk = 0; kk != DIM; ++kk)
for (int ll = 0; ll != DIM; ++ll)
for (int zz = 0; zz != DIM; ++zz) {
auto diff = [&](auto ii, auto jj, auto kk, auto ll, int zz) {
return
t_a(ii, zz) *
t_kd(zz, kk) *
t_kd(jj, ll)
+
t_kd(ii, kk) *
t_kd(zz, ll) * t_a(zz, jj);
};
t_d_a(ii, jj, kk, ll) +=
(diff(ii, jj, kk, ll, zz) + diff(ii, jj, ll, kk, zz)) / 2.;
}
return t_d_a;
};
template <typename T1, typename T2, int DIM>
for (int ii = 0; ii != DIM; ++ii)
for (int jj = 0; jj != DIM; ++jj)
for (int kk = 0; kk != DIM; ++kk)
for (int ll = 0; ll != DIM; ++ll)
for (int mm = 0; mm != DIM; ++mm)
for (int nn = 0; nn != DIM; ++nn)
for (int zz = 0; zz != DIM; ++zz) {
auto diff = [&](auto ii, auto jj, auto kk, auto ll, int mm,
int nn, int zz) {
return
t_s(ii, jj) *
+
};
t_dd_a(kk, ll, mm, nn) += (
diff(ii, jj, kk, ll, mm, nn, zz)
+
diff(ii, jj, ll, kk, mm, nn, zz)
+
diff(ii, jj, kk, ll, nn, mm, zz)
+
diff(ii, jj, ll, kk, nn, mm, zz)
) /
4.;
}
return t_dd_a;
};
template <typename T1, int DIM>
for (int ii = 0; ii != DIM; ++ii)
for (int jj = 0; jj != DIM; ++jj)
for (int kk = 0; kk != DIM; ++kk)
for (int ll = 0; ll != DIM; ++ll) {
auto diff = [&](auto ii, auto jj, auto kk, auto ll) {
};
t_d_a(ii, jj, kk, ll) =
(diff(ii, jj, kk, ll) + diff(ii, jj, ll, kk)) / 2.;
}
return t_d_a;
};
template <typename T, int DIM>
for (int ii = 0; ii != DIM; ++ii)
for (int jj = 0; jj != DIM; ++jj)
for (int kk = 0; kk != DIM; ++kk)
for (int ll = 0; ll != DIM; ++ll)
r +=
t(ii, jj, kk, ll) *
t(ii, jj, kk, ll);
};
static char help[] =
"...\n\n";
int main(
int argc,
char *argv[]) {
auto core_log = logging::core::get();
core_log->add_sink(
BOOST_LOG_SCOPED_THREAD_ATTR("Timeline", attrs::timer());
try {
auto print_ddg = [](
auto &
t,
auto str =
"") {
constexpr
double eps = 1e-6;
for (int ii = 0; ii != 3; ++ii)
for (int jj = 0; jj != 3; ++jj)
for (int kk = 0; kk != 3; ++kk)
for (int ll = 0; ll != 3; ++ll) {
double v =
t(ii, jj, kk, ll);
double w = std::abs(
v) <
eps ? 0 :
v;
<< str << std::fixed << std::setprecision(3) << std::showpos
<< ii + 1 << " " << jj + 1 << " " << kk + 1 << " " << ll + 1
}
};
auto print_ddg_direction = [](
auto &
t,
auto kk,
int ll) {
for (int ii = 0; ii != 3; ++ii)
for (int jj = 0; jj <= ii; ++jj)
<< ii + 1 << " " << jj + 1 << " " << kk + 1 << " " << ll + 1
<<
" : " <<
t(ii, jj, kk, ll);
};
for (int ii = 0; ii != 3; ++ii)
for (int jj = 0; jj != 3; ++jj)
<< ii + 1 <<
" " << jj + 1 <<
" : " <<
t(ii, jj);
};
enum swap { swap12, swap01 };
auto run_lapack = [](
auto &
a, swap s = swap12) {
int info;
double wkopt;
int lwork = -1;
if (info > 0)
std::vector<double> work(lwork);
info =
lapack_dsyev(
'V',
'U', 3,
a.data(), 3,
w, &*work.begin(), lwork);
if (info > 0)
if (s == swap12) {
a[0 * 3 + 0],
a[0 * 3 + 1],
a[0 * 3 + 2],
a[2 * 3 + 0],
a[2 * 3 + 1],
a[2 * 3 + 2],
a[1 * 3 + 0],
a[1 * 3 + 1],
a[1 * 3 + 2]};
return std::make_tuple(t_a, t_eig_vec, t_eig_vals);
}
a[1 * 3 + 0],
a[1 * 3 + 1],
a[1 * 3 + 2],
a[0 * 3 + 0],
a[0 * 3 + 1],
a[0 * 3 + 2],
a[2 * 3 + 0],
a[2 * 3 + 1],
a[2 * 3 + 2],
};
return std::make_tuple(t_a, t_eig_vec, t_eig_vals);
};
{
1., 0.1, -0.5,
0.1, 2., 0.,
-0.5, 0., 3.};
0.969837, -0.0860972, 0.228042,
0.0790574, 0.996073, 0.0398449,
-0.230577, -0.0206147, 0.972836};
1., 0., 0.,
0., 1., 0.,
0., 0., 1.};
t_S_sym(
i,
j) = (t_S(
i,
j) || t_S(
j,
i)) / 2.;
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"Diff A";
{
auto f = [](
double v) {
return exp(
v); };
auto d_f = [](
double v) {
return exp(
v); };
auto dd_f = [](
double v) {
return exp(
v); };
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"Reconstruct mat";
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"Diff";
print_ddg_direction(t_d, 0, 2);
auto t_dd =
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"Diff Diff";
print_ddg_direction(t_dd, 0, 2);
auto norm2_t_b = t_b(
i,
j) * t_b(
i,
j);
MOFEM_LOG(
"ATOM_TEST", Sev::inform) <<
"norm2_t_b " << norm2_t_b;
MOFEM_LOG(
"ATOM_TEST", Sev::inform) <<
"norm2_t_d " << norm2_t_d;
MOFEM_LOG(
"ATOM_TEST", Sev::inform) <<
"norm2_t_dd " << norm2_t_dd;
constexpr double regression_t_b = 572.543;
constexpr double regression_t_d = 859.939;
constexpr double regression_t_dd = 859.939;
constexpr
double eps = 1e-2;
if (std::abs(norm2_t_b - regression_t_b) >
eps)
if (std::abs(norm2_t_d - regression_t_d) >
eps)
if (std::abs(norm2_t_dd - regression_t_dd) >
eps)
}
{
std::array<double, 9>
a{1., 0.1, -0.5,
0.1, 2., 0.,
-0.5, 0., 3.};
auto tuple = run_lapack(
a);
auto &t_eig_vec = std::get<1>(tuple);
auto &t_eig_vals = std::get<2>(tuple);
auto t_eig_val_diff =
(t_eig_vals(
i) - t_L(
i)) * (t_eig_vals(
i) - t_L(
i));
<< "t_eig_val_diff " << t_eig_val_diff;
auto f = [](
double v) {
return exp(
v); };
auto norm2_t_c = t_c(
i,
j) * t_c(
i,
j);
<< "Reconstruct mat difference with lapack eigen valyes and "
"vectors "
<< norm2_t_c;
constexpr
double eps = 1e-8;
if (fabs(norm2_t_c) >
eps)
"Matrix not reeconstructed");
}
{
auto f = [](
double v) {
return v; };
auto d_f = [](
double v) {
return 1; };
auto dd_f = [](
double v) {
return 0; };
constexpr
double eps = 1e-10;
{
t_b(
i,
j) -= (t_A(
i,
j) || t_A(
j,
i)) / 2;
auto norm2_t_b = t_b(
i,
j) * t_b(
i,
j);
<< "Result should be matrix itself " << norm2_t_b;
"This norm should be zero");
}
{
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_d_a";
print_ddg(t_d_a, "hand ");
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_d";
print_ddg(t_d, "code ");
<< "Direvarive hand calculation minus code " << nrm2_t_d_a;
"This norm should be zero");
}
{
1., 0., 0.,
0., 1., 0.,
0., 0., 1.};
t_S_sym(
i,
j) = t_S(
i,
j) || t_S(
j,
i);
auto t_dd =
MOFEM_LOG(
"ATOM_TEST", Sev::inform) <<
"norm2_t_dd " << norm2_t_dd;
"This norm should be zero");
}
}
{
auto f = [](
double v) {
return v *
v; };
auto d_f = [](
double v) {
return 2 *
v; };
auto dd_f = [](
double v) {
return 2; };
constexpr
double eps = 1e-9;
{
t_a(
i,
j) = t_b(
i,
j) - t_A(
i,
k) * t_A(
k,
j);
auto norm2_t_a = t_a(
i,
j) * t_a(
i,
j);
<< "Result should be matrix times matrix " << norm2_t_a;
"This norm should be zero");
}
{
print_ddg_direction(t_d, 0, 2);
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_d_a";
print_ddg(t_d_a, "hand ");
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_d";
print_ddg(t_d, "code ");
<< "Direvarive hand calculation minus code " << nrm2_t_d_a;
"This norm should be zero");
}
{
1., 1. / 2., 1. / 3.,
2. / 2., 1., 2. / 3.,
3. / 2., 1., 3. / 3.};
t_S_sym(
i,
j) = t_S(
i,
j) || t_S(
j,
i);
auto t_dd =
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_dd_a";
print_ddg(t_dd_a, "hand ");
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_dd";
print_ddg(t_dd, "code ");
<< "Direvarive hand calculation minus code " << nrm2_t_dd_a;
"This norm should be zero");
}
}
}
{
std::array<double, 9>
a{5., 4., 0,
4., 5, 0.,
0.0, 0., 9};
auto tuple = run_lapack(
a, swap01);
auto &t_a = std::get<0>(tuple);
auto &t_eig_vecs = std::get<1>(tuple);
auto &t_eig_vals = std::get<2>(tuple);
auto f = [](
double v) {
return v; };
auto d_f = [](
double v) {
return 1; };
constexpr
double eps = 1e-10;
{
t_b(
i,
j) -= (t_a(
i,
j) || t_a(
j,
i)) / 2;
auto norm2_t_b = t_b(
i,
j) * t_b(
i,
j);
<< "Result should be matrix itself " << norm2_t_b;
"This norm should be zero");
}
{
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_d_a";
print_ddg(t_d_a, "hand ");
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_d";
print_ddg(t_d, "code ");
<< "Direvarive hand calculation minus code " << nrm2_t_d_a;
"This norm should be zero");
}
{
auto f = [](
double v) {
return v *
v; };
auto d_f = [](
double v) {
return 2 *
v; };
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_d_a";
print_ddg(t_d_a, "hand ");
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_d";
print_ddg(t_d, "code ");
<< "Direvarive hand calculation minus code " << nrm2_t_d_a;
"This norm should be zero");
}
}
{
std::array<double, 9>
a{4., 0., 0,
0., 4., 0.,
0.0, 0., 4.};
auto f = [](
double v) {
return v; };
auto d_f = [](
double v) {
return 1; };
auto tuple = run_lapack(
a);
auto &t_a = std::get<0>(tuple);
auto &t_eig_vecs = std::get<1>(tuple);
auto &t_eig_vals = std::get<2>(tuple);
constexpr
double eps = 1e-10;
{
t_b(
i,
j) -= (t_a(
i,
j) || t_a(
j,
i)) / 2;
auto norm2_t_b = t_b(
i,
j) * t_b(
i,
j);
<< "Result should be matrix itself " << norm2_t_b;
"This norm should be zero");
}
{
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_d_a";
print_ddg(t_d_a, "hand ");
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_d";
print_ddg(t_d, "code ");
<< "Direvarive hand calculation minus code " << nrm2_t_d_a;
"This norm should be zero");
}
{
auto f = [](
double v) {
return v *
v; };
auto d_f = [](
double v) {
return 2 *
v; };
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_d_a";
print_ddg(t_d_a, "hand ");
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_d";
print_ddg(t_d, "code ");
<< "Direvarive hand calculation minus code " << nrm2_t_d_a;
"This norm should be zero");
}
}
{
std::array<double, 9>
a{0.1, 0., 0.,
0., 0.1, 0.,
0., 0., 0.1};
auto tuple = run_lapack(
a);
auto &t_eig_vecs = std::get<1>(tuple);
auto &t_eig_vals = std::get<2>(tuple);
t_eig_vals(0) -= 1e-4;
t_eig_vals(2) += 1e-4;
constexpr
double eps = 1e-10;
auto f = [](
double v) {
return v; };
auto d_f = [](
double v) {
return 1; };
auto dd_f = [](
double v) {
return 0; };
1., 1. / 2., 1. / 3.,
2. / 2., 1., 2. / 3.,
3. / 2., 1., 3. / 3.};
t_S_sym(
i,
j) = t_S(
i,
j) || t_S(
j,
i);
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_dd";
print_ddg(t_dd, "test ");
<< "Direvarive hand calculation minus code " << nrm2_t_dd;
"This norm should be zero");
}
{
std::array<double, 9>
a{2, 0., 0.,
0., 2, 0.,
0., 0., 2};
auto tuple = run_lapack(
a);
auto &t_eig_vecs = std::get<1>(tuple);
auto &t_eig_vals = std::get<2>(tuple);
constexpr
double eps = 1e-10;
auto f = [](
double v) {
return v *
v; };
auto d_f = [](
double v) {
return 2 *
v; };
auto dd_f = [](
double v) {
return 2; };
1., 1. / 2., 1. / 3.,
2. / 1., 1., 2. / 3.,
3. / 1., 3. / 1., 1.};
t_S_sym(
i,
j) = t_S(
i,
j) || t_S(
j,
i);
<< "Direvarive hand calculation minus code " << nrm2_t_dd_a;
"This norm should be zero");
}
{
std::array<double, 9>
a{5., 4., 0.,
4., 5., 0.,
0., 0., 9};
auto tuple = run_lapack(
a, swap01);
auto &t_eig_vecs = std::get<1>(tuple);
auto &t_eig_vals = std::get<2>(tuple);
constexpr
double eps = 1e-10;
auto f = [](
double v) {
return v *
v; };
auto d_f = [](
double v) {
return 2 *
v; };
auto dd_f = [](
double v) {
return 2; };
1., 1. / 2., 1. / 3.,
2. / 1., 1., 2. / 3.,
3. / 1., 3. / 1., 1.};
t_S_sym(
i,
j) = t_S(
i,
j) || t_S(
j,
i);
print_ddg(t_dd, "test ");
<< "Direvarive hand calculation minus code " << nrm2_t_dd_a;
"This norm should be zero");
}
{
std::array<double, 9>
a{2, 0., 0.,
0., 2, 0.,
0., 0., 2};
auto tuple = run_lapack(
a);
auto &t_eig_vecs = std::get<1>(tuple);
auto &t_eig_vals = std::get<2>(tuple);
t_eig_vals(0) -= 1e-5;
t_eig_vals(2) += 1e-5;
constexpr
double eps = 1e-7;
auto f = [](
double v) {
return exp(
v); };
auto d_f = [](
double v) {
return exp(
v); };
auto dd_f = [](
double v) {
return exp(
v); };
1., 1. / 2., 1. / 3.,
2. / 1., 1., 2. / 3.,
3. / 1., 3. / 1., 1.};
t_S_sym(
i,
j) = t_S(
i,
j) || t_S(
j,
i);
<< "Direvarive nor t_dd_1 " << nrm2_t_dd_t1;
<< "Direvarive norm t_dd_2 " << nrm2_t_dd_t2;
print_ddg(t_dd_1, "t_dd_1 ");
print_ddg(t_dd_2, "t_dd_2 ");
t_dd_3(
i,
j,
k,
l) = t_dd_1(
i,
j,
k,
l) - t_dd_2(
i,
j,
k,
l);
for (int ii = 0; ii != 3; ++ii)
for (int jj = 0; jj != 3; ++jj)
for (int kk = 0; kk != 3; ++kk)
for (int ll = 0; ll != 3; ++ll) {
constexpr
double eps = 1e-4;
if (std::abs(t_dd_3(ii, jj, kk, ll)) >
eps)
<< "Error " << ii << " " << jj << " " << kk << " " << ll
<< " " << t_dd_1(ii, jj, kk, ll) << " "
<< t_dd_2(ii, jj, kk, ll);
}
<< "Direvarive approx. calculation minus code " << nrm2_t_dd_3;
"This norm should be zero");
}
{
std::array<double, 9>
a{5., 4., 0.,
4., 5., 0.,
0., 0., 9};
auto tuple = run_lapack(
a, swap01);
auto &t_eig_vecs = std::get<1>(tuple);
auto &t_eig_vals = std::get<2>(tuple);
t_eig_vals(0) -= 1e-4;
t_eig_vals(2) += 1e-4;
constexpr
double eps = 1e-4;
auto f = [](
double v) {
return v *
v; };
auto d_f = [](
double v) {
return 2 *
v; };
auto dd_f = [](
double v) {
return 2; };
1., 1. / 2., 1. / 3.,
2. / 1., 1., 2. / 3.,
3. / 1., 3. / 1., 1.};
t_S_sym(
i,
j) = t_S(
i,
j) || t_S(
j,
i);
<< "Direvarive nor t_dd_1 " << nrm2_t_dd_t1;
<< "Direvarive norm t_dd_2 " << nrm2_t_dd_t2;
print_ddg(t_dd_1, "t_dd_1 ");
print_ddg(t_dd_2, "t_dd_2 ");
t_dd_3(
i,
j,
k,
l) = t_dd_1(
i,
j,
k,
l) - t_dd_2(
i,
j,
k,
l);
for (int ii = 0; ii != 3; ++ii)
for (int jj = 0; jj != 3; ++jj)
for (int kk = 0; kk != 3; ++kk)
for (int ll = 0; ll != 3; ++ll) {
constexpr
double eps = 1e-3;
if (std::abs(t_dd_3(ii, jj, kk, ll)) >
eps)
<< "Error " << ii << " " << jj << " " << kk << " " << ll
<< " " << t_dd_1(ii, jj, kk, ll) << " "
<< t_dd_2(ii, jj, kk, ll);
}
<< "Direvarive approx. calculation minus code " << nrm2_t_dd_3;
"This norm should be zero");
}
{
std::array<double, 9>
a{5., 4., 0.,
4., 5., 0.,
0., 0., 9};
auto tuple = run_lapack(
a, swap01);
auto &t_eig_vecs = std::get<1>(tuple);
auto &t_eig_vals = std::get<2>(tuple);
constexpr
double eps = 1e-4;
constexpr int p = 3;
auto f = [](
double v) {
return pow(
v, p); };
auto d_f = [](
double v) {
return p * pow(
v, p - 1); };
auto dd_f = [](
double v) {
return p * (p - 1) * pow(
v, std::max(0, p - 2));
};
1., 1. / 2., 1. / 3.,
2. / 1., 1., 2. / 3.,
3. / 1., 3. / 1., 1.};
t_eig_vals(0) += 2e-5;
t_eig_vals(2) -= 2e-5;
<< "Direvarive nor t_dd_1 " << nrm2_t_dd_t1;
<< "Direvarive norm t_dd_2 " << nrm2_t_dd_t2;
print_ddg(t_dd_1, "t_dd_1 ");
print_ddg(t_dd_2, "t_dd_2 ");
t_dd_3(
i,
j,
k,
l) = t_dd_1(
i,
j,
k,
l) - t_dd_2(
i,
j,
k,
l);
for (int ii = 0; ii != 3; ++ii)
for (int jj = 0; jj != 3; ++jj)
for (int kk = 0; kk != 3; ++kk)
for (int ll = 0; ll != 3; ++ll) {
constexpr
double eps = 1e-3;
if (std::abs(t_dd_3(ii, jj, kk, ll)) >
eps)
<< "Error " << ii << " " << jj << " " << kk << " " << ll
<< " " << t_dd_1(ii, jj, kk, ll) << " "
<< t_dd_2(ii, jj, kk, ll) << " " << t_dd_3(ii, jj, kk, ll);
}
<< "Direvarive approx. calculation minus code " << nrm2_t_dd_3;
"This norm should be zero");
}
{
std::array<double, 9>
a{1., 0.1, -0.5,
0.1, 2., 0.,
-0.5, 0., 3.};
auto tuple = run_lapack(
a);
auto &t_eig_vecs = std::get<1>(tuple);
auto &t_eig_vals = std::get<2>(tuple);
auto f = [](
double v) {
return exp(
v); };
auto d_f = [](
double v) {
return exp(
v); };
auto dd_f = [](
double v) {
return exp(
v); };
1., 1. / 2., 1. / 3.,
2. / 1., 1., 2. / 3.,
3. / 1., 3. / 1., 1.};
t_S_sym(
i,
j) = t_S(
i,
j) || t_S(
j,
i);
MOFEM_LOG(
"ATOM_TEST", Sev::inform) <<
"Start";
for (int ii = 0; ii != 1000; ++ii) {
std::ignore = t_d;
std::ignore = t_dd;
}
MOFEM_LOG(
"ATOM_TEST", Sev::inform) <<
"End";
}
auto run_lapack_2d = [](
auto &
a) {
int info;
double wkopt;
int lwork = -1;
if (info > 0)
std::vector<double> work(lwork);
info =
lapack_dsyev(
'V',
'U', 2,
a.data(), 2,
w, &*work.begin(), lwork);
if (info > 0)
a[0 * 2 + 0],
a[0 * 2 + 1],
a[1 * 2 + 0],
a[1 * 2 + 1]};
return std::make_tuple(t_a, t_eig_vecs, t_eig_vals);
};
{
std::array<double, 9>
a{1., 0.1,
0.1, 2.};
auto tuple = run_lapack_2d(
a);
auto &t_A = std::get<0>(tuple);
auto &t_eig_vecs = std::get<1>(tuple);
auto &t_eig_vals = std::get<2>(tuple);
auto f = [](
double v) {
return v *
v; };
auto d_f = [](
double v) {
return 2 *
v; };
auto dd_f = [](
double v) {
return 2; };
constexpr
double eps = 1e-6;
{
t_a(
i,
j) = t_b(
i,
j) - t_A(
i,
k) * t_A(
k,
j);
auto norm2_t_a = t_a(
i,
j) * t_a(
i,
j);
<< "Result should be matrix times matrix " << norm2_t_a;
"This norm should be zero");
}
{
<< "Direvarive hand calculation minus code " << nrm2_t_d_a;
"This norm should be zero");
}
{
1., 1. / 2,
2. / 2., 1.};
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_dd_a";
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_dd";
<< "Direvarive hand calculation minus code " << nrm2_t_dd_a;
"This norm should be zero");
}
}
{
std::array<double, 9>
a{2., 0,
0, 2.};
auto tuple = run_lapack_2d(
a);
auto &t_A = std::get<0>(tuple);
auto &t_eig_vecs = std::get<1>(tuple);
auto &t_eig_vals = std::get<2>(tuple);
auto f = [](
double v) {
return v *
v; };
auto d_f = [](
double v) {
return 2 *
v; };
auto dd_f = [](
double v) {
return 2; };
constexpr
double eps = 1e-6;
{
t_a(
i,
j) = t_b(
i,
j) - t_A(
i,
k) * t_A(
k,
j);
auto norm2_t_a = t_a(
i,
j) * t_a(
i,
j);
<< "Result should be matrix times matrix " << norm2_t_a;
"This norm should be zero");
}
{
<< "Direvarive hand calculation minus code " << nrm2_t_d_a;
"This norm should be zero");
}
{
1., 1. / 2,
2. / 2., 1.};
t_S_sym(
i,
j) = t_S(
i,
j) || t_S(
j,
i);
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_dd_a";
MOFEM_LOG(
"ATOM_TEST", Sev::verbose) <<
"t_dd";
<< "Direvarive hand calculation minus code " << nrm2_t_dd_a;
"This norm should be zero");
}
}
}
}