]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add tests for rank 2 tensor orthogonalization function.
authorMenno Fraters <menno.fraters@outlook.com>
Fri, 28 Feb 2020 18:20:25 +0000 (10:20 -0800)
committerMenno Fraters <menno.fraters@outlook.com>
Fri, 28 Feb 2020 18:51:10 +0000 (10:51 -0800)
tests/ad_common_tests/tensor_functions_01.h
tests/tensors/constexpr_tensor.cc
tests/tensors/constexpr_tensor.output

index e00e044980ff97b3546df7d92d845b6c11394204..85f4fc853a3123b4de4448855419e369dc4e6a82 100644 (file)
@@ -61,7 +61,8 @@ test_tensor()
   const Tensor<2, dim, ADNumberType> A_T         = transpose(A);
   const Tensor<2, dim, ADNumberType> A_adj       = adjugate(A);
   const Tensor<2, dim, ADNumberType> A_cof       = cofactor(A);
-  const ADNumberType                 A_l1_norm   = l1_norm(A);
+  const Tensor<2, dim, ADNumberType> A_orth      = orthogonalize(A);
+  const ADNumberType                 A_l1_norm   = l1_norm(A, 1e-8);
   const ADNumberType                 A_linf_norm = linfty_norm(A);
 
   const ADNumberType A_ddot_B = double_contract<0, 0, 1, 1>(A, B);
index 49748c3ae780d042c475e8c481b4592df01b0cec..d1f2f0905e0cff5d72886e94b580854e1b6e6365 100644 (file)
@@ -17,6 +17,8 @@
 
 #include <deal.II/base/tensor.h>
 
+#include <deal.II/lac/full_matrix.h>
+
 #include "../tests.h"
 
 template <int rank, int dim, typename Number>
@@ -177,6 +179,25 @@ main()
     DEAL_II_CONSTEXPR const auto dummy_6 = contract3(a, middle, a);
     DEAL_II_CONSTEXPR const auto dummy_7 = adjugate(a);
     DEAL_II_CONSTEXPR const auto dummy_8 = cofactor(a);
+    deallog << "Deteriminant before orthogonalization: " << determinant(a)
+            << std::endl;
+    const auto dummy_9 = orthogonalize(a, 1e-8);
+    deallog << "Deteriminant after  orthogonalization: " << determinant(dummy_9)
+            << std::endl;
+    Assert(determinant(dummy_9) - 1. < 1e-8, ExcInternalError());
+
+
+    constexpr double       non_orthogonal_init[3][3] = {{1., 2., 3.},
+                                                  {1., 1.5, 2.},
+                                                  {2., 0., 1}};
+    constexpr Tensor<2, 3> non_orthogonal{non_orthogonal_init};
+
+    deallog << "Deteriminant before orthogonalization: "
+            << determinant(non_orthogonal) << std::endl;
+    const auto dummy_10 = orthogonalize(non_orthogonal, 1e-8);
+    deallog << "Deteriminant after  orthogonalization: "
+            << determinant(dummy_10) << std::endl;
+    Assert(determinant(dummy_10) - 1. < 1e-8, ExcInternalError());
   }
 
   {
index 5b07862e373ac4b6df30f9973496dbcdc1f8485d..29275c9ddcfcbc1af4d1b035e58f929b0f484f24 100644 (file)
@@ -166,4 +166,8 @@ DEAL::Using Tensor within constexpr functions
 DEAL::15.2000
 DEAL::116.000
 DEAL::Used memory: 72
+DEAL::Deteriminant before orthogonalization: 1.00000
+DEAL::Deteriminant after  orthogonalization: 1.00000
+DEAL::Deteriminant before orthogonalization: -1.50000
+DEAL::Deteriminant after  orthogonalization: -1.00000
 DEAL::OK

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.