37 #define VIENNACL_WITH_UBLAS
56 template <
typename MatrixLayout>
58 std::vector<ScalarType> & eigenvalues,
59 std::vector<ScalarType> & d,
60 std::vector<ScalarType> & e)
62 std::size_t Q_size = Q.
size2();
65 for(std::size_t j = 0; j < Q_size; j++)
68 value = (d[0]- eigenvalues[j]) * Q(0, j) + e[1] * Q(1, j);
73 for(std::size_t i = 1; i < Q_size - 1; i++)
75 value = e[i] * Q(i - 1, j) + (d[i]- eigenvalues[j]) * Q(i, j) + e[i + 1] * Q(i + 1, j);
81 value = e[Q_size - 1] * Q(Q_size - 2, j) + (d[Q_size - 1] - eigenvalues[j]) * Q(Q_size - 1, j);
93 template <
typename MatrixLayout>
99 std::vector<ScalarType> d(sz), e(sz), d_ref(sz), e_ref(sz);
101 std::cout <<
"Testing matrix of size " << sz <<
"-by-" << sz << std::endl << std::endl;
104 for(
unsigned int i = 0; i < sz; ++i)
106 d[i] = ((float)(i % 9)) - 4.5f;
107 e[i] = ((float)(i % 5)) - 4.5f;
118 if(!test_eigen_val_vec<MatrixLayout>(Q, d, d_ref, e_ref))
129 std::cout << std::endl <<
"COMPUTATION OF EIGENVALUES AND EIGENVECTORS" << std::endl;
130 std::cout << std::endl <<
"Testing QL algorithm for symmetric tridiagonal row-major matrices..." << std::endl;
131 test_qr_method_sym<viennacl::row_major>();
133 std::cout << std::endl <<
"Testing QL algorithm for symmetric tridiagonal column-major matrices..." << std::endl;
134 test_qr_method_sym<viennacl::column_major>();
136 std::cout << std::endl <<
"--------TEST SUCCESSFULLY COMPLETED----------" << std::endl;
void tql2(matrix_base< SCALARTYPE, F > &Q, VectorType &d, VectorType &e)
Implementation of the tql2-algorithm for eigenvalue computations.
Represents a vector consisting of 1 at a given index and zeros otherwise. To be used as an initialize...
void test_qr_method_sym()
bool test_eigen_val_vec(viennacl::matrix< ScalarType, MatrixLayout > &Q, std::vector< ScalarType > &eigenvalues, std::vector< ScalarType > &d, std::vector< ScalarType > &e)
size_type size2() const
Returns the number of columns.
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
Implementation of the ViennaCL scalar class.