# hsoskstmpl.h

    00001
    00002 namespace sc {
    00003
    00004 class LocalHSOSKSContribution {
    00005   private:
    00006     double * const gmat;
    00007     double * const gmato;
    00008     double * const pmat;
    00009     double * const pmato;
    00010     double a0;
    00011
    00012   public:
    00013     LocalHSOSKSContribution(double *g, double *p, double *go, double *po,
    00014                           double _a0) :
    00015       gmat(g), gmato(go), pmat(p), pmato(po), a0(_a0) {}
    00016     ~LocalHSOSKSContribution() {}
    00017
    00018     void set_bound(double, double) {}
    00019
    00020     inline void cont1(int ij, int kl, double val) {
    00021       gmat[ij] += val*pmat[kl];
    00022       gmat[kl] += val*pmat[ij];
    00023     }
    00024
    00025     inline void cont2(int ij, int kl, double val) {
    00026       val *= 0.25*a0;
    00027       gmat[ij] -= val*pmat[kl];
    00028       gmat[kl] -= val*pmat[ij];
    00029
    00030       gmato[ij] += val*pmato[kl];
    00031       gmato[kl] += val*pmato[ij];
    00032     }
    00033
    00034     inline void cont3(int ij, int kl, double val) {
    00035       val *= 0.5*a0;
    00036       gmat[ij] -= val*pmat[kl];
    00037       gmat[kl] -= val*pmat[ij];
    00038
    00039       gmato[ij] += val*pmato[kl];
    00040       gmato[kl] += val*pmato[ij];
    00041     }
    00042
    00043     inline void cont4(int ij, int kl, double val) {
    00044       gmat[ij] += (1.0 - 0.25*a0)*val*pmat[kl];
    00045       gmat[kl] += (1.0 - 0.25*a0)*val*pmat[ij];
    00046
    00047       gmato[ij] += a0*0.25*val*pmato[kl];
    00048       gmato[kl] += a0*0.25*val*pmato[ij];
    00049     }
    00050
    00051     inline void cont5(int ij, int kl, double val) {
    00052       gmat[ij] += (1.0 - 0.5*a0)*val*pmat[kl];
    00053       gmat[kl] += (1.0 - 0.5*a0)*val*pmat[ij];
    00054
    00055       gmato[ij] += 0.5*a0*val*pmato[kl];
    00056       gmato[kl] += 0.5*a0*val*pmato[ij];
    00057     }
    00058 };
    00059
    00060 class LocalHSOSKSEnergyContribution {
    00061   private:
    00062     double * const pmat;
    00063     double * const pmato;
    00064     double a0;
    00065
    00066   public:
    00067     double ec;
    00068     double ex;
    00069
    00070     LocalHSOSKSEnergyContribution(double *p, double *po,
    00071                                 double _a0) : pmat(p), pmato(po), a0(_a0) {
    00072       ec=ex=0;
    00073     }
    00074
    00075     ~LocalHSOSKSEnergyContribution() {}
    00076
    00077     void set_bound(double, double) {}
    00078
    00079     inline void cont1(int ij, int kl, double val) {
    00080       ec += val*pmat[ij]*pmat[kl];
    00081     }
    00082
    00083     inline void cont2(int ij, int kl, double val) {
    00084       ex -= a0*0.25*val*(pmat[ij]*pmat[kl] + pmato[ij]*pmato[kl]);
    00085     }
    00086
    00087     inline void cont3(int ij, int kl, double val) {
    00088       ex -= a0*0.5*val*(pmat[ij]*pmat[kl] + pmato[ij]*pmato[kl]);
    00089     }
    00090
    00091     inline void cont4(int ij, int kl, double val) {
    00092       ec += val*pmat[ij]*pmat[kl];
    00093       ex -= a0*0.25*val*(pmat[ij]*pmat[kl] + pmato[ij]*pmato[kl]);
    00094     }
    00095
    00096     inline void cont5(int ij, int kl, double val) {
    00097       ec += val*pmat[ij]*pmat[kl];
    00098       ex -= a0*0.5*val*(pmat[ij]*pmat[kl] + pmato[ij]*pmato[kl]);
    00099     }
    00100 };
    00101
    00102 }