]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add matrix with singular eigenvector matrix 14865/head
authorMartin Kronbichler <martin.kronbichler@uni-a.de>
Mon, 13 Mar 2023 18:13:01 +0000 (19:13 +0100)
committerMartin Kronbichler <martin.kronbichler@uni-a.de>
Tue, 14 Mar 2023 13:17:16 +0000 (14:17 +0100)
tests/lapack/full_matrix_38.cc
tests/lapack/full_matrix_38.output

index f84e30fb55a58dd4f8023befb9d525d7187c22d1..81ead78bbb430e6086a4e8f6a2d09f092a7772e4 100644 (file)
@@ -38,12 +38,20 @@ const double mat1[2][2] = {{4., -1.}, {-1., 4.}};
  */
 const double mat2[2][2] = {{1., -1.}, {1., 1.}};
 
+/*
+ * Eigenvalues and -vectors of this system are
+ * lambda = 1     v = (1, 0, 0)
+ * lambda = 1     v = (0, 1, 0)
+ * lambda = 1     v = (-1, 0, 0)
+ */
+const double mat3[3][3] = {{1., 0, 2.}, {0., 1., 0.}, {0., 0., 1.}};
+
 
 void
-check_matrix(const double *matrix_pointer)
+check_matrix(const double *matrix_pointer, const unsigned int size)
 {
-  FullMatrix<double>       A(2, 2, matrix_pointer);
-  LAPACKFullMatrix<double> LA(2, 2);
+  FullMatrix<double>       A(size, size, matrix_pointer);
+  LAPACKFullMatrix<double> LA(size, size);
   LA = A;
 
   deallog << "Checking matrix " << std::endl;
@@ -58,9 +66,9 @@ check_matrix(const double *matrix_pointer)
     }
   deallog << std::endl;
   deallog << "Right eigenvectors" << std::endl;
-  LA.get_right_eigenvectors().print_formatted(deallog.get_file_stream());
+  LA.get_right_eigenvectors().print(deallog.get_file_stream());
   deallog << "Left eigenvectors" << std::endl;
-  LA.get_left_eigenvectors().print_formatted(deallog.get_file_stream());
+  LA.get_left_eigenvectors().print(deallog.get_file_stream());
   deallog << std::endl;
 }
 
@@ -72,8 +80,11 @@ main()
   initlog();
 
   // Test symmetric system
-  check_matrix(&mat1[0][0]);
+  check_matrix(&mat1[0][0], 2);
 
   // Test non-symmetric system with complex eigenvalues/eigenvectors
-  check_matrix(&mat2[0][0]);
+  check_matrix(&mat2[0][0], 2);
+
+  // Test case of one eigenvalue with two associated eigenvectors
+  check_matrix(&mat3[0][0], 3);
 }
index 28e5a4ca21713ba07fb79e970d86702b14fe27ca..86c641da78d8c6a01dd5003de034c11ea29cbdfb 100644 (file)
@@ -4,20 +4,34 @@ DEAL::Checking matrix
 -1.000e+00 4.000e+00  
 DEAL::Eigenvalues: (5.00000,0.00000) (3.00000,0.00000) 
 DEAL::Right eigenvectors
-(7.071e-01,0.000e+00) (7.071e-01,0.000e+00) 
-(-7.071e-01,0.000e+00) (7.071e-01,0.000e+00) 
+(0.71,0.0)(0.71,0.0)
+(-0.71,0.0)(0.71,0.0)
 DEAL::Left eigenvectors
-(7.071e-01,0.000e+00) (7.071e-01,0.000e+00) 
-(-7.071e-01,0.000e+00) (7.071e-01,0.000e+00) 
+(0.71,0.0)(0.71,0.0)
+(-0.71,0.0)(0.71,0.0)
 DEAL::
 DEAL::Checking matrix 
 1.000e+00  -1.000e+00 
 1.000e+00  1.000e+00  
 DEAL::Eigenvalues: (1.00000,1.00000) (1.00000,-1.00000) 
 DEAL::Right eigenvectors
-(7.071e-01,0.000e+00) (7.071e-01,0.000e+00) 
-(0.000e+00,-7.071e-01) (0.000e+00,7.071e-01) 
+(0.71,0.0)(0.71,0.0)
+(0.0,-0.71)(0.0,0.71)
 DEAL::Left eigenvectors
-(-7.071e-01,0.000e+00) (-7.071e-01,0.000e+00) 
-(0.000e+00,7.071e-01) (0.000e+00,-7.071e-01) 
+(-0.71,0.0)(-0.71,0.0)
+(0.0,0.71)(0.0,-0.71)
+DEAL::
+DEAL::Checking matrix 
+1.000e+00             2.000e+00  
+           1.000e+00             
+                      1.000e+00  
+DEAL::Eigenvalues: (1.00000,0.00000) (1.00000,0.00000) (1.00000,0.00000) 
+DEAL::Right eigenvectors
+(1.0,0.0)(0.0,0.0)(-1.0,0.0)
+(0.0,0.0)(1.0,0.0)(0.0,0.0)
+(0.0,0.0)(0.0,0.0)(1.1e-16,0.0)
+DEAL::Left eigenvectors
+(1.1e-16,0.0)(0.0,0.0)(0.0,0.0)
+(0.0,0.0)(1.0,0.0)(0.0,0.0)
+(-1.0,0.0)(0.0,0.0)(1.0,0.0)
 DEAL::

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.