Révision | 1d17f754f4ab74687380d69b8f4c2e267469962e (tree) |
---|---|
l'heure | 2013-02-27 03:01:34 |
Auteur | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
Refactoring MNDO to speed up. #30829
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1304 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -3929,41 +3929,45 @@ void Mndo::FreeDiatomicTwoElecTwoCore2ndDeriTemps(double*** rotatingMatrix, | ||
3929 | 3929 | void Mndo::RotateDiatomicTwoElecTwoCoreToSpaceFrame(double**** matrix, |
3930 | 3930 | double const* const* rotatingMatrix) const{ |
3931 | 3931 | double oldMatrix[dxy][dxy][dxy][dxy]; |
3932 | - for(int mu=0; mu<dxy; mu++){ | |
3933 | - for(int nu=0; nu<dxy; nu++){ | |
3934 | - for(int lambda=0; lambda<dxy; lambda++){ | |
3935 | - for(int sigma=0; sigma<dxy; sigma++){ | |
3936 | - oldMatrix[mu][nu][lambda][sigma] = matrix[mu][nu][lambda][sigma]; | |
3937 | - } | |
3938 | - } | |
3939 | - } | |
3940 | - } | |
3941 | - | |
3932 | + MolDS_wrappers::Blas::GetInstance()->Dcopy(dxy*dxy*dxy*dxy, &matrix[0][0][0][0], &oldMatrix[0][0][0][0]); | |
3933 | + | |
3942 | 3934 | // rotate (fast algorithm, see also slow algorithm shown later) |
3935 | + double** twiceRotatingMatrix = NULL; | |
3936 | + double** ptrOldMatrix = NULL; | |
3937 | + double** ptrMatrix = NULL; | |
3938 | + MallocerFreer::GetInstance()->Malloc<double>(&twiceRotatingMatrix, dxy*dxy, dxy*dxy); | |
3939 | + MallocerFreer::GetInstance()->Malloc<double*>(&ptrOldMatrix, dxy*dxy); | |
3940 | + MallocerFreer::GetInstance()->Malloc<double*>(&ptrMatrix, dxy*dxy); | |
3943 | 3941 | for(int mu=0; mu<dxy; mu++){ |
3944 | 3942 | for(int nu=0; nu<dxy; nu++){ |
3943 | + int i=mu*dxy+nu; | |
3945 | 3944 | for(int lambda=0; lambda<dxy; lambda++){ |
3946 | 3945 | for(int sigma=0; sigma<dxy; sigma++){ |
3947 | - matrix[mu][nu][lambda][sigma] = 0.0; | |
3948 | - for(int i=0; i<dxy; i++){ | |
3949 | - double tempI = 0.0; | |
3950 | - for(int j=0; j<dxy; j++){ | |
3951 | - double tempIJ = 0.0; | |
3952 | - for(int k=0; k<dxy; k++){ | |
3953 | - double tempIJK = 0.0; | |
3954 | - for(int l=0; l<dxy; l++){ | |
3955 | - tempIJK += oldMatrix[i][j][k][l]*rotatingMatrix[sigma][l]; | |
3956 | - } | |
3957 | - tempIJ += tempIJK*rotatingMatrix[lambda][k]; | |
3958 | - } | |
3959 | - tempI += tempIJ*rotatingMatrix[nu][j]; | |
3960 | - } | |
3961 | - matrix[mu][nu][lambda][sigma] += tempI*rotatingMatrix[mu][i]; | |
3962 | - } | |
3946 | + int j=lambda*dxy+sigma; | |
3947 | + twiceRotatingMatrix[i][j] = rotatingMatrix[mu][lambda]*rotatingMatrix[nu][sigma]; | |
3963 | 3948 | } |
3964 | 3949 | } |
3950 | + ptrOldMatrix[i] = &oldMatrix[mu][nu][0][0]; | |
3951 | + ptrMatrix [i] = &matrix [mu][nu][0][0]; | |
3965 | 3952 | } |
3966 | 3953 | } |
3954 | + bool isColumnMajorTwiceRotatingMatrix = false; | |
3955 | + bool isColumnMajorPtrOldMatrix = false; | |
3956 | + double alpha = 1.0; | |
3957 | + double beta = 0.0; | |
3958 | + MolDS_wrappers::Blas::GetInstance()->Dgemmm(isColumnMajorTwiceRotatingMatrix, | |
3959 | + isColumnMajorPtrOldMatrix, | |
3960 | + !isColumnMajorTwiceRotatingMatrix, | |
3961 | + dxy*dxy, dxy*dxy, dxy*dxy, dxy*dxy, | |
3962 | + alpha, | |
3963 | + twiceRotatingMatrix, | |
3964 | + ptrOldMatrix, | |
3965 | + twiceRotatingMatrix, | |
3966 | + beta, | |
3967 | + ptrMatrix); | |
3968 | + MallocerFreer::GetInstance()->Free<double>(&twiceRotatingMatrix, dxy*dxy, dxy*dxy); | |
3969 | + MallocerFreer::GetInstance()->Free<double*>(&ptrOldMatrix, dxy*dxy); | |
3970 | + MallocerFreer::GetInstance()->Free<double*>(&ptrMatrix, dxy*dxy); | |
3967 | 3971 | |
3968 | 3972 | /* |
3969 | 3973 | // rotate (slow algorithm) |