From: Martin Kronbichler Date: Mon, 13 Mar 2023 18:13:01 +0000 (+0100) Subject: Add matrix with singular eigenvector matrix X-Git-Tag: v9.5.0-rc1~474^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F14865%2Fhead;p=dealii.git Add matrix with singular eigenvector matrix --- diff --git a/tests/lapack/full_matrix_38.cc b/tests/lapack/full_matrix_38.cc index f84e30fb55..81ead78bbb 100644 --- a/tests/lapack/full_matrix_38.cc +++ b/tests/lapack/full_matrix_38.cc @@ -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 A(2, 2, matrix_pointer); - LAPACKFullMatrix LA(2, 2); + FullMatrix A(size, size, matrix_pointer); + LAPACKFullMatrix 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); } diff --git a/tests/lapack/full_matrix_38.output b/tests/lapack/full_matrix_38.output index 28e5a4ca21..86c641da78 100644 --- a/tests/lapack/full_matrix_38.output +++ b/tests/lapack/full_matrix_38.output @@ -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::