本文整理汇总了C++中ArrayXd::transpose方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayXd::transpose方法的具体用法?C++ ArrayXd::transpose怎么用?C++ ArrayXd::transpose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayXd
的用法示例。
在下文中一共展示了ArrayXd::transpose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
// The eigen approach
ArrayXd n = ArrayXd::LinSpaced(N+1,0,N);
double multiplier = M_PI/N;
Array<double, 1, N+1> nT = n.transpose();
ArrayXd x = - cos(multiplier*n);
ArrayXd xsub = x.middleRows(1, N-1);
ArrayXd ysub = (x1-x0)/2*xsub + (x1+x0)/2;
ArrayXXd T = cos((acos(x).matrix()*nT.matrix()).array());
ArrayXXd Tsub = cos((acos(xsub).matrix()*nT.matrix()).array());
ArrayXd sqinx = 1/sqrt(1-xsub*xsub);
MatrixXd inv1x2 = (sqinx).matrix().asDiagonal();
// Can't use the following to test elements of inv1x2
// std::cout << inv1x2(0,0) << "\n";
MatrixXd Usub = inv1x2 * sin(((acos(xsub).matrix())*nT.matrix()).array()).matrix();
MatrixXd dTsub = Usub*(n.matrix().asDiagonal());
MatrixXd d2Tsub = ((sqinx*sqinx).matrix().asDiagonal())*((xsub.matrix().asDiagonal()) * (dTsub.matrix()) - (Tsub.matrix()) * ((n*n).matrix().asDiagonal()));
MatrixXd d2T(N+1, N+1);
RowVectorXd a = (pow((-1),nT))*(nT*nT+1)*(nT*nT)/3;
RowVectorXd b = (nT*nT+1)*(nT*nT)/3;
d2T.middleRows(1,N-1) = d2Tsub;
d2T.row(0) = a;
d2T.row(N) = b;
MatrixXd D2 = d2T.matrix() * ((T.matrix()).inverse());
MatrixXd E2 = D2.middleRows(1,N-1).middleCols(1,N-1);
MatrixXd Y = ysub.matrix().asDiagonal();
MatrixXd H = - (4 / ((x1-x0)*(x1-x0))) * E2 + k*Y;
Eigen::EigenSolver<Eigen::MatrixXd> HE(H);
VectorXcd D = HE.eigenvalues();
MatrixXcd V = HE.eigenvectors();
std::cout << HE.info() << std::endl;
// Open ofstream
ofstream Dfile;
Dfile.open("D-output.txt");
ofstream Vfile;
Vfile.open("V-output.txt");
ofstream V544file;
V544file.open("V544-output.txt");
Dfile.precision(15);
Dfile << D.real() << "\n";
Vfile.precision(15);
Vfile << V.real() << "\n";
V544file.precision(15);
for(int i = 1; i<N-1; i++)
{
V544file << ysub[i-1];
V544file << " " << V.col(544).row(i-1).real() << "\n";
}
Dfile.close();
Vfile.close();
V544file.close();
system("gnuplot -p plot.gp");
system("rsvg-convert -w 2000 -o V544-plot.png V544-plot.svg");
}