Hammer  1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IContainer.hh
Go to the documentation of this file.
1 ///
2 /// @file IContainer.hh
3 /// @brief Interface class for tensor container data structure
4 ///
5 
6 //**** This file is a part of the HAMMER library
7 //**** Copyright (C) 2016 - 2020 The HAMMER Collaboration
8 //**** HAMMER is licensed under version 3 of the GPL; see COPYING for details
9 //**** Please note the MCnet academic guidelines; see GUIDELINES for details
10 
11 // -*- C++ -*-
12 #ifndef HAMMER_MATH_IMULTICONTAINER
13 #define HAMMER_MATH_IMULTICONTAINER
14 
15 #include <complex>
16 
19 
20 namespace Hammer {
21 
22  namespace MultiDimensional {
23 
24  class IContainer {
25 
26  public:
27  virtual ~IContainer() {}
29  IContainer(const IContainer&) = default;
30  IContainer(IContainer&&) = default;
31  IContainer& operator=(const IContainer&) = default;
32  IContainer& operator=(IContainer&&) = default;
33 
34  using ElementType = std::complex<double>;
36  using const_reference = const ElementType&;
37 
38  virtual size_t rank() const = 0;
39  virtual IndexList dims() const = 0;
40  virtual LabelsList labels() const = 0;
41  virtual size_t numValues() const = 0;
42  virtual size_t dataSize() const = 0;
43  virtual size_t entrySize() const = 0;
44  virtual IndexType labelToIndex(IndexLabel label) const = 0;
45 
46  virtual IndexPairList getSameLabelPairs(const IContainer& other,
47  const UniqueLabelsList& indices) const = 0;
48  virtual IndexPairList getSpinLabelPairs() const = 0;
49 
50  virtual bool isSameShape(const IContainer& other) const = 0;
51  virtual bool canAddAt(const IContainer& subContainer, IndexLabel coord, IndexType position) const = 0;
52 
53  virtual reference element(const IndexList& coords = {}) = 0;
54  virtual ElementType element(const IndexList& coords = {}) const = 0;
55 
56  virtual reference element(IndexList::const_iterator start, IndexList::const_iterator end) = 0;
57  virtual ElementType element(IndexList::const_iterator start, IndexList::const_iterator end) const = 0;
58 
59  virtual bool compare(const IContainer& other) const = 0;
60  virtual TensorData clone() const = 0;
61  virtual void clear() = 0;
62 
63  virtual IContainer& operator*=(double value) = 0;
64  virtual IContainer& operator*=(const ElementType value) = 0;
65 
66  virtual IContainer& conjugate() = 0;
67 
68  using SerialType = std::pair<flatbuffers::Offset<void>, Serial::FBTensorTypes>;
69 
70  virtual SerialType write(flatbuffers::FlatBufferBuilder* msgwriter) const = 0;
71  };
72 
73  }
74 
75 }
76 
77 #endif
virtual IContainer & operator*=(double value)=0
virtual size_t entrySize() const =0
std::pair< flatbuffers::Offset< void >, Serial::FBTensorTypes > SerialType
Definition: IContainer.hh:68
Forward declaration of serialization related typedefs and includes.
virtual LabelsList labels() const =0
std::vector< IndexPair > IndexPairList
virtual bool compare(const IContainer &other) const =0
virtual IndexPairList getSpinLabelPairs() const =0
virtual size_t rank() const =0
virtual TensorData clone() const =0
virtual size_t dataSize() const =0
virtual IndexPairList getSameLabelPairs(const IContainer &other, const UniqueLabelsList &indices) const =0
std::complex< double > ElementType
Definition: IContainer.hh:34
uint16_t IndexType
virtual IndexType labelToIndex(IndexLabel label) const =0
std::unique_ptr< IContainer > TensorData
Forward declarations of types used in the tensor classes.
const ElementType & const_reference
Definition: IContainer.hh:36
std::vector< IndexType > IndexList
virtual SerialType write(flatbuffers::FlatBufferBuilder *msgwriter) const =0
IndexLabel
label identifiers of tensor indices they are used to determine which indices can be contracted togeth...
Definition: IndexLabels.hh:27
virtual IndexList dims() const =0
virtual bool isSameShape(const IContainer &other) const =0
std::vector< IndexLabel > LabelsList
std::set< IndexLabel > UniqueLabelsList
virtual size_t numValues() const =0
IContainer & operator=(const IContainer &)=default
virtual bool canAddAt(const IContainer &subContainer, IndexLabel coord, IndexType position) const =0
auto end(reversion_wrapper< T > w)
Definition: Tools/Utils.hh:84
virtual IContainer & conjugate()=0
virtual reference element(const IndexList &coords={})=0