1 /**********************************************************************
2   Cont_Matrix3.c:
3 
4      Cont_Matrix3.c is a subroutine to contract a Matrix3 (HVNA2).
5 
6   Log of Cont_Matrix3.c:
7 
8      19/May/2004  Released by T.Ozaki
9 
10 ***********************************************************************/
11 
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <math.h>
15 #include <time.h>
16 #include "openmx_common.h"
17 
Cont_Matrix3(double **** Mat,double **** CMat)18 void Cont_Matrix3(double ****Mat, double ****CMat)
19 {
20   int spin,Mc_AN,Gc_AN,h_AN,L,L1,M1;
21   int p,q,p0,q0,al,be,Cwan;
22   double sumS,tmp0;
23 
24   for (Mc_AN=1; Mc_AN<=Matomnum; Mc_AN++){
25     Gc_AN = M2G[Mc_AN];
26     Cwan = WhatSpecies[Gc_AN];
27 
28     for (h_AN=0; h_AN<=FNAN[Gc_AN]; h_AN++){
29 
30       for (al=0; al<Spe_Total_CNO[Cwan]; al++){
31 	for (be=0; be<Spe_Total_CNO[Cwan]; be++){
32 	  sumS = 0.0;
33 	  for (p=0; p<Spe_Specified_Num[Cwan][al]; p++){
34 	    p0 = Spe_Trans_Orbital[Cwan][al][p];
35 	    for (q=0; q<Spe_Specified_Num[Cwan][be]; q++){
36 	      q0 = Spe_Trans_Orbital[Cwan][be][q];
37 	      tmp0 = CntCoes[Mc_AN][al][p]*CntCoes[Mc_AN][be][q];
38 	      sumS += tmp0*Mat[Mc_AN][h_AN][p0][q0];
39 	    }
40 	  }
41 	  CMat[Mc_AN][h_AN][al][be] = sumS;
42 	}
43       }
44     }
45   }
46 
47 }
48