Mackey  V3.3
A C++ library for computing RO(G) graded homology
Box.hpp
Go to the documentation of this file.
1 #pragma once
2 #include "Utility/General.hpp"
3 #include "Chains.hpp"
4 #include "ChangeBasis.hpp"
7 
8 
9 namespace mackey {
10 
11  namespace implementation_details{
12  //SFINAE aliases
13 
14  template<typename T>
15  using is_rank = std::enable_if_t<std::is_same<T, row_vector_t<T>>::value, int>;
16 
17  template<typename T>
18  using is_vector_rank = std::enable_if_t<std::is_same<T, std::vector<row_vector_t<typename T::value_type>>>::value, int>;
19 
20  template<typename T>
21  using is_arrow = std::enable_if_t<std::is_same<T, arrow_t<T>>::value, int>;
22 
23  template<typename T>
24  using is_chains = std::enable_if_t<std::is_same<T, chains_t<T>>::value, int>;
25 
26  template<typename T>
27  using is_junction = std::enable_if_t<std::is_same<T, junction_t<T>>::value, int>;
28 
29  template<typename T, bool>
30  struct optional_base;
31 
32  template<typename T>
33  struct optional_base<T, 0> {};
34 
35  template<typename T>
36  struct optional_base<T, 1> { T _optional; };
37  }
38 
42  template<typename _output_t, typename _optional_t = void>
43  class Tensor : implementation_details::optional_base<_optional_t, !std::is_same<_optional_t, void>::value> {
44  public:
47  _output_t& tensor();
48 
51  auto& optional();
52 
55  const _output_t& tensor() const;
56 
59  const auto& optional() const;
60 
66  template<typename _input_t>
67  Tensor(const _input_t& A, const _input_t& B, int i= -1);
68 
69  private:
70  static constexpr bool optional_exists = !std::is_same<_optional_t, void>::value;
71 
72  _output_t _tensor;
73 
74  //The tensor product of the ranks of A,B is the rank of A tensor B
75  //Here: _input_t=rank_t, _output_t=rank_t, _optional_t is void, i=-1
76  template<typename _input_t, typename implementation_details::is_rank<_input_t> = 0>
77  void tensor(const _input_t&, const _input_t&, int = -1);
78 
79  //The tensor product of the ranks of A_*,B_* at location i is the rank of (A_* tensor B_*)_i
80  //Here: _input_t=std::vector<rank_t>, _output_t=rank_t, _optional_t is std::vector<int64_t> or void, i= location
81  template<typename _input_t, typename implementation_details::is_vector_rank<_input_t> = 0, typename S = _output_t, typename implementation_details::is_rank<S> = 0>
82  void tensor(const _input_t&, const _input_t&, int = -1);
83 
84  //The tensor product of the ranks of A_*,B_* is the rank of A_* tensor B_*
85  //Here: _input_t=std::vector<rank_t>, _output_t=std::vector<rank_t>, _optional_t is void, i=-1
86  template<typename _input_t, typename T = _output_t, typename S = _output_t, typename implementation_details::is_vector_rank<T> = 0, typename implementation_details::is_vector_rank<S> = 0>
87  void tensor(const _input_t&, const _input_t&, int = -1);
88 
89  //The tensor product of the Chains A_*,B_* at location i is the arrow (A_* tensor B_*)_i
90  //Here: _input_t=Chains<rank_t,diff_t>, _output_t=Arrow<rank_t,diff_t>, _optional_t is std::vector<int64_t> or void, i= location
91  template<typename _input_t, typename T = _output_t, typename implementation_details::is_arrow<T> = 0>
92  void tensor(const _input_t&, const _input_t&, int = -1);
93 
94  //The tensor product of the Chains A_*,B_* up to location i is the Chains (A_* tensor B_*)_* for *<=i
95  //Here: _input_t=Chains<rank_t,diff_t>, _output_t=Chains<rank_t,diff_t>, _optional_t is std::vector<std::vector<int64_t>> or void, i= location or -1 (if the whole tensor is desired)
96  template<typename _input_t, typename T = _output_t, typename implementation_details::is_chains<T> = 0>
97  void tensor(const _input_t&, const _input_t&, int = -1);
98 
99  //The tensor product of the Chains A_*,B_* at location i as the Junction (A_* tensor B_*)_i->(A_* tensor B_*)_{i-1}
100  //Here: _input_t=Chains<rank_t,diff_t>, _output_t=Junction<rank_t,diff_t>, _optional_t is std::vector<int64_t> or void, i= location
101  template<typename _input_t, typename T = _output_t, typename implementation_details::is_junction<T> = 0>
102  void tensor(const _input_t&, const _input_t&, int = -1);
103 
104  };
105 }
106 #include "impl/Box.ipp"
Contains the classes mackey::Arrow, mackey::Chains and mackey::Junction.
Contains the class mackey::ChangeBasis.
Contains general functions and vector overloads independent of everything else.
Tensor product of chain complexes and more.
Definition: Box.hpp:43
const _output_t & tensor() const
Returns the tensor product.
auto & optional()
Returns the optional parameter (detailed rank)
_output_t & tensor()
Returns the tensor product.
const auto & optional() const
Returns the optional parameter (detailed rank)
Tensor(const _input_t &A, const _input_t &B, int i=-1)
Constructor that tensors A,B and optionally at given location only.
Everything in this library is under this namespace.
Definition: Box.hpp:9