monolish  0.14.0
MONOlithic LIner equation Solvers for Highly-parallel architecture
toeplitz_plus_hankel.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  T a2) {
9  Logger &logger = Logger::get_instance();
10  logger.util_in(monolish_func);
11 
12  matrix::COO<T> mat(M, M);
13  mat.insert(0, 0, a0 - a2);
14  mat.insert(0, 1, a1);
15  mat.insert(0, 2, a2);
16  mat.insert(1, 0, a1);
17  mat.insert(1, 1, a0);
18  mat.insert(1, 2, a1);
19  mat.insert(1, 3, a2);
20  for (int i = 2; i < M - 2; ++i) {
21  mat.insert(i, i - 2, a2);
22  mat.insert(i, i - 1, a1);
23  mat.insert(i, i, a0);
24  mat.insert(i, i + 1, a1);
25  mat.insert(i, i + 2, a2);
26  }
27  mat.insert(M - 2, M - 4, a2);
28  mat.insert(M - 2, M - 3, a1);
29  mat.insert(M - 2, M - 2, a0);
30  mat.insert(M - 2, M - 1, a1);
31  mat.insert(M - 1, M - 3, a2);
32  mat.insert(M - 1, M - 2, a1);
33  mat.insert(M - 1, M - 1, a0 - a2);
34 
35  logger.util_out();
36  return mat;
37 }
39  double a0,
40  double a1,
41  double a2);
42 template matrix::COO<float>
43 util::toeplitz_plus_hankel_matrix(const int &M, float a0, float a1, float a2);
44 
45 template <typename T>
46 T util::toeplitz_plus_hankel_matrix_eigenvalue(const int &M, int N, T a0, T a1,
47  T a2, T b0, T b1, T b2) {
48  T exact_result =
49  (a0 + 2.0 * (a1 * std::cos(M_PI * 1.0 * (N + 1) / (M + 1)) +
50  a2 * std::cos(M_PI * 2.0 * (N + 1) / (M + 1)))) /
51  (b0 + 2.0 * (b1 * std::cos(M_PI * 1.0 * (N + 1) / (M + 1)) +
52  b2 * std::cos(M_PI * 2.0 * (N + 1) / (M + 1))));
53  return exact_result;
54 }
55 template double
56 util::toeplitz_plus_hankel_matrix_eigenvalue(const int &M, int N, double a0,
57  double a1, double a2, double b0,
58  double b1, double b2);
59 template float util::toeplitz_plus_hankel_matrix_eigenvalue(const int &M, int N,
60  float a0, float a1,
61  float a2, float b0,
62  float b1, float b2);
63 
64 } // namespace monolish
monolish_func
#define monolish_func
Definition: monolish_logger.hpp:9
monolish::Logger
logger class (singleton, for developper class)
Definition: monolish_logger.hpp:19
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::util::toeplitz_plus_hankel_matrix_eigenvalue
T toeplitz_plus_hankel_matrix_eigenvalue(const int &M, int N, T a0, T a1, T a2, T b0, T b1, T b2)
Nth smallest eigenvalue of GEVP Ax=lBx of Toeplitz-plus-Hankel matrixes A, B.
Definition: toeplitz_plus_hankel.cpp:46
monolish::util::toeplitz_plus_hankel_matrix
matrix::COO< T > toeplitz_plus_hankel_matrix(const int &M, T a0, T a1, T a2)
create Toeplitz-plus-Hankel matrix
Definition: toeplitz_plus_hankel.cpp:7
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