This file is indexed.

/usr/include/trilinos/Sacado_Traits.hpp is in libtrilinos-sacado-dev 12.12.1-5.

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
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
// @HEADER
// ***********************************************************************
//
//                           Sacado Package
//                 Copyright (2006) Sandia Corporation
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
// USA
// Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
// (etphipp@sandia.gov).
//
// ***********************************************************************
//
// The forward-mode AD classes in Sacado are a derivative work of the
// expression template classes in the Fad package by Nicolas Di Cesare.
// The following banner is included in the original Fad source code:
//
// ************ DO NOT REMOVE THIS BANNER ****************
//
//  Nicolas Di Cesare <Nicolas.Dicesare@ann.jussieu.fr>
//  http://www.ann.jussieu.fr/~dicesare
//
//            CEMRACS 98 : C++ courses,
//         templates : new C++ techniques
//            for scientific computing
//
//********************************************************
//
//  NumericalTraits class to illustrate TRAITS
//
//********************************************************
// @HEADER

#ifndef SACADO_TRAITS_HPP
#define SACADO_TRAITS_HPP

#include "Sacado_ConfigDefs.h"
#include "Sacado_dummy_arg.hpp"
#include "Sacado_mpl_enable_if.hpp"
#include "Sacado_mpl_disable_if.hpp"
#include "Sacado_mpl_is_convertible.hpp"
#include "Sacado_mpl_is_same.hpp"
#include <string>

#ifdef HAVE_SACADO_COMPLEX
#include <complex>
#endif

namespace Sacado {

  /*!
   * \brief Enum use to signal whether the derivative array should be
   * initialized in AD object constructors.
   */
  enum DerivInit {
    NoInitDerivArray = 0, //!< Do not initialize the derivative array
    InitDerivArray        //!< Initialize the derivative array
  };

  //! Is a type an expression
  template <typename T>
  struct IsExpr {
    static const bool value = false;
  };

  //! Determine whether a given type is a view
  template <typename T>
  struct IsView {
    static const bool value = false;
  };

  //! Get the base Fad type from a view/expression
  template <typename T>
  struct BaseExprType {
    typedef T type;
  };

  //! Get view type for any Fad type
  template <typename T,unsigned,unsigned> struct ViewFadType {};

  //! Specialize this for a given type T to disable default Promote rules
  template <typename T> struct OverrideDefaultPromote {
    static const bool value = false;
  };

  //! Base template specification for %Promote
  /*!
   * The %Promote classes provide a mechanism for computing the
   * promoted type of a binary operation.
   */
  template <typename A, typename B, typename Enabled = void> struct Promote {};

  //! Specialization of %Promote for a single type
  template <typename A>
  struct Promote< A, A,
                  typename mpl::enable_if_c< !OverrideDefaultPromote<A>::value >::type > {
    typedef typename BaseExprType<A>::type type;
  };

  //! Specialization of %Promote when A is convertible to B but not vice-versa
  template <typename A, typename B>
  struct Promote< A, B,
                  typename mpl::enable_if_c< mpl::is_convertible<A,B>::value &&
                                            !mpl::is_convertible<B,A>::value &&
                                            !OverrideDefaultPromote<A>::value &&
                                            !OverrideDefaultPromote<B>::value
                                           >::type > {
    typedef typename BaseExprType<B>::type type;
  };

  //! Specialization of %Promote when B is convertible to A but not vice-versa
  template <typename A, typename B>
  struct Promote< A, B,
                  typename mpl::enable_if_c< mpl::is_convertible<B,A>::value &&
                                            !mpl::is_convertible<A,B>::value &&
                                            !OverrideDefaultPromote<A>::value &&
                                            !OverrideDefaultPromote<B>::value
                                           >::type > {
    typedef typename BaseExprType<A>::type type;
  };

 /*!
  * \brief Specialization of Promote when A and B are convertible to each
  * other, and one of them is an expression.
  */
  template <typename A, typename B>
  struct Promote< A, B,
                  typename mpl::enable_if_c< mpl::is_convertible<A,B>::value &&
                                             mpl::is_convertible<B,A>::value &&
                                             !mpl::is_same<A,B>::value &&
                                             ( IsExpr<A>::value ||
                                               IsExpr<B>::value ) >::type >
  {
    typedef typename BaseExprType<A>::type A_base_fad_type;
    typedef typename BaseExprType<B>::type B_base_fad_type;
    typedef typename Promote< A_base_fad_type, B_base_fad_type >::type type;
  };

  /*!
   * \brief Specialization of Promote when A is an expression and B is
   * convertible to its value-type, e.g., Promote< fad-expression, double >
   * (using BaseExprType to remove ViewFad)
   */
  template <typename A, typename B>
  struct Promote< A, B,
                  typename mpl::enable_if_c< !mpl::is_convertible<A,B>::value &&
                                             !mpl::is_convertible<B,A>::value &&
                                             IsExpr<A>::value &&
                                             mpl::is_convertible< B, typename BaseExprType< typename A::value_type >::type >::value
                                             >::type >
  {
    typedef typename BaseExprType<A>::type type;
  };

  /*!
   * \brief Specialization of Promote when B is an expression and A is
   * convertible to its value-type, e.g., Promote< double, fad-expression >
   * (using BaseExprType to remove ViewFad)
   */
  template <typename A, typename B>
  struct Promote< A, B,
                  typename mpl::enable_if_c< !mpl::is_convertible<A,B>::value &&
                                             !mpl::is_convertible<B,A>::value &&
                                             IsExpr<B>::value &&
                                              mpl::is_convertible< A, typename BaseExprType< typename B::value_type >::type >::value
                                             >::type >
  {
    typedef typename BaseExprType<B>::type type;
  };

  /*!
   * \brief Specialization of Promote when A and B are (different) expressions,
   * with the same value type, e.g, Promote< fad-expr1, fad-expr2 >
   * (using BaseExprType to remove ViewFad)
   */
  template <typename A, typename B>
  struct Promote< A, B,
                  typename mpl::enable_if_c< !mpl::is_convertible<A,B>::value &&
                                             !mpl::is_convertible<B,A>::value &&
                                             IsExpr<A>::value &&
                                             IsExpr<B>::value &&
                                             mpl::is_same< typename BaseExprType< typename A::value_type >::type,
                                                           typename BaseExprType< typename B::value_type >::type >::value
                                             >::type >
  {
    typedef typename BaseExprType<A>::type A_base_expr_type;
    typedef typename BaseExprType<B>::type B_base_expr_type;
    typedef typename Promote< A_base_expr_type, B_base_expr_type >::type type;
  };

  //! Specialization of %Promote to builtin types
#define SACADO_PROMOTE_SPECIALIZATION(type1,type2,type3)   \
  template <> struct Promote< type1, type2, void > {       \
    typedef type3 type;                                    \
  };                                                       \
  template <> struct Promote< type2, type1, void > {       \
    typedef type3 type;                                    \
  };

  SACADO_PROMOTE_SPECIALIZATION(double,float,double)
  SACADO_PROMOTE_SPECIALIZATION(double,long,double)
  SACADO_PROMOTE_SPECIALIZATION(double,int,double)
  SACADO_PROMOTE_SPECIALIZATION(float,long,float)
  SACADO_PROMOTE_SPECIALIZATION(float,int,float)
#ifdef HAVE_SACADO_COMPLEX
  SACADO_PROMOTE_SPECIALIZATION(std::complex<double>,std::complex<float>,std::complex<double>)
  SACADO_PROMOTE_SPECIALIZATION(std::complex<double>,double,std::complex<double>)
  SACADO_PROMOTE_SPECIALIZATION(std::complex<double>,float,std::complex<double>)
  SACADO_PROMOTE_SPECIALIZATION(std::complex<double>,long,std::complex<double>)
  SACADO_PROMOTE_SPECIALIZATION(std::complex<double>,int,std::complex<double>)
  SACADO_PROMOTE_SPECIALIZATION(std::complex<float>,float,std::complex<float>)
  SACADO_PROMOTE_SPECIALIZATION(std::complex<float>,long,std::complex<float>)
  SACADO_PROMOTE_SPECIALIZATION(std::complex<float>,int,std::complex<float>)
#endif // HAVE_SACADO_COMPLEX

#undef SACADO_PROMOTE_SPECIALIZATION

   // Macros for building proper Promote specialization for AD types

#define SACADO_AD_PROMOTE_SPEC(NS, AD) /* */

#define SACADO_AD_PROMOTE_SPEC2(NS, AD) /* */

#define SACADO_FAD_PROMOTE_SPEC(NS, FAD) /* */

#define SACADO_SFAD_PROMOTE_SPEC(NS, FAD) /* */

#define SACADO_EXPR_PROMOTE_SPEC(NS) /* */

#define SACADO_VFAD_PROMOTE_SPEC(NS) /* */

#define SACADO_RAD_PROMOTE_SPEC(NS)                                     \
  namespace NS {                                                        \
    template <typename> class ADvar;                                    \
    template <typename> class ADvari;                                   \
  }                                                                     \
  template <typename T>                                                 \
  struct OverrideDefaultPromote< NS :: ADvari <T>& > {                  \
    static const bool value = true;                                     \
  };                                                                    \
  template <typename T>                                                 \
  struct Promote< NS :: ADvar <T>,                                      \
                  NS :: ADvari <T>& > {                                 \
    typedef NS :: ADvar <T> type;                                       \
  };                                                                    \
  template <typename T>                                                 \
  struct Promote< NS :: ADvari <T>&,                                    \
                  NS :: ADvar <T> > {                                   \
    typedef NS :: ADvar <T> type;                                       \
  };                                                                    \
  template <typename T>                                                 \
  struct Promote< NS :: ADvari <T>&,                                    \
                  typename NS :: ADvari <T>::value_type > {             \
    typedef NS :: ADvar <T> type;                                       \
  };                                                                    \
  template <typename T>                                                 \
  struct Promote< typename NS :: ADvari <T>::value_type,                \
                  NS :: ADvari <T>& > {                                 \
    typedef NS :: ADvar <T> type;                                       \
  };                                                                    \
  template <typename T>                                                 \
  struct Promote< NS :: ADvari <T>&,                                    \
                  typename dummy< typename NS :: ADvari <T>::value_type, \
                                  typename NS :: ADvari <T>::scalar_type \
                                  >::type > {                           \
    typedef NS :: ADvar <T> type;                                       \
  };                                                                    \
  template <typename T>                                                 \
  struct Promote< typename dummy< typename NS :: ADvari <T>::value_type, \
                                  typename NS :: ADvari <T>::scalar_type \
                                  >::type,                              \
                  NS :: ADvari <T>& > {                                 \
    typedef NS :: ADvar <T> type;                                       \
  };

  //
  // We define defaults for all of the traits to make Sacado easier to use.
  // The default choices are based on what appears to be the "safest" choice
  // for any scalar type.  They may not work in all cases, in which case a
  // specialization should be provided.
  //

  //! Base template specification for %ScalarType
  /*!
   * The %ScalarType classes provide a mechanism for computing the
   * base underlying type of nested AD classes
   */
  template <typename T> struct ScalarType {
    typedef T type;
  };

  //! Specialization of %ScalarType for const types
  /*!
   * This should work for most types
   */
  template <typename T> struct ScalarType<const T> {
    typedef const typename ScalarType<T>::type type;
  };

  //! Base template specification for %ValueType
  /*!
   * The %ValueType classes provide a mechanism for computing the
   * the type stored in AD classes
   */
  template <typename T> struct ValueType {
    typedef T type;
  };

  //! Specialization of %ValueType for const types
  /*!
   * This should work for most types
   */
  template <typename T> struct ValueType<const T> {
    typedef const typename ValueType<T>::type type;
  };

  //! Base template specification for %IsADType
  /*!
   * The %IsADType classes provide a mechanism for computing the
   * determining whether a type is an AD type
   */
  template <typename T> struct IsADType {
    static const bool value = false;
  };

  //! Base template specification for %IsScalarType
  /*!
   * The %IsScalarType classes provide a mechanism for computing the
   * determining whether a type is a scalar type (float, double, etc...)
   */
  template <typename T> struct IsScalarType {
    static const bool value = false;
  };

  //! Base template specification for %Value
  /*!
   * The %Value functor returns the value of an AD type.
   */
  template <typename T> struct Value {
    KOKKOS_INLINE_FUNCTION
    static const T& eval(const T& x) { return x; }
  };

  //! Base template specification for %ScalarValue
  /*!
   * The %ScalarValue functor returns the base scalar value of an AD type,
   * i.e., something that isn't an AD type.
   */
  template <typename T> struct ScalarValue {
    KOKKOS_INLINE_FUNCTION
    static const T& eval(const T& x) { return x; }
  };

  //! Base template specification for marking constants
  template <typename T> struct MarkConstant {
    KOKKOS_INLINE_FUNCTION
    static void eval(T& x) {}
  };

  //! Base template specification for string names of types
  template <typename T> struct StringName {
    static std::string eval() { return ""; }
  };

  //! Base template specification for testing equivalence
  template <typename T> struct IsEqual {
    KOKKOS_INLINE_FUNCTION
    static bool eval(const T& x, const T& y) { return x == y; }
  };

  //! Base template specification for testing whether type is statically sized
  template <typename T> struct IsStaticallySized {
    static const bool value = false;
  };

  //! Specialization of %IsStaticallySized for const types
  /*!
   * This should work for most types
   */
  template <typename T> struct IsStaticallySized<const T> {
    static const bool value = IsStaticallySized<T>::value;
  };

  //! Base template specification for static size
  template <typename T> struct StaticSize {
    static const unsigned value = 0;
  };

  //! Base template specification for whether a type is a Fad type
  template <typename T> struct IsFad {
    static const bool value = false;
  };

  //! Remove const from a type
  template <typename T>
  struct RemoveConst {
    typedef T type;
  };

  //! Remove const from a type
  template <typename T>
  struct RemoveConst< const T > {
    typedef T type;
  };

  //! Specialization of above classes to builtin types
#define SACADO_BUILTIN_SPECIALIZATION(t,NAME)             \
  template <> struct ScalarType< t > {                    \
    typedef t type;                                       \
  };                                                      \
  template <> struct ValueType< t > {                     \
    typedef t type;                                       \
  };                                                      \
  template <> struct IsADType< t > {                      \
    static const bool value = false;                      \
  };                                                      \
  template <> struct IsScalarType< t > {                  \
    static const bool value = true;                       \
  };                                                      \
  template <> struct Value< t > {                         \
    KOKKOS_INLINE_FUNCTION                                \
    static const t& eval(const t& x) { return x; }        \
  };                                                      \
  template <> struct ScalarValue< t > {                   \
    KOKKOS_INLINE_FUNCTION                                \
    static const t& eval(const t& x) { return x; }        \
  };                                                      \
  template <> struct StringName< t > {                    \
    static std::string eval() { return NAME; }            \
  };                                                      \
  template <> struct IsEqual< t > {                       \
    KOKKOS_INLINE_FUNCTION                                \
    static bool eval(const t& x, const t& y) {            \
      return x == y; }                                    \
  };                                                      \
  template <> struct IsStaticallySized< t > {             \
    static const bool value = true;                       \
  };

#define SACADO_BUILTIN_SPECIALIZATION_COMPLEX(t,NAME)     \
  template <> struct ScalarType< t > {                    \
    typedef t type;                                       \
  };                                                      \
  template <> struct ValueType< t > {                     \
    typedef t type;                                       \
  };                                                      \
  template <> struct IsADType< t > {                      \
    static const bool value = false;                      \
  };                                                      \
  template <> struct IsScalarType< t > {                  \
    static const bool value = true;                       \
  };                                                      \
  template <> struct Value< t > {                         \
    static const t& eval(const t& x) { return x; }        \
  };                                                      \
  template <> struct ScalarValue< t > {                   \
    static const t& eval(const t& x) { return x; }        \
  };                                                      \
  template <> struct StringName< t > {                    \
    static std::string eval() { return NAME; }            \
  };                                                      \
  template <> struct IsEqual< t > {                       \
    static bool eval(const t& x, const t& y) {            \
      return x == y; }                                    \
  };                                                      \
  template <> struct IsStaticallySized< t > {             \
    static const bool value = true;                       \
  };

  SACADO_BUILTIN_SPECIALIZATION(char,"char")
  SACADO_BUILTIN_SPECIALIZATION(float,"float")
  SACADO_BUILTIN_SPECIALIZATION(double,"double")
  SACADO_BUILTIN_SPECIALIZATION(int,"int")
  SACADO_BUILTIN_SPECIALIZATION(unsigned int,"unsigned int")
  SACADO_BUILTIN_SPECIALIZATION(long,"long")
  SACADO_BUILTIN_SPECIALIZATION(unsigned long,"unsigned long")
  SACADO_BUILTIN_SPECIALIZATION(bool,"bool")
#ifdef HAVE_SACADO_COMPLEX
  SACADO_BUILTIN_SPECIALIZATION_COMPLEX(std::complex<double>,"std::complex<double>")
  SACADO_BUILTIN_SPECIALIZATION_COMPLEX(std::complex<float>,"std::complex<float>")
#endif

#undef SACADO_BUILTIN_SPECIALIZATION
#undef SACADO_BUILTIN_SPECIALIZATION_COMPLEX

template< typename T , T v , bool NonZero = ( v != T(0) ) >
struct integral_nonzero
{
  // Declaration of 'static const' causes an unresolved linker symbol in debug
  // static const T value = v ;
  enum { value = T(v) };
  typedef T value_type ;
  typedef integral_nonzero<T,v> type ;
  KOKKOS_INLINE_FUNCTION integral_nonzero() {}
  KOKKOS_INLINE_FUNCTION integral_nonzero( const T & ) {}
  KOKKOS_INLINE_FUNCTION integral_nonzero( const integral_nonzero & ) {}
  KOKKOS_INLINE_FUNCTION integral_nonzero& operator=(const integral_nonzero &) {return *this;}
  KOKKOS_INLINE_FUNCTION integral_nonzero& operator=(const T &) {return *this;}
};

template< typename T , T zero >
struct integral_nonzero<T,zero,false>
{
  T value ;
  typedef T value_type ;
  typedef integral_nonzero<T,0> type ;
  KOKKOS_INLINE_FUNCTION integral_nonzero() : value() {}
  KOKKOS_INLINE_FUNCTION integral_nonzero( const T & v ) : value(v) {}
  KOKKOS_INLINE_FUNCTION integral_nonzero( const integral_nonzero & v) : value(v.value) {}
  KOKKOS_INLINE_FUNCTION integral_nonzero& operator=(const integral_nonzero & v) { value = v.value; return *this; }
  KOKKOS_INLINE_FUNCTION integral_nonzero& operator=(const T & v) { value = v; return *this; }
};

} // namespace Sacado

#endif // SACADO_TRAITS_HPP