monolish  0.14.0
MONOlithic LIner equation Solvers for Highly-parallel architecture
tridiagonal_toeplitz.cpp
Go to the documentation of this file.
1 #include "../../../include/monolish_blas.hpp"
2 #include "../../internal/monolish_internal.hpp"
3 
4 namespace monolish {
5 
6 template <typename T>
8  Logger &logger = Logger::get_instance();
9  logger.util_in(monolish_func);
10 
11  matrix::COO<T> mat(M, M);
12  mat.insert(0, 0, a);
13  mat.insert(0, 1, b);
14  for (int i = 1; i < M - 1; ++i) {
15  mat.insert(i, i - 1, b);
16  mat.insert(i, i, a);
17  mat.insert(i, i + 1, b);
18  }
19  mat.insert(M - 1, M - 2, b);
20  mat.insert(M - 1, M - 1, a);
21 
22  logger.util_out();
23  return mat;
24 }
25 template matrix::COO<double>
26 util::tridiagonal_toeplitz_matrix(const int &M, double a, double b);
28  float a, float b);
29 
30 template <typename T>
31 T util::tridiagonal_toeplitz_matrix_eigenvalue(const int &M, int N, T a, T b) {
32  T exact_result = a - 2.0 * std::abs(b) * std::cos(M_PI * (N + 1) / (M + 1));
33  return exact_result;
34 }
35 template double util::tridiagonal_toeplitz_matrix_eigenvalue(const int &M,
36  int N, double a,
37  double b);
38 template float util::tridiagonal_toeplitz_matrix_eigenvalue(const int &M, int N,
39  float a, float b);
40 
41 } // namespace monolish
monolish_func
#define monolish_func
Definition: monolish_logger.hpp:9
monolish::util::tridiagonal_toeplitz_matrix
matrix::COO< T > tridiagonal_toeplitz_matrix(const int &M, T a, T b)
create tridiagonal Toeplitz matrix
Definition: tridiagonal_toeplitz.cpp:7
monolish::Logger
logger class (singleton, for developper class)
Definition: monolish_logger.hpp:19
monolish::util::tridiagonal_toeplitz_matrix_eigenvalue
T tridiagonal_toeplitz_matrix_eigenvalue(const int &M, int N, T a, T b)
Nth smallest eigenvalue of MxM tridiagonal Toeplitz matrix.
Definition: tridiagonal_toeplitz.cpp:31
monolish::matrix::COO::insert
void insert(const size_t m, const size_t n, const Float val)
insert element to (m, n)
Definition: at_insert_sort_coo.cpp:30
monolish::Logger::util_out
void util_out()
Definition: logger_utils.cpp:123
monolish::Logger::util_in
void util_in(const std::string func_name)
Definition: logger_utils.cpp:113
monolish
Definition: monolish_matrix_blas.hpp:9
monolish::matrix::COO
Coodinate (COO) format Matrix (need to sort)
Definition: monolish_coo.hpp:38
monolish::Logger::get_instance
static Logger & get_instance()
Definition: monolish_logger.hpp:42