This file is indexed.

/usr/include/sc/chemistry/qc/scf/ltbgrad.h is in libsc-dev 2.3.1-16.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
//
// ltbgrad.h --- definition of the local two-electron gradient builder
//
// Copyright (C) 1996 Limit Point Systems, Inc.
//
// Author: Edward Seidl <seidl@janed.com>
// Maintainer: LPS
//
// This file is part of the SC Toolkit.
//
// The SC Toolkit is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// The SC Toolkit is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public License
// along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
//
// The U.S. Government is granted a limited license as per AL 91-7.
//

#ifndef _chemistry_qc_scf_ltbgrad_h
#define _chemistry_qc_scf_ltbgrad_h

#ifdef __GNUC__
#pragma interface
#endif

#include <math.h>

#include <util/misc/timer.h>
#include <math/scmat/offset.h>

#include <chemistry/qc/basis/tbint.h>
#include <chemistry/qc/basis/petite.h>

#include <chemistry/qc/scf/tbgrad.h>

namespace sc {
  
template<class T>
class LocalTBGrad : public TBGrad<T> {
  public:
    double *tbgrad;

  protected:
    MessageGrp *grp_;
    TwoBodyDerivInt *tbi_;
    GaussianBasisSet *gbs_;
    PetiteList *rpl_;
    Molecule *mol_;

    double pmax_;
    double accuracy_;

    int threadno_;
    int nthread_;

  public:
    LocalTBGrad(T& t, const Ref<TwoBodyDerivInt>& tbdi, const Ref<PetiteList>& pl,
                const Ref<GaussianBasisSet>& bs, const Ref<MessageGrp>& g,
                double *tbg, double pm, double a, int nt = 1, int tn = 0,
                double exchange_fraction = 1.0) :
      TBGrad<T>(t,exchange_fraction),
      tbgrad(tbg), pmax_(pm), accuracy_(a), threadno_(tn), nthread_(nt)
    {
      grp_ = g.pointer();
      gbs_ = bs.pointer();
      rpl_ = pl.pointer();
      tbi_ = tbdi.pointer();
      mol_ = gbs_->molecule().pointer();
    }

    ~LocalTBGrad() {}
    
    void run() {
      int me = grp_->me();
      int nproc = grp_->n();
      
      // grab ref for convenience
      GaussianBasisSet& gbs = *gbs_;
      Molecule& mol = *mol_;
      PetiteList& pl = *rpl_;
      TwoBodyDerivInt& tbi = *tbi_;
      
      // create vector to hold skeleton gradient
      double *tbint = new double[mol.natom()*3];
      memset(tbint, 0, sizeof(double)*mol.natom()*3);

      // for bounds checking
      int PPmax = (int) (log(6.0*pmax_*pmax_)/log(2.0));
      int threshold = (int) (log(accuracy_)/log(2.0));
  
      int kindex=0;
      int threadind=0;
      for (int i=0; i < gbs.nshell(); i++) {
        if (!pl.in_p1(i))
          continue;
    
        int ni=gbs(i).nfunction();
        int fi=gbs.shell_to_function(i);
    
        for (int j=0; j <= i; j++) {
          int ij=i_offset(i)+j;
          if (!pl.in_p2(ij))
            continue;
      
          if (tbi.log2_shell_bound(i,j,-1,-1)+PPmax < threshold)
            continue;
      
          int nj=gbs(j).nfunction();
          int fj=gbs.shell_to_function(j);
    
          for (int k=0; k <= i; k++,kindex++) {
            if (kindex%nproc != me)
              continue;
            
            threadind++;
            if (threadind % nthread_ != threadno_)
              continue;
            
            int nk=gbs(k).nfunction();
            int fk=gbs.shell_to_function(k);
    
            for (int l=0; l <= ((i==k)?j:k); l++) {
              if (tbi.log2_shell_bound(i,j,k,l)+PPmax < threshold)
                continue;
          
              int kl=i_offset(k)+l;
              int qijkl;
              if (!(qijkl=pl.in_p4(ij,kl,i,j,k,l)))
                continue;
          
              int nl=gbs(l).nfunction();
              int fl=gbs.shell_to_function(l);

              DerivCenters cent;
              tbi.compute_shell(i,j,k,l,cent);

              const double * buf = tbi.buffer();
          
              double cscl, escl;

              this->set_scale(cscl, escl, i, j, k, l);

              int indijkl=0;
              int nx=cent.n();
              //if (cent.has_omitted_center()) nx--;
              for (int x=0; x < nx; x++) {
                int ix=cent.atom(x);
                int io=cent.omitted_atom();
                for (int ixyz=0; ixyz < 3; ixyz++) {
                  double tx = tbint[ixyz+ix*3];
                  double to = tbint[ixyz+io*3];
                  
                  for (int ip=0, ii=fi; ip < ni; ip++, ii++) {
                    for (int jp=0, jj=fj; jp < nj; jp++, jj++) {
                      for (int kp=0, kk=fk; kp < nk; kp++, kk++) {
                        for (int lp=0, ll=fl; lp < nl; lp++, ll++, indijkl++) {
                          double contrib;
                          double qint = buf[indijkl]*qijkl;

                          contrib = cscl*qint*
                            TBGrad<T>::contribution.cont1(ij_offset(ii,jj),
                                               ij_offset(kk,ll));

                          tx += contrib;
                          to -= contrib;

                          contrib = escl*qint*
                            TBGrad<T>::contribution.cont2(ij_offset(ii,kk),
                                               ij_offset(jj,ll));

                          tx += contrib;
                          to -= contrib;

                          if (i!=j && k!=l) {
                            contrib = escl*qint*
                              TBGrad<T>::contribution.cont2(ij_offset(ii,ll),
                                                 ij_offset(jj,kk));

                            tx += contrib;
                            to -= contrib;
                          }
                        }
                      }
                    }
                  }

                  tbint[ixyz+ix*3] = tx;
                  tbint[ixyz+io*3] = to;
                }
              }
            }
          }
        }
      }
      
      CharacterTable ct = mol.point_group()->char_table();
      SymmetryOperation so;

      for (int alpha=0; alpha < mol.natom(); alpha++) {
        double tbx = tbint[alpha*3+0];
        double tby = tbint[alpha*3+1];
        double tbz = tbint[alpha*3+2];
        
        for (int g=1; g < ct.order(); g++) {
          so = ct.symm_operation(g);
          int ap = pl.atom_map(alpha,g);

          tbx += tbint[ap*3+0]*so(0,0) + tbint[ap*3+1]*so(1,0) +
                 tbint[ap*3+2]*so(2,0);
          tby += tbint[ap*3+0]*so(0,1) + tbint[ap*3+1]*so(1,1) +
                 tbint[ap*3+2]*so(2,1);
          tbz += tbint[ap*3+0]*so(0,2) + tbint[ap*3+1]*so(1,2) +
                 tbint[ap*3+2]*so(2,2);
        }
        double scl = 1.0/(double)ct.order();
        tbgrad[alpha*3+0] += tbx*scl;
        tbgrad[alpha*3+1] += tby*scl;
        tbgrad[alpha*3+2] += tbz*scl;
      }
    
      delete[] tbint;
    }
};

}

#endif

// Local Variables:
// mode: c++
// c-file-style: "ETS"
// End: