本文整理汇总了C++中DiagonalMatrix::Ncols方法的典型用法代码示例。如果您正苦于以下问题:C++ DiagonalMatrix::Ncols方法的具体用法?C++ DiagonalMatrix::Ncols怎么用?C++ DiagonalMatrix::Ncols使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiagonalMatrix
的用法示例。
在下文中一共展示了DiagonalMatrix::Ncols方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Print
void Print(const DiagonalMatrix& X)
{
++PCN;
cout << "\nMatrix type: " << X.Type().Value() << " (";
cout << X.Nrows() << ", ";
cout << X.Ncols() << ")\n\n";
if (X.IsZero()) { cout << "All elements are zero\n" << flush; return; }
int nr=X.Nrows(); int nc=X.Ncols();
for (int i=1; i<=nr; i++)
{
for (int j=1; j<i; j++) cout << "\t";
if (i<=nc) cout << X(i,i) << "\t";
cout << "\n";
}
cout << flush; ++PCZ;
}
示例2: subspace_h
void SpinAdapted::Linear::block_davidson(vector<Wavefunction>& b, DiagonalMatrix& h_diag, double normtol, const bool &warmUp, Davidson_functor& h_multiply, bool& useprecond, int currentRoot, std::vector<Wavefunction> &lowerStates)
{
pout.precision (12);
#ifndef SERIAL
mpi::communicator world;
#endif
int iter = 0;
double levelshift = 0.0;
int nroots = b.size();
//normalise all the guess roots
if(mpigetrank() == 0) {
for(int i=0; i<nroots; ++i)
{
for(int j=0; j<i; ++j)
{
double overlap = DotProduct(b[j], b[i]);
ScaleAdd(-overlap, b[j], b[i]);
}
Normalise(b[i]);
}
//if we are doing state specific, lowerstates has lower energy states
if (lowerStates.size() != 0) {
for (int i=0; i<lowerStates.size(); i++) {
double overlap = DotProduct(b[0], lowerStates[i]);
ScaleAdd(-overlap/DotProduct(lowerStates[i], lowerStates[i]), lowerStates[i], b[0]);
}
Normalise(b[0]);
}
}
vector<Wavefunction> sigma;
int converged_roots = 0;
int maxiter = h_diag.Ncols() - lowerStates.size();
while(true)
{
if (dmrginp.outputlevel() > 0)
pout << "\t\t\t Davidson Iteration :: " << iter << endl;
++iter;
dmrginp.hmultiply -> start();
int sigmasize, bsize;
if (mpigetrank() == 0) {
sigmasize = sigma.size();
bsize = b.size();
}
#ifndef SERIAL
mpi::broadcast(world, sigmasize, 0);
mpi::broadcast(world, bsize, 0);
#endif
//multiply all guess vectors with hamiltonian c = Hv
for(int i=sigmasize; i<bsize; ++i) {
Wavefunction sigmai, bi;
Wavefunction* sigmaptr=&sigmai, *bptr = &bi;
if (mpigetrank() == 0) {
sigma.push_back(b[i]);
sigma[i].Clear();
sigmaptr = &sigma[i];
bptr = &b[i];
}
#ifndef SERIAL
mpi::broadcast(world, *bptr, 0);
#endif
if (mpigetrank() != 0) {
sigmai = bi;
sigmai.Clear();
}
h_multiply(*bptr, *sigmaptr);
//if (mpigetrank() == 0) {
// cout << *bptr << endl;
// cout << *sigmaptr << endl;
//}
}
dmrginp.hmultiply -> stop();
Wavefunction r;
DiagonalMatrix subspace_eigenvalues;
if (mpigetrank() == 0) {
Matrix subspace_h(b.size(), b.size());
for (int i = 0; i < b.size(); ++i)
for (int j = 0; j <= i; ++j) {
subspace_h.element(i, j) = DotProduct(b[i], sigma[j]);
subspace_h.element(j, i) = subspace_h.element(i, j);
}
Matrix alpha;
diagonalise(subspace_h, subspace_eigenvalues, alpha);
if (dmrginp.outputlevel() > 0) {
for (int i = 1; i <= subspace_eigenvalues.Ncols (); ++i)
pout << "\t\t\t " << i << " :: " << subspace_eigenvalues(i,i)+dmrginp.get_coreenergy() << endl;
//.........这里部分代码省略.........