This file is indexed.

/usr/include/TiledArray/expressions/mult_engine.h is in libtiledarray-dev 0.4.4-1.

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
/*
 *  This file is a part of TiledArray.
 *  Copyright (C) 2014  Virginia Tech
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  Justus Calvin
 *  Department of Chemistry, Virginia Tech
 *
 *  mult_engine.h
 *  Mar 31, 2014
 *
 */

#ifndef TILEDARRAY_EXPRESSIONS_MULT_ENGINE_H__INCLUDED
#define TILEDARRAY_EXPRESSIONS_MULT_ENGINE_H__INCLUDED

#include <TiledArray/expressions/cont_engine.h>
#include <TiledArray/tile_op/mult.h>
#include <TiledArray/tile_op/scal_mult.h>


namespace TiledArray {
  namespace expressions {

    // Forward declarations
    template <typename, typename> class MultExpr;
    template <typename, typename> class ScalMultExpr;
    template <typename, typename> class MultEngine;
    template <typename, typename> class ScalMultEngine;

    template <typename Left, typename Right>
    struct EngineTrait<MultEngine<Left, Right> > :
      public BinaryEngineTrait<Left, Right, TiledArray::math::Mult>
    { };

    template <typename Left, typename Right>
    struct EngineTrait<ScalMultEngine<Left, Right> > :
      public BinaryEngineTrait<Left, Right, TiledArray::math::ScalMult>
    { };


    /// Multiplication expression engine

    /// \tparam Left The left-hand engine type
    /// \tparam Right The Right-hand engine type
    template <typename Left, typename Right>
    class MultEngine : public ContEngine<MultEngine<Left, Right> > {
    public:
      // Class hierarchy typedefs
      typedef MultEngine<Left, Right> MultEngine_; ///< This class type
      typedef ContEngine<MultEngine_> ContEngine_; ///< Contraction engine base class
      typedef BinaryEngine<MultEngine_> BinaryEngine_; ///< Binary base class type
      typedef BinaryEngine<MultEngine_> ExprEngine_; ///< Expression engine base class type

      // Argument typedefs
      typedef typename EngineTrait<MultEngine_>::left_type left_type; ///< The left-hand expression type
      typedef typename EngineTrait<MultEngine_>::right_type right_type; ///< The right-hand expression type

      // Operational typedefs
      typedef typename EngineTrait<MultEngine_>::value_type value_type; ///< The result tile type
      typedef typename EngineTrait<MultEngine_>::scalar_type scalar_type; ///< Tile scalar type
      typedef typename EngineTrait<MultEngine_>::op_type op_type; ///< The tile operation type
      typedef typename EngineTrait<MultEngine_>::policy policy; ///< The result policy type
      typedef typename EngineTrait<MultEngine_>::dist_eval_type dist_eval_type; ///< The distributed evaluator type

      // Meta data typedefs
      typedef typename EngineTrait<MultEngine_>::size_type size_type; ///< Size type
      typedef typename EngineTrait<MultEngine_>::trange_type trange_type; ///< Tiled range type
      typedef typename EngineTrait<MultEngine_>::shape_type shape_type; ///< Shape type
      typedef typename EngineTrait<MultEngine_>::pmap_interface pmap_interface; ///< Process map interface type

    private:

      bool contract_; ///< Expression type flag (true == contraction, false ==
                      ///< coefficent-wise multiplication)

    public:

      /// Constructor

      /// \tparam L The left-hand argument expression type
      /// \tparam R The right-hand argument expression type
      /// \param expr The parent expression
      template <typename L, typename R>
      MultEngine(const MultExpr<L, R>& expr) : ContEngine_(expr), contract_(false) { }


      /// Set the variable list for this expression

      /// This function will set the variable list for this expression and its
      /// children such that the number of permutations is minimized. The final
      /// variable list may not be set to target, which indicates that the
      /// result of this expression will be permuted to match \c target_vars.
      /// \param target_vars The target variable list for this expression
      void perm_vars(const VariableList& target_vars) {
        if(contract_)
          ContEngine_::perm_vars(target_vars);
        else {
          BinaryEngine_::perm_vars(target_vars);
        }
      }

      /// Set the variable list for this expression

      /// This function will set the variable list for this expression and its
      /// children such that the number of permutations is minimized.
      void perm_vars() {
        if(contract_)
          ContEngine_::perm_vars();
        else {
          BinaryEngine_::perm_vars();
        }
      }

      /// Initialize the variable list of this expression

      /// \param target_vars The target variable list for this expression
      void init_vars(const VariableList& target_vars) {
        BinaryEngine_::left_.init_vars();
        BinaryEngine_::right_.init_vars();

        if(BinaryEngine_::left_.vars().is_permutation(BinaryEngine_::right_.vars())) {
          BinaryEngine_::perm_vars(target_vars);
        } else {
          contract_ = true;
          ContEngine_::init_vars();
          ContEngine_::perm_vars(target_vars);
        }
      }

      /// Initialize the variable list of this expression
      void init_vars() {
        BinaryEngine_::left_.init_vars();
        BinaryEngine_::right_.init_vars();

        if(BinaryEngine_::left_.vars().is_permutation(BinaryEngine_::right_.vars())) {
          BinaryEngine_::init_vars();
        } else {
          contract_ = true;
          ContEngine_::init_vars();
        }
      }

      /// Initialize result tensor structure

      /// This function will initialize the permutation, tiled range, and shape
      /// for the result tensor.
      /// \param target_vars The target variable list for the result tensor
      void init_struct(const VariableList& target_vars) {
        if(contract_)
          ContEngine_::init_struct(target_vars);
        else
          BinaryEngine_::init_struct(target_vars);
      }

      /// Initialize result tensor distribution

      /// This function will initialize the world and process map for the result
      /// tensor.
      /// \param world The world were the result will be distributed
      /// \param pmap The process map for the result tensor tiles
      void init_distribution(World* world, std::shared_ptr<pmap_interface> pmap) {
        if(contract_)
          ContEngine_::init_distribution(world, pmap);
        else
          BinaryEngine_::init_distribution(world, pmap);
      }

      /// Non-permuting tiled range factory function

      /// \return The result tiled range object
      trange_type make_trange() const {
        if(contract_)
          return ContEngine_::make_trange();
        else
          return BinaryEngine_::make_trange();
      }

      /// Permuting tiled range factory function

      /// \param perm The permutation to be applied to the array
      /// \return The result tiled range object
      trange_type make_trange(const Permutation& perm) const {
        if(contract_)
          return ContEngine_::make_trange(perm);
        else
          return BinaryEngine_::make_trange(perm);
      }

      /// Non-permuting shape factory function

      /// \return The result shape
      shape_type make_shape() const {
        return BinaryEngine_::left_.shape().mult(BinaryEngine_::right_.shape());
      }

      /// Permuting shape factory function

      /// \param perm The permutation to be applied to the array
      /// \return The result shape
      shape_type make_shape(const Permutation& perm) const {
        return BinaryEngine_::left_.shape().mult(BinaryEngine_::right_.shape(), perm);
      }

      /// Non-permuting tile operation factory function

      /// \return The tile operation
      static op_type make_tile_op() { return op_type(); }

      /// Permuting tile operation factory function

      /// \param perm The permutation to be applied to tiles
      /// \return The tile operation
      static op_type make_tile_op(const Permutation& perm) { return op_type(perm); }

      /// Construct the distributed evaluator for this expression

      /// \return The distributed evaluator that will evaluate this expression
      dist_eval_type make_dist_eval() const {
        if(contract_)
          return ContEngine_::make_dist_eval();
        else
          return BinaryEngine_::make_dist_eval();
      }

      /// Expression identification tag

      /// \return An expression tag used to identify this expression
      const char* make_tag() const { return "[*] "; }

      /// Expression print

      /// \param os The output stream
      /// \param target_vars The target variable list for this expression
      void print(ExprOStream os, const VariableList& target_vars) const {
        if(contract_)
          return ContEngine_::print(os, target_vars);
        else
          return BinaryEngine_::print(os, target_vars);
      }

    }; // class MultEngine


    /// Scaled multiplication expression engine

    /// \tparam Left The left-hand engine type
    /// \tparam Right The Right-hand engine type
    template <typename Left, typename Right>
    class ScalMultEngine : public ContEngine<ScalMultEngine<Left, Right> > {
    public:
      // Class hierarchy typedefs
      typedef ScalMultEngine<Left, Right> ScalMultEngine_; ///< This class type
      typedef ContEngine<ScalMultEngine_> ContEngine_; ///< Contraction engine base class
      typedef BinaryEngine<ScalMultEngine_> BinaryEngine_; ///< Binary base class type
      typedef BinaryEngine<ScalMultEngine_> ExprEngine_; ///< Expression engine base class type

      // Argument typedefs
      typedef typename EngineTrait<ScalMultEngine_>::left_type left_type; ///< The left-hand expression type
      typedef typename EngineTrait<ScalMultEngine_>::right_type right_type; ///< The right-hand expression type

      // Operational typedefs
      typedef typename EngineTrait<ScalMultEngine_>::value_type value_type; ///< The result tile type
      typedef typename EngineTrait<ScalMultEngine_>::scalar_type scalar_type; ///< Tile scalar type
      typedef typename EngineTrait<ScalMultEngine_>::op_type op_type; ///< The tile operation type
      typedef typename EngineTrait<ScalMultEngine_>::policy policy; ///< The result policy type
      typedef typename EngineTrait<ScalMultEngine_>::dist_eval_type dist_eval_type; ///< The distributed evaluator type

      // Meta data typedefs
      typedef typename EngineTrait<ScalMultEngine_>::size_type size_type; ///< Size type
      typedef typename EngineTrait<ScalMultEngine_>::trange_type trange_type; ///< Tiled range type
      typedef typename EngineTrait<ScalMultEngine_>::shape_type shape_type; ///< Shape type
      typedef typename EngineTrait<ScalMultEngine_>::pmap_interface pmap_interface; ///< Process map interface type

    private:

      bool contract_; ///< Expression type flag (true == contraction, false ==
                      ///< coefficent-wise multiplication)

    public:

      /// Constructor

      /// \tparam L The left-hand argument expression type
      /// \tparam R The right-hand argument expression type
      /// \param expr The parent expression
      template <typename L, typename R>
      ScalMultEngine(const ScalMultExpr<L, R>& expr) : ContEngine_(expr), contract_(false) { }

      /// Set the variable list for this expression

      /// This function will set the variable list for this expression and its
      /// children such that the number of permutations is minimized. The final
      /// variable list may not be set to target, which indicates that the
      /// result of this expression will be permuted to match \c target_vars.
      /// \param target_vars The target variable list for this expression
      void perm_vars(const VariableList& target_vars) {
        if(contract_)
          ContEngine_::perm_vars(target_vars);
        else {
          BinaryEngine_::perm_vars(target_vars);
        }
      }

      /// Set the variable list for this expression

      /// This function will set the variable list for this expression and its
      /// children such that the number of permutations is minimized.
      void perm_vars() {
        if(contract_)
          ContEngine_::perm_vars();
        else {
          BinaryEngine_::perm_vars();
        }
      }

      /// Initialize the variable list of this expression

      /// \param target_vars The target variable list for this expression
      void init_vars(const VariableList& target_vars) {
        BinaryEngine_::left_.init_vars();
        BinaryEngine_::right_.init_vars();

        if(BinaryEngine_::left_.vars().is_permutation(BinaryEngine_::right_.vars())) {
          BinaryEngine_::perm_vars(target_vars);
        } else {
          contract_ = true;
          ContEngine_::init_vars();
          ContEngine_::perm_vars(target_vars);
        }
      }

      /// Initialize the variable list of this expression
      void init_vars() {
        BinaryEngine_::left_.init_vars();
        BinaryEngine_::right_.init_vars();

        if(BinaryEngine_::left_.vars().is_permutation(BinaryEngine_::right_.vars())) {
          if(left_type::leaves <= right_type::leaves)
            ExprEngine_::vars_ = BinaryEngine_::left_.vars();
          else
            ExprEngine_::vars_ = BinaryEngine_::right_.vars();
        } else {
          contract_ = true;
          ContEngine_::init_vars();
        }
      }

      /// Initialize result tensor structure

      /// This function will initialize the permutation, tiled range, and shape
      /// for the result tensor.
      /// \param target_vars The target variable list for the result tensor
      void init_struct(const VariableList& target_vars) {
        if(contract_)
          ContEngine_::init_struct(target_vars);
        else
          BinaryEngine_::init_struct(target_vars);
      }

      /// Initialize result tensor distribution

      /// This function will initialize the world and process map for the result
      /// tensor.
      /// \param world The world were the result will be distributed
      /// \param pmap The process map for the result tensor tiles
      void init_distribution(World* world, std::shared_ptr<pmap_interface> pmap) {
        if(contract_)
          ContEngine_::init_distribution(world, pmap);
        else
          BinaryEngine_::init_distribution(world, pmap);
      }

      /// Construct the distributed evaluator for this expression

      /// \return The distributed evaluator that will evaluate this expression
      dist_eval_type make_dist_eval() const {
        if(contract_)
          return ContEngine_::make_dist_eval();
        else
          return BinaryEngine_::make_dist_eval();
      }

      /// Non-permuting tiled range factory function

      /// \return The result tiled range object
      trange_type make_trange() const {
        if(contract_)
          return ContEngine_::make_trange();
        else
          return BinaryEngine_::make_trange();
      }

      /// Permuting tiled range factory function

      /// \param perm The permutation to be applied to the array
      /// \return The result tiled range object
      trange_type make_trange(const Permutation& perm) const {
        if(contract_)
          return ContEngine_::make_trange(perm);
        else
          return BinaryEngine_::make_trange(perm);
      }

      /// Non-permuting shape factory function

      /// \return The result shape
      shape_type make_shape() const {
        return BinaryEngine_::left_.shape().mult(BinaryEngine_::right_.shape(),
            ContEngine_::factor_);
      }

      /// Permuting shape factory function

      /// \param perm The permutation to be applied to the array
      /// \return The result shape
      shape_type make_shape(const Permutation& perm) const {
        return BinaryEngine_::left_.shape().mult(BinaryEngine_::right_.shape(),
            ContEngine_::factor_, perm);
      }

      /// Non-permuting tile operation factory function

      /// \return The tile operation
      op_type make_tile_op() const { return op_type(ContEngine_::factor_); }

      /// Permuting tile operation factory function

      /// \param perm The permutation to be applied to tiles
      /// \return The tile operation
      op_type make_tile_op(const Permutation& perm) const {
        return op_type(perm, ContEngine_::factor_);
      }



      /// Expression identification tag

      /// \return An expression tag used to identify this expression
      std::string make_tag() const {
        std::stringstream ss;
        ss << "[*] [" << ContEngine_::factor_ << "] ";
        return ss.str();
      }

      /// Expression print

      /// \param os The output stream
      /// \param target_vars The target variable list for this expression
      void print(ExprOStream os, const VariableList& target_vars) const {
        if(contract_)
          return ContEngine_::print(os, target_vars);
        else
          return BinaryEngine_::print(os, target_vars);
      }

    }; // class ScalMultEngine

  }  // namespace expressions
} // namespace TiledArray

#endif // TILEDARRAY_EXPRESSIONS_MULT_ENGINE_H__INCLUDED