修订版 | 6938e0018d1eede2c2fb1a5ea598cdd2f6a8012a (tree) |
---|---|
时间 | 2013-01-24 23:59:18 |
作者 | Katsuhiko Nishimra <ktns.87@gmai...> |
Commiter | Katsuhiko Nishimra |
Use dsyrk in CalcOrbitalElectronPopulation. #30560
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1256 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -1,6 +1,7 @@ | ||
1 | 1 | //************************************************************************// |
2 | 2 | // Copyright (C) 2011-2012 Mikiya Fujii // |
3 | -// Copyright (C) 2012-2013 Michihiro Okuyama | |
3 | +// Copyright (C) 2012-2013 Michihiro Okuyama // | |
4 | +// Copyright (C) 2013-2013 Katsuhiko Nishimra // | |
4 | 5 | // // |
5 | 6 | // This file is part of MolDS. // |
6 | 7 | // // |
@@ -1498,52 +1499,21 @@ double Cndo2::GetFockOffDiagElement(const Atom& atomA, | ||
1498 | 1499 | void Cndo2::CalcOrbitalElectronPopulation(double** orbitalElectronPopulation, |
1499 | 1500 | const Molecule& molecule, |
1500 | 1501 | double const* const* fockMatrix) const{ |
1501 | - int totalNumberAOs = molecule.GetTotalNumberAOs(); | |
1502 | + const int totalNumberAOs = molecule.GetTotalNumberAOs(); | |
1503 | + const int numberTotalValenceElectrons = molecule.GetTotalNumberValenceElectrons(); | |
1504 | + | |
1502 | 1505 | MallocerFreer::GetInstance()->Initialize<double>(orbitalElectronPopulation, totalNumberAOs, totalNumberAOs); |
1503 | 1506 | |
1504 | - double** transposedFockMatrix = NULL; | |
1505 | - try{ | |
1506 | - MallocerFreer::GetInstance()->Malloc<double>(&transposedFockMatrix, totalNumberAOs, totalNumberAOs); | |
1507 | - for(int mu=0; mu<totalNumberAOs; mu++){ | |
1508 | - for(int nu=0; nu<totalNumberAOs; nu++){ | |
1509 | - transposedFockMatrix[mu][nu] = fockMatrix[nu][mu]; | |
1510 | - } | |
1511 | - } | |
1512 | - | |
1513 | - int numberTotalValenceElectrons = molecule.GetTotalNumberValenceElectrons(); | |
1514 | - stringstream ompErrors; | |
1515 | -#pragma omp parallel for schedule(auto) | |
1516 | - for(int mu=0; mu<totalNumberAOs; mu++){ | |
1517 | - try{ | |
1518 | - for(int nu=mu; nu<totalNumberAOs; nu++){ | |
1519 | - double value = 0.0; | |
1520 | - for(int mo=0; mo<numberTotalValenceElectrons/2; mo++){ | |
1521 | - value += transposedFockMatrix[mu][mo]*transposedFockMatrix[nu][mo]; | |
1522 | - } | |
1523 | - orbitalElectronPopulation[mu][nu] = 2.0*value; | |
1524 | - } | |
1525 | - } | |
1526 | - catch(MolDSException ex){ | |
1527 | -#pragma omp critical | |
1528 | - ompErrors << ex.what() << endl ; | |
1529 | - } | |
1530 | - } | |
1531 | - // Exception throwing for omp-region | |
1532 | - if(!ompErrors.str().empty()){ | |
1533 | - throw MolDSException(ompErrors.str()); | |
1534 | - } | |
1535 | - } | |
1536 | - catch(MolDSException ex){ | |
1537 | - MallocerFreer::GetInstance()->Free<double>(&transposedFockMatrix, totalNumberAOs, totalNumberAOs); | |
1538 | - throw ex; | |
1539 | - } | |
1540 | - MallocerFreer::GetInstance()->Free<double>(&transposedFockMatrix, totalNumberAOs, totalNumberAOs); | |
1541 | - | |
1542 | - for(int mu=0; mu<totalNumberAOs; mu++){ | |
1543 | - for(int nu=mu+1; nu<totalNumberAOs; nu++){ | |
1544 | - orbitalElectronPopulation[nu][mu] = orbitalElectronPopulation[mu][nu]; | |
1545 | - } | |
1546 | - } | |
1507 | + bool isMatrixAColumnMajor = false; | |
1508 | + bool isMatrixATransposed = true; | |
1509 | + bool isLowerTriangularPartMatrixCUsed = false; | |
1510 | + double alpha = 2.0, beta = 0.0; | |
1511 | + MolDS_wrappers::Blas::GetInstance()->Dsyrk(totalNumberAOs, numberTotalValenceElectrons/2, | |
1512 | + isMatrixAColumnMajor, | |
1513 | + isMatrixATransposed, | |
1514 | + isLowerTriangularPartMatrixCUsed, | |
1515 | + alpha, fockMatrix, | |
1516 | + beta, orbitalElectronPopulation); | |
1547 | 1517 | |
1548 | 1518 | /* |
1549 | 1519 | this->OutputLog("orbital population\n"); |