C++QEDCore  2.100.2 (v2 Milestone 10 Development branch)
a framework for simulating open quantum dynamics – core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
LiouvilleanAveragedCommon.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_LIOUVILLEANAVERAGEDCOMMON_H_INCLUDED
5 #define CPPQEDCORE_STRUCTURE_LIOUVILLEANAVERAGEDCOMMON_H_INCLUDED
6 
7 #include "LiouvilleanAveragedCommonFwd.h"
8 
9 #include "Types.h"
10 
11 #include "BlitzArray.h"
12 #include "BlitzArrayExtensions.h"
13 #include "Exception.h"
14 
15 #include <boost/shared_ptr.hpp>
16 
17 namespace structure {
18 
23 };
24 
26 template<LiouvilleanAveragedTag>
28 
31 
32 const LA_Li_tagType LA_Li_tag;
33 const LA_Av_tagType LA_Av_tag;
34 
35 
38 {
39 public:
40  typedef boost::shared_ptr<const LiouvilleanAveragedCommon> Ptr;
41 
42  typedef DArray<1> DArray1D;
43 
44  virtual ~LiouvilleanAveragedCommon() {}
45 
47 
51  std::ostream& displayKey(std::ostream& o,
52  size_t& i
53  ) const {return displayKey_v(o,i);}
54 
56 
60  size_t nAvr() const {return nAvr_v();}
61 
62 private:
63  virtual std::ostream& displayKey_v(std::ostream&, size_t&) const = 0;
64  virtual size_t nAvr_v ( ) const = 0;
65 
66 
67 };
68 
69 
72 {
73  AveragesNumberMismatchException(int size, size_t nAvr) {std::cerr<<size<<' '<<nAvr<<std::endl;}
74 
75 };
76 
77 
80 
81 
83 
84 template<int RANK>
86 {
87 public:
88  typedef boost::shared_ptr<const LiouvilleanAveragedCommonRanked> Ptr;
89 
91 
93 
95 
97 
105  const DArray1D average(double t,
106  const LazyDensityOperator& matrix
107  ) const
108  {
109  const DArray1D averages(average_v(t,matrix));
110  if (size_t(averages.size())!=nAvr()) throw AveragesNumberMismatchException(averages.size(),nAvr());
111  if (!all(blitzplusplus::isfinite(averages))) throw InfiniteDetectedException();
112 
113  return averages;
114  }
115 
116 private:
117  virtual const DArray1D average_v(double, const LazyDensityOperator&) const = 0;
118 
119 };
120 
121 
122 } // structure
123 
124 
125 
126 #endif // CPPQEDCORE_STRUCTURE_LIOUVILLEANAVERAGEDCOMMON_H_INCLUDED
The class that is (meant to be, at least) the base of all exceptions in the framework.
Definition: Exception.h:18
Defines class of the same name.
DArray< 1 > DArray1D
A 1D real array storing the quantum averages – even if they are complex, their real & imaginary part...
A tagging struct corresponding to LiouvilleanAveragedTag.
std::ostream & displayKey(std::ostream &o, size_t &i) const
Displays a key (a.k.a. legend)
blitz::Array< double, RANK > DArray
An array of doubles of arbitrary arity.
Definition: BlitzArray.h:13
Comprises modules for describing quantum systems.
Definition: Averaged.h:17
size_t nAvr(const SSF &free0, const SSF &free1, const SSI &ia)
Outfactored common functionality of Liouvillean and Averaged.
Common interface for calculating quantum averages.
Exception for LiouvilleanAveragedCommonRanked::average.
The template-parameter independent part of LiouvilleanAveragedCommonRanked.
Exception for LiouvilleanAveragedCommonRanked::average.
Declares extensions for creating vector & matrix views of blitz::Arrays.
LiouvilleanAveragedTag
Enumeration describing a (compile-time) choice between Liouvillean & Averaged.
Common functionality of Liouvillean & Averaged.
Defines tentative base classes for the exception classes of the framework.
size_t nAvr() const
Returns the number of calculated quantum averages.
Defines template aliases for real and complex arrays.
const DArray1D average(double t, const LazyDensityOperator &matrix) const
Calculates quantum averages & checks post-conditions.