C++QEDCore  v2 Milestone 10
a framework for simulating open quantum dynamics – core
Transformation.h
1 // Copyright András Vukics 2006–2014. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.txt)
2 // -*- C++ -*-
3 #ifndef CPPQEDCORE_QUANTUMDATA_TRANSFORMATION_H_INCLUDED
4 #define CPPQEDCORE_QUANTUMDATA_TRANSFORMATION_H_INCLUDED
5 
6 #include "TransformationFwd.h"
7 
8 #include "Types.h"
9 
10 #include "CMatrix.h"
12 
13 #include <boost/fusion/container/vector.hpp>
14 #include <boost/fusion/algorithm/transformation/join.hpp>
15 #include <boost/fusion/container/generation/make_vector.hpp>
16 #include <boost/fusion/container/vector/convert.hpp>
17 #include <boost/fusion/sequence/intrinsic/at_c.hpp>
18 
19 
20 
21 namespace quantumdata {
22 
23 
25 namespace transformation {
26 
27 
28 template<int RANK>
29 struct Identity
30 {
31 };
32 
33 
34 
35 
36 // Special Traits:
37 
38 // The following is a base class for all Traits that describe such transformations as cannot be factorized.
39 
40 template<typename TRAFO>
42 {
43  typedef typename boost::fusion::vector<TRAFO> TrafoTypes;
44  // Simply creates a single-element vector out of TRAFO, so that afterwards it can be treated in a unified way with Composites, e.g. by Compose
45 
46  static const TrafoTypes getTrafos(const TRAFO& trafo) {return boost::fusion::make_vector(trafo);}
47  // The same at runtime
48 
49 };
50 
51 
52 
53 template<int RANK>
54 struct Traits<Identity<RANK> > : ElementaryTraits<Identity<RANK> >
55 {
56  static const int N_RANK=RANK;
57 
58  typedef typename Types<N_RANK>::StateVectorLow StateVectorLow;
59  static void transform(Identity<RANK>, const StateVectorLow& in, StateVectorLow& out) {out=in;}
60 
61 };
62 
63 
64 
65 // Elementary examples are ...
66 // ... Transformations described by (multi)matrices:
67 
68 template<int TWO_TIMES_RANK>
69 struct Traits<CArray<TWO_TIMES_RANK> > : ElementaryTraits<CArray<TWO_TIMES_RANK> >
70 {
71  static const int N_RANK=TWO_TIMES_RANK/2;
72 
73  typedef typename Types<N_RANK>::StateVectorLow StateVectorLow;
74  static void transform(const CArray<TWO_TIMES_RANK>& trafo, const StateVectorLow& in, StateVectorLow& out);
75 
76 };
77 
78 
79 // ... Transformations described by functions of the appropriate signature:
80 
82 template<int RANK>
83 struct Traits< void(*)(const CArray<RANK>&, CArray<RANK>&) >
85 {
86  static const int N_RANK=RANK;
87 
88  typedef typename Types<N_RANK>::StateVectorLow StateVectorLow;
89 
90  typedef void(*TRAFO)(const StateVectorLow&, StateVectorLow&);
91 
92  static void transform(const TRAFO trafo, const StateVectorLow& in, StateVectorLow& out) {trafo(in,out);}
93 
94 };
95 
96 
97 /*
98 // ... Transformations described by functors of the appropriate signature:
99 
100 template<int RANK>
101 struct Traits<boost::function<void(const CArray<RANK>&, CArray<RANK>&)> >
102  : ElementaryTraits<boost::function<void(const CArray<RANK>&, CArray<RANK>&)> >
103 {
104  static const int N_RANK=RANK;
105 
106  typedef typename Types<N_RANK>::StateVectorLow StateVectorLow;
107 
108  typedef void(*TRAFO)(const StateVectorLow&, StateVectorLow&);
109 
110  typedef boost::function<void(const CArray<RANK>&, CArray<RANK>&)> TRAFO;
111 
112  static void transform(TRAFO trafo, const StateVectorLow& in, StateVectorLow& out) {trafo(in,out);}
113 
114 };
115 */
116 
117 } // transformation
118 
119 } // quantumdata
120 
121 #endif // CPPQEDCORE_QUANTUMDATA_TRANSFORMATION_H_INCLUDED
122 
Definition of blitzplusplus::basi::Iterator together with its helpers.
Defines class of the same name.
Comprises classes representing the state of composite quantum systems and providing various interface...
Definition: ArrayBase.h:16
blitz::Array< dcomp,RANK > CArray
A complex array of arbitrary arity.
Definition: BlitzArray.h:16
quantumdata::Types< 1 >::StateVectorLow StateVectorLow
unary StateVectorLow
Definition: Free.h:34
defines the typedef linalg::CMatrix and some helpers