This file is indexed.

/usr/include/clipper/core/nxmap.h is in libclipper-dev 2.1+20100511-0ubuntu1.

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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
/*! \file lib/nxmap.h
    Header file for non-crystal map
*/
//C Copyright (C) 2000-2006 Kevin Cowtan and University of York
//L
//L  This library is free software and is distributed under the terms
//L  and conditions of version 2.1 of the GNU Lesser General Public
//L  Licence (LGPL) with the following additional clause:
//L
//L     `You may also combine or link a "work that uses the Library" to
//L     produce a work containing portions of the Library, and distribute
//L     that work under terms of your choice, provided that you give
//L     prominent notice with each copy of the work that the specified
//L     version of the Library is used in it, and that you include or
//L     provide public access to the complete corresponding
//L     machine-readable source code for the Library including whatever
//L     changes were used in the work. (i.e. If you make changes to the
//L     Library you must distribute those, but you do not need to
//L     distribute source or object code to those portions of the work
//L     not covered by this licence.)'
//L
//L  Note that this clause grants an additional right and does not impose
//L  any additional restriction, and so does not affect compatibility
//L  with the GNU General Public Licence (GPL). If you wish to negotiate
//L  other terms, please contact the maintainer.
//L
//L  You can redistribute it and/or modify the library under the terms of
//L  the GNU Lesser General Public License as published by the Free Software
//L  Foundation; either version 2.1 of the License, or (at your option) any
//L  later version.
//L
//L  This library is distributed in the hope that it will be useful, but
//L  WITHOUT ANY WARRANTY; without even the implied warranty of
//L  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//L  Lesser General Public License for more details.
//L
//L  You should have received a copy of the CCP4 licence and/or GNU
//L  Lesser General Public License along with this library; if not, write
//L  to the CCP4 Secretary, Daresbury Laboratory, Warrington WA4 4AD, UK.
//L  The GNU Lesser General Public can also be obtained by writing to the
//L  Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
//L  MA 02111-1307 USA


#ifndef CLIPPER_NXMAP
#define CLIPPER_NXMAP


#include "derivs.h"


namespace clipper
{

  //! NXmap_base: base for non-crystallographic map class
  /*!
    The non-crystallographic map class stores a map of arbitrary data
    type. Unlike an Xmap it is finite in extent and has no
    symmetry. An RT operator provides mapping onto an arbitrary
    orthogonal coordinate frame. Iterators provide efficient access to
    data.

    This base contains everything except the data, which is templated
    in the derived type clipper::NXmap<T>.
  */
  class NXmap_base
  {
  public:
    //! test if object has been initialised
    bool is_null() const;

    //! return the grid dimensions for this map
    const Grid& grid() const { return grid_; }
    //! return the orthogonal-to-grid coordinate operator
    const RTop<>& operator_orth_grid() const { return rt_orth_grid; }
    //! return the grid-to-orthogonal coordinate operator
    const RTop<>& operator_grid_orth() const { return rt_grid_orth; }
    //! convert map coordinate to orthogonal
    /*! \param cm The grid coordinate to be converted.
      \return The equivalent orthogonal coordinate. */
    inline Coord_orth coord_orth( const Coord_map& cm ) const
      { return Coord_orth( rt_grid_orth*cm ); }
    //! convert orthogonal coordinate to map
    /*! \param co The orthogonal coordinate to be converted.
      \return The equivalent grid coordinate. */
    inline Coord_map coord_map( const Coord_orth& co ) const
      { return Coord_map ( rt_orth_grid*co ); }

    //! is the given coord available in the map?
    bool in_map( const Coord_grid& pos ) const { return grid_.in_grid( pos ); }
    //! is the given coord available in the map using the given interpolant?
    template<class I> bool in_map( const Coord_map& cm ) const;

    //! get multiplicity of a map grid point (always 1 for NXmap)
    int multiplicity( const Coord_grid& pos ) const { return 1; }

    //! Map reference base class
    /*! This is a reference to an Map. It forms a base class for
      index-like and coordinate-like Map references. If you write a
      method which will work with either, then specify this instead of
      either of the derived classed. \internal */
    class Map_reference_base
    {
    public:
      //! return the parent NXmap
      inline const NXmap_base& base_nxmap() const { return *map_; }
      //! Get the index into the map data array
      inline const int& index() const { return index_; }
      //! Check for end of map
      inline bool last() const { return ( index_ >= map_->grid_.size() ); }
    protected:
      //! pointer to map for which this Map_reference_index is defined
      const NXmap_base* map_;
      //! integer index into map data array
      int index_;
    };

    //! Map reference with index-like behaviour
    /*! This is a reference to a map coordinate. It behaves like a
      simple index into the map, but can be easily converted into a
      coordinate as and when required. It also implements methods for
      iterating through the map. It is very compact, but coord()
      involves some overhead.

      \note The following methods are inherited from
      Map_reference_base but are documented here for convenience:
      base_nxmap(), index(), last().
    */
    class Map_reference_index : public Map_reference_base
    {
    public:
      //! Null constructor
      Map_reference_index() {}
      //! Constructor: need parent map
      explicit Map_reference_index( const NXmap_base& map )
	{ map_ = &map; index_ = 0; }
      //! Constructor: need parent map and coord
      Map_reference_index( const NXmap_base& map, const Coord_grid& pos )
	{ map_ = &map; index_ = map_->grid_.index( pos ); }
      //! Get current grid coordinate
      inline Coord_grid coord() const
	{ return map_->grid_.deindex(index_); }
      //! Get current value of orthogonal coordinate
      inline const Coord_orth coord_orth() const
	{ return map_->coord_orth( coord().coord_map() ); }
      //! Set current value of coordinate - optimised for nearby coords
      inline Map_reference_index& set_coord( const Coord_grid& pos )
	{ index_ = map_->grid_.index( pos ); return *this; }
      //! Simple increment
      inline Map_reference_index& next() { index_++; return *this; }
      //! Index of neighbouring point
      /* Use for e.g. peak search. Valid for -1 <= du/dv/dw <= 1 only.
	 \param du/dv/dw Coordinate offset. \return Map index. */
      inline int index_offset(const int& du,const int& dv,const int& dw) const {
	return index_ + du*map_->du + dv*map_->dv + dw*map_->dw;
      }
      // inherited functions listed for documentation purposes
      //-- const NXmap_base& base_nxmap() const;
      //-- const int& index() const;
      //-- bool last() const;
    };

    //! Map reference with coordinate-like behaviour
    /*! This is a reference to a map coordinate. It behaves like a
      coordinate, but also stores the index of the corresponding point
      in the map. It also implements methods for iterating through the
      a map. Since the current coordinate is stored, coord() is
      fast. However it required 5 words of storage.

      \note The following methods are inherited from
      Map_reference_base but are documented here for convenience:
      base_nxmap(), index(), last().
    */
    class Map_reference_coord : public NXmap_base::Map_reference_base
    {
    public:
      //! Null constructor
      Map_reference_coord() {}
      //! Constructor: need parent map
      explicit Map_reference_coord( const NXmap_base& map )
	{ map_ = &map; }
      //! Constructor: need parent map and coord
      Map_reference_coord( const NXmap_base& map, const Coord_grid& pos )
	{ map_ = &map; set_coord( pos ); }
      //! Get current value of coordinate
      inline Coord_grid coord() const { return pos_; }
      //! Get current value of orthogonal coordinate
      inline const Coord_orth coord_orth() const
	{ return map_->coord_orth( coord().coord_map() ); }
      //! Set current value of coordinate - optimised for nearby coords
      inline Map_reference_coord& set_coord( const Coord_grid& pos )
	{ pos_ = pos; index_ = map_->grid_.index( pos_ ); return *this; }
      //! Simple increment
      /*! Use of this function resets the stored coordinate and sym */
      inline Map_reference_coord& next() {
	index_++;
	pos_ = map_->grid_.deindex(index_);
	return *this;
      }
      // Increment u,v,w
      inline Map_reference_coord& next_u() { pos_.u()++; index_ += map_->du; return *this; }  //!< increment u
      inline Map_reference_coord& next_v() { pos_.v()++; index_ += map_->dv; return *this; }  //!< increment v
      inline Map_reference_coord& next_w() { pos_.w()++; index_ += map_->dw; return *this; }  //!< increment w
      inline Map_reference_coord& prev_u() { pos_.u()--; index_ -= map_->du; return *this; }  //!< decrement u
      inline Map_reference_coord& prev_v() { pos_.v()--; index_ -= map_->dv; return *this; }  //!< decrement v
      inline Map_reference_coord& prev_w() { pos_.w()--; index_ -= map_->dw; return *this; }  //!< decrement w
      //! Assignment operator from a coord
      inline Map_reference_coord& operator =( const Coord_grid& pos )
	{ return set_coord( pos ); }
      // inherited functions listed for documentation purposes
      //-- const NXmap_base& base_nxmap() const;
      //-- const int& index() const;
      //-- bool last() const;
    protected:
      //! Current coord
      Coord_grid pos_;
    };

    //! return a basic Map_reference_index for this map
    Map_reference_index first() const { return Map_reference_index( *this ); }
    //! return a coord Map_reference_index for this map
    Map_reference_coord first_coord() const { return Map_reference_coord( *this ); }

  protected:
    Grid grid_;               //!< grid for the map
    RTop<> rt_orth_grid; //!< orth->grid operator
    RTop<> rt_grid_orth; //!< grid->orth operator
    int du, dv, dw;           //!< steps for shifts along u,v,w

    //! Null constructor, for later initialisation
    NXmap_base();
    //! initialiser: takes grid and orthogonal->grid coordinate operator 
    void init( const Grid& grid, const RTop<>& rt );
    //! initialiser: takes grid, cell, and fraction limits
    void init( const Cell& cell, const Grid_sampling& grid, const Grid_range& grid_extent );

    friend class NXmap_base::Map_reference_base;
    friend class NXmap_base::Map_reference_index;
    friend class NXmap_base::Map_reference_coord;
  };




  //! NXmap<T>: actual non-crystallographic map class
  /*!
    The non-crystallographic map class stores a map of arbitrary data
    type. Unlike an Xmap it is finite in extent and has no
    symmetry. An RT operator provides mapping onto an arbitrary
    orthogonal coordinate frame. Iterators provide efficient access to
    data.

    This is derived from NXmap_base, and adds the templatised data
    itself and the methods which deal with it.

    \note The following methods are inherited from NXmap_base but are
    documented here for convenience: grid(), coord_orth(),
    coord_grid(), first(), first_coord().
  */
  template<class T> class NXmap : public NXmap_base
  {
  public:
    //! Null constructor, for later initialisation
    NXmap() {}
    //! Constructor: takes grid and orthogonal->grid coordinate operator
    NXmap( const Grid& grid, const RTop<>& rt );
    //! Constructor: takes grid, cell, and extent
    NXmap( const Cell& cell, const Grid_sampling& grid, const Grid_range& grid_extent );
    //! initialiser: takes grid and orthogonal->grid coordinate operator 
    void init( const Grid& grid, const RTop<>& rt );
    //! initialiser: takes grid, cell, and fraction limits
    void init( const Cell& cell, const Grid_sampling& grid, const Grid_range& grid_extent );

    //! get data by Map_reference_index
    inline const T& operator[] (const NXmap_base::Map_reference_index i) const
      { return list[i.index()]; }
    //! set data by Map_reference_index
    inline T& operator[] (const NXmap_base::Map_reference_index i)
      { return list[i.index()]; }

    //! get data by Map_reference_coord
    inline const T& operator[] (const NXmap_base::Map_reference_coord i) const
      { return list[i.index()]; }
    //! set data by Map_reference_coord
    inline T& operator[] (const NXmap_base::Map_reference_coord i)
      { return list[i.index()]; }

    //! get a density value for an arbitrary position
    inline const T& get_data( const Coord_grid& pos ) const
      { return list[ grid_.index( pos ) ]; }
    //! set a density value for an arbitrary position
    inline void set_data( const Coord_grid& pos, const T& val )
      { list[ grid_.index( pos ) ] = val; }

    //! get map value for map coord using supplied interpolator
    template<class I> T interp( const Coord_map& pos ) const;
    //! get map value and grad for map coord using supplied interpolator
    template<class I> void interp_grad( const Coord_map& pos, T& val, Grad_map<T>& grad ) const;
    //! get map value and curv for map coord using supplied interpolator
    template<class I> void interp_curv( const Coord_map& pos, T& val, Grad_map<T>& grad, Curv_map<T>& curv ) const;

    // inherited functions listed for documentation purposes
    //-- const Grid& grid() const;
    //-- const RTop<> operator_orth_grid() const;
    //-- const RTop<> operator_grid_orth() const;
    //-- const Coord_orth coord_orth( const Coord_map&  cg ) const;
    //-- const Coord_map  coord_map ( const Coord_orth& co ) const;
    //-- const Map_reference_index first();
    //-- const Map_reference_coord first_coord();

    //! assignment operator: assigns a single value to the whole map
    const T& operator =( const T& value );
    //! add another map to this one
    const NXmap<T>& operator +=( const NXmap<T>& other );
    //! subtract another map from this one
    const NXmap<T>& operator -=( const NXmap<T>& other );

  private:
    std::vector<T> list;
  };



  // template fucntion definitions

  /*! Note that the higher the order of the interpolant, the more of
    the boundary of the map becomes inaccessible.
    \param cm The coord_map to test.
    \return true if interpolation can be performed at that coordinate. */
  template<class I> bool NXmap_base::in_map( const Coord_map& cm ) const
    { return I::can_interp( *this, cm ); }

  /*! Initialise an NXmap to some rhomboid chosen from within a crystal
    coordinate space, specified by the grid and a transformation from
    orthogonal to grid coordinates.
    \param grid The grid dimensions of the desired map.
    \param rt The rotation/transln op from orthogonal to grid coordinates. */
  template<class T> NXmap<T>::NXmap( const Grid& grid, const RTop<>& rt )
    { init( grid, rt ); }

  /*! Initialise an NXmap to some rhomboid chosen from within a crystal
    grid coordinate space, specified by a cell, sampling and box within
    that grid. This is useful for creating an NXmap which exactly
    matches some subregion of a crystallographic map.
    \param cell Unit cell defining the crystal space.
    \param grid The grid sampling of the given unit cell.
    \param grid_extent The map extent within that cell. */
  template<class T> NXmap<T>::NXmap( const Cell& cell, const Grid_sampling& grid, const Grid_range& grid_extent )
    { init( cell, grid, grid_extent ); }

  /*! Initialise an NXmap to some rhomboid chosen from within a crystal
    coordinate space, specified by the grid and a transformation from
    orthogonal to grid coordinates.
    \param grid The grid dimensions of the desired map.
    \param rt The rotation/transln op from orthogonal to grid coordinates. */
  template<class T> void NXmap<T>::init( const Grid& grid, const RTop<>& rt )
    { NXmap_base::init( grid, rt ); list.resize( grid.size() ); }

  /*! Initialise an NXmap to some rhomboid chosen from within a crystal
    grid coordinate space, specified by a cell, sampling and box within
    that grid. This is useful for creating an NXmap which exactly
    matches some subregion of a crystallographic map.
    \param cell Unit cell defining the crystal space.
    \param grid The grid sampling of the given unit cell.
    \param grid_extent The map extent within that cell. */
  template<class T> void NXmap<T>::init( const Cell& cell, const Grid_sampling& grid, const Grid_range& grid_extent )
    { NXmap_base::init( cell, grid, grid_extent ); list.resize( grid_extent.size() ); }


  /*! The value of the map at the desired non-grid map
    coordinate are calculated using
    the supplied interpolator template.
    \param pos The map coord at which the density is to be calcuated.
    \return The value of the density at that point.
    map coordinates (see Cell::coord_orth). */
  template<class T> template<class I> T NXmap<T>::interp( const Coord_map& pos ) const
  {
    T val;
    I::interp( *this, pos, val );
    return val;
  }


  /*! The value of the map at the desired non-grid map
    coordinate and its gradient are calculated using
    the supplied interpolator template.
    \param pos The map coord at which the density is to be calcuated.
    \param val The value of the density at that point.
    \param grad The interpolated gradient vector with respect to the
    map coordinates (see Cell::coord_orth).
    \param curv The interpolated curvature matrix with respect to the
    map coordinates (see Cell::coord_orth). */
  template<class T> template<class I> void NXmap<T>::interp_grad( const Coord_map& pos, T& val, Grad_map<T>& grad ) const
  {
    I::interp_grad( *this, pos, val, grad );
  }


  /*! The value of the map at the desired non-grid map
    coordinate and its gradient and curvature are calculated using
    the supplied interpolator template.
    \param pos The map coord at which the density is to be calcuated.
    \param val The value of the density at that point.
    \param grad The interpolated gradient vector with respect to the
    map coordinates (see Cell::coord_orth).
    \param curv The interpolated curvature matrix with respect to the
    map coordinates (see Cell::coord_orth). */
  template<class T> template<class I> void NXmap<T>::interp_curv( const Coord_map& pos, T& val, Grad_map<T>& grad, Curv_map<T>& curv ) const
  {
    I::interp_curv( *this, pos, val, grad, curv );
  }


  /*! All values, including missing values, are overwritten by the value.
    \param value The value to which the map is to be set. */
  template<class T> const T& NXmap<T>::operator =( const T& value )
  {
    // copy value into map
    Map_reference_index im;
    for ( im = first(); !im.last(); im.next() ) list[im.index()] = value;
    return value;
  }


  /*! The map grids must match. */
  template<class T> const NXmap<T>& NXmap<T>::operator +=( const NXmap<T>& other )
  {
    if ( grid() != other.grid() )
      Message::message( Message_fatal( "NXmap: map mismatch in +=" ) );
    Map_reference_index im;
    for ( im = first(); !im.last(); im.next() ) list[im.index()] += other[im];
    return (*this);
  }

  /*! The map grids must match. */
  template<class T> const NXmap<T>& NXmap<T>::operator -=( const NXmap<T>& other )
  {
    if ( grid() != other.grid() )
      Message::message( Message_fatal( "NXmap: map mismatch in -=" ) );
    Map_reference_index im;
    for ( im = first(); !im.last(); im.next() ) list[im.index()] -= other[im];
    return (*this);
  }


} // namespace clipper

#endif