This file is indexed.

/usr/include/sc/chemistry/molecule/energy.h is in libsc-dev 2.3.1-16build1.

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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
//
// energy.h
//
// Copyright (C) 1996 Limit Point Systems, Inc.
//
// Author: Curtis Janssen <cljanss@limitpt.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_molecule_energy_h
#define _chemistry_molecule_energy_h

#ifdef __GNUC__
#pragma interface
#endif

#include <iostream>

#include <math/optimize/function.h>
#include <math/optimize/conv.h>
#include <chemistry/molecule/molecule.h>
#include <chemistry/molecule/coor.h>
#include <chemistry/molecule/hess.h>

namespace sc {

/** The MolecularEnergy abstract class inherits from the Function class.
It computes the energy of the molecule as a function of the geometry.  The
coordinate system used can be either internal or cartesian.  */
class MolecularEnergy: public Function {
  private:
    RefSCDimension moldim_; // the number of cartesian variables
    Ref<MolecularCoor> mc_;
    Ref<Molecule> mol_;
    Ref<MolecularHessian> hess_;
    Ref<MolecularHessian> guesshess_;

    RefSCVector cartesian_gradient_;
    RefSymmSCMatrix cartesian_hessian_;

    /// Whether to do intermediate checkpointing of this object
    bool ckpt_;
    /// Name of the file into which to checkpoint this object
    char *ckpt_file_;
    /// How often this object should be checkpointed (only matters in iterative methods)
    int ckpt_freq_;
    
  protected:
    Ref<PointGroup> initial_pg_;

    void failure(const char *);

    /// This is just a wrapper around set_value().
    virtual void set_energy(double);

    /** These are passed gradients and hessian in cartesian coordinates.
        The gradient and hessian in internal coordinates are computed. */
    virtual void set_gradient(RefSCVector&);
    virtual void set_hessian(RefSymmSCMatrix&);

    void x_to_molecule();
    void molecule_to_x();

    int print_molecule_when_changed_;
  public:
    MolecularEnergy(const MolecularEnergy&);
    /** The KeyVal constructor.
        <dl>

        <dt><tt>molecule</tt><dd> A Molecule object.  There is no default.

        <dt><tt>coor</tt><dd> A MolecularCoor object that describes the
        coordinates.  If this is not given cartesian coordinates will be
        used.  For convenience, two keywords needed by the MolecularCoor
        object are automatically provided: natom3 and matrixkit.

        <dt><tt>value_accuracy</tt><dd> Sets the accuracy to which values
        are computed.  The default is 1.0e-6 atomic units.

        <dt><tt>gradient_accuracy</tt><dd> Sets the accuracy to which
        gradients are computed.  The default is 1.0e-6 atomic units.

        <dt><tt>hessian_accuracy</tt><dd> Sets the accuracy to which
        hessians are computed.  The default is 1.0e-4 atomic units.

        <dt><tt>hessian</tt><dd>Specifies a MolecularHessian object that is
        used to compute the hessian.  If this MolecularEnergy
        specialization does not provide a hessian of its own, and a hessian
        is needed, then this keyword must be specified.

        <dt><tt>guess_hessian</tt><dd>Specifies a MolecularHessian object
        that is used to compute a guess hessian.  Guess hessians are used
        to improve the rate of convergence of optimizations.  If this
        keyword is not specified, and a MolecularCoor object is given by
        <tt>coor</tt>, then the guess hessian is obtained from the
        MolecularCoor object.  If neither this nor <tt>coor</tt> are given,
        then Function::guess_hessian is used, which returns a unit matrix.

        <dt><tt>print_molecule_when_changed</tt><dd> If true, then whenever
        the molecule's coordinates are updated they will be printed.  The
        default is true.

	<dt><tt>checkpoint</tt><dd> If true, then this object will be
	checkpointed during its evaluation. Not all implementations
	of <tt>MolecularEnergy</tt> support checkpointing.
	The default is false.

	<dt><tt>checkpoint_file</tt><dd> Specifies the name of the file
	into which this object will be checkpointed. Default is
	"<inpubasename>.ckpt", where "<inputbasename>" is the name of the input
	file without ".in".

	<dt><tt>checkpoint_freq</tt><dd> Specifies how often this object to
	be checkpointed. Only matters for objects which are computed
	iteratively. Default is 1.
	</dl> */
    MolecularEnergy(const Ref<KeyVal>&);
    MolecularEnergy(StateIn&);
    ~MolecularEnergy();

    void save_data_state(StateOut&);

    /// Set up checkpointing
    void set_checkpoint();
    void set_checkpoint_file(const char*);
    void set_checkpoint_freq(int freq);
    /// Check if need to checkpoint
    bool if_to_checkpoint() const;
    const char* checkpoint_file() const;
    int checkpoint_freq() const;
    
    MolecularEnergy & operator=(const MolecularEnergy&);
    
    /// A wrapper around value();
    virtual double energy();

    virtual Ref<Molecule> molecule() const;
    virtual RefSCDimension moldim() const;
    
    void guess_hessian(RefSymmSCMatrix&);
    RefSymmSCMatrix inverse_hessian(RefSymmSCMatrix&);

    /** If a molecule hessian object is given, it will be used to provide a
        hessian. */
    RefSymmSCMatrix hessian();
    int hessian_implemented() const;

    void set_x(const RefSCVector&);

    /// Return the cartesian coordinates.
    RefSCVector get_cartesian_x();
    /// Return the cartesian gradient.
    RefSCVector get_cartesian_gradient();
    /// Return the cartesian hessian.
    RefSymmSCMatrix get_cartesian_hessian();

    Ref<MolecularCoor> molecularcoor() { return mc_; }

    /** Call this if you have changed the molecular symmetry of the
        molecule contained by this MolecularEnergy. */
    virtual void symmetry_changed();

    Ref<NonlinearTransform> change_coordinates();
    
    /// Nicely print n x 3 data that are stored in a vector.
    void print_natom_3(const RefSCVector &,
                       const char *t=0, std::ostream&o=ExEnv::out0()) const;
    void print_natom_3(double **, const char *t=0, std::ostream&o=ExEnv::out0()) const;
    void print_natom_3(double *, const char *t=0, std::ostream&o=ExEnv::out0()) const;

    virtual void print(std::ostream& = ExEnv::out0()) const;
};


class SumMolecularEnergy: public MolecularEnergy {
  protected:
    int n_;
    Ref<MolecularEnergy> *mole_;
    double *coef_;
    void compute();
  public:
    SumMolecularEnergy(const Ref<KeyVal> &);
    SumMolecularEnergy(StateIn&);
    ~SumMolecularEnergy();

    void save_data_state(StateOut&);

    int value_implemented() const;
    int gradient_implemented() const;
    int hessian_implemented() const;

    void set_x(const RefSCVector&);
};


/* The MolEnergyConvergence class derives from the Convergence class.  The
MolEnergyConvergence class allows the user to request that cartesian
coordinates be used in evaluating the convergence criteria.  This is
useful, since the internal coordinates can be somewhat arbitary.  If the
optimization is constrained, then the fixed internal coordinates will be
projected out of the cartesian gradients.  The input is similar to that for
Convergence class with the exception that giving none of the convergence
criteria keywords is the same as providing the following input to the
KeyVal constructor:

<pre>
  conv<MolEnergyConvergence>: (
    max_disp = 1.0e-4
    max_grad = 1.0e-4
    graddisp = 1.0e-4
  )
</pre>

For MolEnergyConverence to work, the Function object given to the Optimizer
object must derive from MolecularEnergy.
*/
class MolEnergyConvergence: public Convergence {
  protected:
    Ref<MolecularEnergy> mole_;
    int cartesian_;

    void set_defaults();
  public:
    // Standard constructors and destructor.
    MolEnergyConvergence();
    MolEnergyConvergence(StateIn&);
    /** The KeyVal constructor.

        In addition to the keywords read by Convergence, the following
        keywords are examined:

        <dl>

        <dt><tt>energy</tt><dd> The MolecularEnergy object.  This is
        required.

        <dt><tt>cartesian</tt><dd> If true, cartesian displacements and
        gradients will be compared to the convergence criteria.  The
        default is true.

        </dl>

     */
    MolEnergyConvergence(const Ref<KeyVal>&);
    virtual ~MolEnergyConvergence();

    void save_data_state(StateOut&);

    // Set the current gradient and position information.  These
    //will possibly grab the cartesian infomation if we have a
    //MolecularEnergy.
    void get_grad(const Ref<Function> &);
    void get_x(const Ref<Function> &);
    void set_nextx(const RefSCVector &);

    // Return nonzero if the optimization has converged.
    int converged();
};

}

#endif

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