Create test and correct some mistakes
This commit is contained in:
@@ -1,9 +1,35 @@
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
||||
#include "matrix.hpp"
|
||||
|
||||
void test_tridiag_setup() {
|
||||
void test_create_symmetric_tridiagonal() {
|
||||
double tol = 10e-8;
|
||||
double diff;
|
||||
int N = 6;
|
||||
double h = 1./(double) (N+1);
|
||||
double a = -1. / (h*h), d = 2. / (h*h);
|
||||
|
||||
arma::mat A = create_symmetric_tridiagonal(N, a, d);
|
||||
|
||||
arma::vec eigval;
|
||||
arma::mat eigvec;
|
||||
|
||||
arma::eig_sym(eigval, eigvec, A);
|
||||
|
||||
for (int i=0; i < N; i++) {
|
||||
diff = eigval(i) - (d + 2.*a*std::cos(((i+1.)*M_PI)/(N+1.)));
|
||||
assert(std::abs(diff) < tol);
|
||||
}
|
||||
}
|
||||
|
||||
void test_max_off_diag_symmetric() {
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
test_create_symmetric_tridiagonal();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user