This file is indexed.

/usr/include/trilinos/IterationPack_IterQuantityAccessContiguousDef.hpp is in libtrilinos-dev 10.4.0.dfsg-1ubuntu2.

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
// @HEADER
// ***********************************************************************
// 
// Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
//                  Copyright (2003) Sandia Corporation
// 
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
// 
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//  
// This library 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
// Lesser General Public License for more details.
//  
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA
// Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
// 
// ***********************************************************************
// @HEADER
//
// Definitions to template functions

#ifndef ITER_QUANITY_ACCESS_CONTINUOUS_DEF_H
#define ITER_QUANITY_ACCESS_CONTINUOUS_DEF_H

#include <typeinfo>
#include <algorithm>
#include <iterator>

#include "IterationPack_IterQuantityAccessContiguousDecl.hpp"
#include "Teuchos_TestForException.hpp"

namespace IterationPack {

// Constructors/initializers

template<class T_info>
IterQuantityAccessContiguous<T_info>::IterQuantityAccessContiguous(
  int                              num_quantities
  ,const std::string&              name
  ,const abstract_factory_ptr_t&   abstract_factory
  )
  :num_quantities_(0)
  ,name_(name)
  ,abstract_factory_(abstract_factory)
  ,max_offset_(0)
{
  resize( num_quantities );
}

template<class T_info>
IterQuantityAccessContiguous<T_info>::~IterQuantityAccessContiguous() {
  release_mem();
}

template<class T_info>
void IterQuantityAccessContiguous<T_info>::set_factory(
  const abstract_factory_ptr_t& abstract_factory
  )
{
  release_mem();
  abstract_factory_ = abstract_factory;
  max_offset_ = std::numeric_limits<int>::min() + num_quantities_;  // uninitialized
  // ToDo: Don't wipe out storage, just reallocate new objects
  // as iteration quantities are updated.  This will take a little bit of
  // work and more overhead but it should be worth it in some types of
  // applications.
}

template<class T_info>
void IterQuantityAccessContiguous<T_info>::resize( int num_quantities ) {
  TEST_FOR_EXCEPTION(
    num_quantities < 1, std::length_error
    ,"IterQuantityAccessContiguous::resize(num_quantities): Error, "
    "name = "<<name_<<", num_quantities = "<<num_quantities<<" must be greater than zero" );
  if( num_quantities_ != num_quantities )
    release_mem();
  num_quantities_ = num_quantities;
  max_offset_ = std::numeric_limits<int>::min() + num_quantities_; // uninitialized
}

// Overridden from IterQuantity

template<class T_info>
IterQuantity* IterQuantityAccessContiguous<T_info>::clone() const {
  return 0;
  // ToDo: replace above with the following when the copy
  // constructor is implemented.
  // return new IterQuantityAccessContiguous<T_info>(*this);
}

template<class T_info>
const char* IterQuantityAccessContiguous<T_info>::name() const {
  return name_.c_str();
}

template<class T_info>
bool IterQuantityAccessContiguous<T_info>::has_storage_k(int offset) const {
  return is_initialized()
    ? offset >= max_offset_ - num_quantities_ + 1
    : true;
}

template<class T_info>
bool IterQuantityAccessContiguous<T_info>::updated_k(int offset) const {
  if( !is_initialized() )
    return false;
  if( ( offset > max_offset_ ) || ( offset < max_offset_ - num_quantities_ + 1 ) )
    return false;
  return updated_[max_offset_ - offset];
}

template<class T_info>
int IterQuantityAccessContiguous<T_info>::last_updated() const {
  if( !is_initialized() )
    return base_t::NONE_UPDATED;
  // Find the last still set as updated.
  for(	int offset = max_offset_;
      offset >= max_offset_ - num_quantities_ + 1;
      --offset										)
  {
    if( updated_[max_offset_ - offset] )
      return offset;
  }
  return base_t::NONE_UPDATED;
}

template<class T_info>
void IterQuantityAccessContiguous<T_info>::set_not_updated_k(int offset) {
  this->assert_updated_k(offset);
  updated_[max_offset_ - offset] = false;
}

template<class T_info>
void IterQuantityAccessContiguous<T_info>::set_all_not_updated() {
  if(!is_initialized()) return;
  std::fill( updated_.begin(), updated_.end(), false );
}

template<class T_info>
bool IterQuantityAccessContiguous<T_info>::will_loose_mem(int offset, int set_offset) const {
  this->assert_updated_k(offset);
  return set_offset - max_offset_ > num_quantities_ - (max_offset_ - offset) - 1;
}

template<class T_info>
void IterQuantityAccessContiguous<T_info>::next_iteration()
{
  if( !is_initialized() ) return;
  --max_offset_;
}

template<class T_info>
void IterQuantityAccessContiguous<T_info>::print_concrete_type( std::ostream& out ) const
{
  const int last_updated = this->last_updated();
  if(last_updated != base_t::NONE_UPDATED)
    out << typeName(get_k(last_updated));
  else if( abstract_factory_.get() == NULL )
    out << "NULL";
  else
    out << typeName(*abstract_factory_->create());
}

// Overridden from IterQuantityAccess

template<class T_info>
T_info& IterQuantityAccessContiguous<T_info>::get_k(int offset) {
  this->assert_updated_k(offset);
  return *quantities_[max_offset_ - offset];
}
template<class T_info>
const T_info& IterQuantityAccessContiguous<T_info>::get_k(int offset) const {
  this->assert_updated_k(offset);
  return *quantities_[max_offset_ - offset];
}

template<class T_info>
T_info& IterQuantityAccessContiguous<T_info>::set_k(int offset) {

  lazy_initialization();

  this->assert_has_storage_k(offset);	// assert that we are not trying to iterate backwards

  if(offset > max_offset_ + num_quantities_ - 1) {
    // There will be no back memory so you don't need to adjust the pointers
    max_offset_ = offset;
    std::fill(updated_.begin(), updated_.end(), false);
  }
  else {
    // Pointers may have to be rearranged
    if(offset > max_offset_) {
      // We need to rearrange quantities_ and updated_.
      int shifted = offset - max_offset_;

      // ///////////////////////////////////
      // Set the updated flags

      // Example: We are shifting from:
      //		[1, 0, -1, -2] to [ 3, 2, 1, 0 ]

      // Shift the flags for the memory that may be saved
      updated_t::iterator
        itr_updated_from        = updated_.begin(),
        itr_updated_from_end    = itr_updated_from + num_quantities_ - shifted,
        itr_updated_to          = itr_updated_from + shifted;

      std::copy(itr_updated_from, itr_updated_from_end, itr_updated_to);

      // make updated[] for the new quantities false
      std::fill_n( updated_.begin(), shifted, false );

      // /////////////////////////////////////
      // rotate the quantitiy pointer vector

      // example: [1, 0, -1, -2] => [3, 2, 1, 0] so reverse rotate 0 to the back.

      // Rotate the (num_quantities_ - shifted) pointer to the back and the
      // remainder back arround again.

#if defined(_INTEL_CXX)
      typedef std::reverse_iterator<T_info**, T_info*, T_info*&
        , T_info**, ptrdiff_t>									rev_t;
#else
      typedef std::reverse_iterator<T_info**>						rev_t;
#endif

      std::rotate(
          rev_t(&quantities_[0] + num_quantities_)
        , rev_t(&quantities_[0] + num_quantities_ - shifted)
        , rev_t(&quantities_[0])                              );

      max_offset_ = offset;

    }
    // else, no pointers need to be rearranged since we are not advancing the range
  }

  updated_[max_offset_ - offset] = true;
  return *quantities_[max_offset_ - offset];
}

template<class T_info>
T_info& IterQuantityAccessContiguous<T_info>::set_k(int set_offset, int get_offset) {
  T_info& iq = this->get_k(get_offset);   // May throw exception
  return this->set_k(set_offset) = iq;    // ""
}

// Private member functions

template<class T_info>
bool IterQuantityAccessContiguous<T_info>::is_initialized() const {
  return store_.size() > 0;
}

template<class T_info>
void IterQuantityAccessContiguous<T_info>::lazy_initialization() {
  if( !is_initialized() ) {
    TEST_FOR_EXCEPTION(
      abstract_factory_.get() == NULL, std::logic_error
      ,"IterQuantityAccessContiguous::lazy_initialization(): Error, "
      "iq_name = "<<name_<<" the abstract factory can not be NULL" );
    // Allocate storage
    updated_.resize(num_quantities_,false);
    store_.resize(num_quantities_);
    quantities_.resize(num_quantities_,NULL);
    // Set initial points to locations
    typename updated_t::iterator       itr_updated         = updated_.begin();
    typename store_t::iterator         itr_store           = store_.begin();
    typename quantities_t::iterator    itr_quantities      = quantities_.begin();
    for( ; itr_store != store_.end(); ++itr_updated, ++itr_store, ++itr_quantities )
    {
      *itr_updated     = false;
      *itr_store       = abstract_factory_->create();
      *itr_quantities  = itr_store->get();
    }
    max_offset_ = std::numeric_limits<int>::min() + num_quantities_ + 1;
  }
}

template<class T_info>
void IterQuantityAccessContiguous<T_info>::release_mem() {
  updated_.resize(0);
  store_.resize(0);
  quantities_.resize(0);
}

}	// end namespace IterationPack

#endif	// ITER_QUANITY_ACCESS_CONTINUOUS_DEF_H