Spectral Integral Suite in C++
intWts.h
Go to the documentation of this file.
1 // function out = IntWts(N)
2 Eigen::MatrixXd intWts(int N){
3  // IntWts: Integration weight matrix is generated for two functions in a
4  // Chebyshev basis.
5  // Working procedure:
6  // \int_{-1}^{1} T_m(y) Tn(y) dy = \int_{0}^{\pi} cos(m \theta) cos(n
7  // \theta) sin (\theta) d \theta.
8  // This integral is given by:
9  // z = -((1+(-1)^(m+n))/(-1 + m + n)) + (1 + (-1)^(m-n))/(1 + m - n) +
10  // (1 + (-1)^(m-n))/(1 - m + n) + (1 + (-1)^(m+n))/(1 + m + n);
11  // where if any term has denominator as zero, the term is treated as zero.
12 Eigen::MatrixXd out(N+1,N+1);
13 out = Eigen::MatrixXd::Zero(N + 1, N + 1);
14 cout << __LINE__ << " " << __FILE__ << endl << flush;
15 for (int m = 0; m < N+1; m++) {
16  for (int n = 0; n < N+1; n++){
17  double z = 0;
18  if ((m + n) != 1) {
19  z += -((1.0+pow((-1),(m+n)))/(-1.0 + m + n));
20  }
21  if ((m-n) != -1) {
22  z += (1.0 + pow((-1),(m-n)))/(1.0 + m - n);
23  }
24  if ((-m+n) != -1) {
25  z += (1.0 + pow((-1),(m-n)))/(1.0 - m + n);
26  }
27  if ((m+n) != -1) {
28  z += (1.0 + pow((-1),(m+n)))/(1.0 + m + n);
29  }
30  out(m,n) = z/4;
31  }
32 }
33 cout << __LINE__ << " " << __FILE__ << endl
34  << flush;
35 out(0, 0) = out(0, 0) / 4.0;
36 out.block(1, 0, N, 1) = out.block(1, 0, N, 1)/2.0;
37 out.block(0, 1, 1, N) = out.block(0, 1, 1, N) / 2.0;
38 //out(2: end, 1) = out(2: end, 1) /2;
39 //out(1,2:end) = out(1,2:end)/2;
40 return out;
41 }
Eigen::MatrixXd intWts(int N)
Definition: intWts.h:2
valarray< complex< T > > pow(valarray< complex< T > > base, T power)
Definition: sis.hpp:453
int N
Specifies number of Chebyshev polynomials, default N = 31.
Definition: sis.hpp:472