C++QEDCore  v2 Milestone 10
a framework for simulating open quantum dynamics – core
Interaction.h
Go to the documentation of this file.
1 // Copyright András Vukics 2006–2014. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.txt)
2 // -*- C++ -*-
4 #ifndef CPPQEDCORE_STRUCTURE_INTERACTION_H_INCLUDED
5 #define CPPQEDCORE_STRUCTURE_INTERACTION_H_INCLUDED
6 
7 #include "InteractionFwd.h"
8 
9 #include "DynamicsBase.h"
10 #include "Free.h"
11 
12 #include "BlitzTiny.h"
13 #include "SmartPtr.h"
14 
15 #include <boost/bind.hpp>
16 
17 #include <boost/range/adaptor/transformed.hpp>
18 #include <boost/range/algorithm/copy.hpp>
19 
20 
21 namespace structure {
22 
23 
25 
37 template<int RANK>
38 class Interaction : public DynamicsBase, public DimensionsBookkeeper<RANK>
39 {
40 public:
41  typedef boost::shared_ptr<const Interaction> Ptr;
42 
44 
45  typedef blitz::TinyVector<Free::Ptr,RANK> Frees;
46 
47  template<typename F> using FreesTemplate=blitz::TinyVector<F,RANK>;
48 
49  typedef typename DimensionsBookkeeper<RANK>::Dimensions Dimensions;
50 
51  explicit Interaction(const Frees& frees,
52  const RealFreqs& realFreqs=emptyRF,
53  const ComplexFreqs& complexFreqs=emptyCF)
54  : DynamicsBase(realFreqs,complexFreqs), DimensionsBookkeeper<RANK>(extractDimensions(frees)), frees_(frees) {}
55 
56  Interaction(const Frees& frees, const ComplexFreqs& complexFreqs) : Interaction(frees,emptyRF,complexFreqs) {}
57  Interaction(const Frees& frees, RealFreqsInitializer rf, ComplexFreqsInitializer cf={}) : Interaction(frees,RealFreqs(rf),ComplexFreqs(cf)) {}
58  Interaction(const Frees& frees, ComplexFreqsInitializer cf) : Interaction(frees,RealFreqsInitializer(),cf) {}
59  Interaction(const Frees& frees, RF rf, CF cf=CF()) : Interaction(frees,RealFreqsInitializer{rf}, cf==CF() ? ComplexFreqsInitializer{} : ComplexFreqsInitializer{cf}) {}
60  Interaction(const Frees& frees, CF cf) : Interaction(frees,ComplexFreqsInitializer{cf}) {}
61  Interaction(const Frees& frees, RealFreqsInitializer rf, CF cf) : Interaction(frees,rf,{cf}) {}
62  Interaction(const Frees& frees, RF rf, ComplexFreqsInitializer cf) : Interaction(frees,{rf},cf) {}
63 
64  template<typename F0, typename F1, typename... RCF_type>
65  Interaction(const F0& f0, const F1& f1, const RCF_type&... realAndComplexFreqs)
66  : Interaction(Frees(cpputils::sharedPointerize(f0),cpputils::sharedPointerize(f1)),realAndComplexFreqs...) {}
67 
68  const Frees& getFrees() const {return frees_;}
69 
70 protected:
72  class FreesProxy
73  {
74  public:
75  template<typename... Pack>
76  FreesProxy(Pack&&... pack) : frees_(cpputils::sharedPointerize(pack)...) {}
77 
78  operator const Frees&() const {return frees_;}
79 
80  private:
81  const Frees frees_;
82  };
83 
84 private:
85  static const Dimensions extractDimensions(const Frees& frees)
86  {
87  Dimensions res;
88  boost::copy(frees | boost::adaptors::transformed(boost::bind(&Free::getTotalDimension,_1)), res.begin());
89  return res;
90  }
91 
92  const Frees frees_;
93 
94 };
95 
96 
97 } // structure
98 
99 #endif // CPPQEDCORE_STRUCTURE_INTERACTION_H_INCLUDED
Defines class of the same name.
blitz::TinyVector< Free::Ptr, RANK > Frees
A tiny vector of shared pointers to the Free objects between which the interaction is defined...
Definition: Interaction.h:45
Describes interaction of Free elements.
Definition: Interaction.h:38
std::tuple< std::string, dcomp,double > CF
same for complex
Definition: DynamicsBase.h:53
Namespace comprising otherwise hard-to-classify generic utilities.
Definition: Algorithm.h:10
const boost::shared_ptr< T > sharedPointerize(boost::shared_ptr< T > t)
Part of a bundle of functions providing a unified interface to wrap objects into the shared-pointer i...
Definition: SmartPtr.h:52
std::list< CF > ComplexFreqs
same for complex
Definition: DynamicsBase.h:56
Shared-pointerizes the elements passed as Frees.
Definition: Interaction.h:72
Comprises modules for describing quantum systems.
Definition: Averaged.h:17
Stores and manipulates dimensions of constructs over composite Hilbert spaces of arbitrary arity...
Provides services for dealing with frequency-like parameters, both real and complex, for all elements, frees and interactions alike, which are hence all derived from this class.
Definition: DynamicsBase.h:47
Defines class of the same name.
std::list< RF > RealFreqs
list of real frequency-like parameters
Definition: DynamicsBase.h:55
Defines template aliases for blitz::TinyVectors used for characterising the size of multi-arrays and ...
Tools for creating non-owning shared pointers.
std::tuple< std::string, double, double > RF
name-value-multiplier tuple for a real frequency-like parameter
Definition: DynamicsBase.h:52
blitz::TinyVector< F, RANK > FreesTemplate
F must be convertible to Free::Ptr by cpputils::sharedPointerize
Definition: Interaction.h:47
size_t getTotalDimension() const
Get the total dimension of a system of arbitrary arity.