15 #define EIGEN_USE_BLAS 16 #define SIS_USE_LAPACK 23 typedef complex<double>
Cd_t;
24 typedef valarray<complex<double> >
Vcd_t;
25 complex<double>
ii(0.0, 1.0);
38 Eigen::VectorXd omval(20);
39 Eigen::MatrixXd data(20,3);
40 Eigen::MatrixXd data2(20,2);
41 omval = Eigen::VectorXd::LinSpaced(20, -2, 0);
43 valarray<double>
y, Uy, U, Uyy(
N + 1);
48 U = 1.0 -
pow(
y, 2.0);
61 Lbc.L << 1.0, 0.0, 0.0, 0.0,
65 Rbc.L << 1.0, 0.0, 0.0, 0.0,
69 Lbc.eval.setConstant(-1.0);
70 Rbc.eval.setConstant(1.0);
84 C << 1.0, 0.0, 0.0, 0.0,
88 for (
int k = 0; k < 20; k++)
90 complex<double> iiomega =
ii * omval(k);
91 double k2 = kx * kx + kz * kz;
96 Delta.coef << 1.0, 0.0, -k2;
97 Delta2.
coef << 1.0, 0.0, -2 * k2, 0.0, k4;
99 Mmat << 1.0, 0.0, 0.0, 0.0,
102 0.0, 0.0, 0.0, 0.0 * Delta;
104 Lmat << (-
ii * kx * U) + (Delta / Re), -Uy, 0.0, -
ii * kx,
105 0.0, (-
ii * kx * U) + (Delta / Re), 0.0, -Dy,
106 0.0, 0.0, (-
ii * kx * U) + (Delta / Re), -
ii * kz,
107 ii * kx, Dy,
ii * kz, 0.0;
110 A = ((iiomega * Mmat) - Lmat);
112 svd.
compute(A, B, C, Lbc, Rbc, Lbc, Rbc, 15 * (
N + 1));
115 cout <<
"First two singular values: " << svd.
eigenvalues[0] <<
" " 118 data(k,0) = omval(k);
123 data2(k,0) = omval(k);
125 psd = sqrt(svd.PowerSpectralDensity(A, B, C, Lbc, Rbc, Lbc, Rbc));
126 cout <<
"Power spectral density for omega = " << omval(k) <<
" is " <<
real(psd) << endl;
127 data2(k,1) =
real(psd);
130 ofstream outfile(
"data/Ex12.txt");
134 outfile.open(
"data/Ex_12_2.txt");
BcMat will hold general Boundary conditions as LinopMats at evealuation points, as given by operator ...
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > eval
Linop This class creates a Linear operator to solve TPBVPs.
valarray< complex< double > > Vcd_t
Eigen::Matrix< std::complex< T >, Eigen::Dynamic, 1 > eigenvalues
This class represents a block matrix operator. It is a matrix of operators.
complex< double > ii(0.0, 1.0)
void compute(const LinopMat< T > &A_, const BcMat< T > &Lbc_, const BcMat< T > &Rbc_, int num_vals)
Computes the singular values/functions of a Linear block matrix operator.
Eigen::Matrix< T, Eigen::Dynamic, 1 > coef
Stores the coefficients in the differential equation.
void setChebPts(std::valarray< T > &in)
This function sets points to evaluate a function so that a DCT will give represent the same function ...
valarray< complex< T > > pow(valarray< complex< T > > base, T power)
This class computes various SingularValues of a differential block matrix operator using using it's a...
int N
Specifies number of Chebyshev polynomials, default N = 31.
valarray< T > real(const valarray< complex< T > > &in)
real part of a complex valarray
std::valarray< SIS_TYPE > y(N+1)
void resize(int r_, int c_)
This clears all contents in the LinopMat, and then creates a fresh LinopMat of size r_ x c_...