39 template <
typename ScalarType>
43 ScalarType M[9][9] = {{ 4, 1, -2, 2, -7, 3, 9, -6, -2},
44 { 1, -2, 0, 1, -1, 5, 4, 7, 3},
45 {-2, 0, 3, 2, 0, 3, 6, 1, -1},
46 { 2, 1, 2, 1, 4, 5, 6, 7, 8},
47 {-7, -1, 0, 4, 5, 4, 9, 1, -8},
48 { 3, 5, 3, 5, 4, 9, -3, 3, 3},
49 { 9, 4, 6, 6, 9, -3, 3, 6, -7},
50 {-6, 7, 1, 7, 1, 3, 6, 2, 6},
51 {-2, 3, -1, 8, -8, 3, -7, 6, 1}};
53 for(std::size_t i = 0; i < 9; i++)
54 for(std::size_t j = 0; j < 9; j++)
61 for(std::size_t i = 0; i < 9; i++)
68 template <
typename ScalarType>
71 for (
unsigned int i = 0; i < v.size(); i++)
72 std::cout << std::setprecision(6) << std::fixed << v[i] <<
"\t";
73 std::cout << std::endl;
84 std::cout <<
"Testing matrix of size " << 9 <<
"-by-" << 9 << std::endl;
88 std::vector<ScalarType> eigenvalues_ref(9);
89 std::vector<ScalarType> eigenvalues(9);
91 initialize(A_input, eigenvalues_ref);
93 std::cout << std::endl <<
"Input matrix: " << std::endl;
94 std::cout << A_input << std::endl;
105 std::cout <<
"Calculation..." << std::endl;
111 std::cout << std::endl <<
"Eigenvalues:" << std::endl;
113 std::cout << std::endl <<
"Reference eigenvalues:" << std::endl;
115 std::cout << std::endl;
116 std::cout <<
"Eigenvectors - each column is an eigenvector" << std::endl;
117 std::cout << Q << std::endl;
122 std::cout << std::endl;
123 std::cout <<
"------- Tutorial completed --------" << std::endl;
124 std::cout << std::endl;
Generic interface for matrix-vector and matrix-matrix products. See viennacl/linalg/vector_operations...
Implementation of the QR method for eigenvalue computations. Experimental.
void vector_print(std::vector< ScalarType > &v)
void qr_method_sym(viennacl::matrix< SCALARTYPE > &A, viennacl::matrix< SCALARTYPE > &Q, std::vector< SCALARTYPE > &D)