Tomographer  v2.0
Tomographer C++ Framework Documentation
tspacefigofmerit.h
Go to the documentation of this file.
1 /* This file is part of the Tomographer project, which is distributed under the
2  * terms of the MIT license.
3  *
4  * The MIT License (MIT)
5  *
6  * Copyright (c) 2016 ETH Zurich, Institute for Theoretical Physics, Philippe Faist
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24  * SOFTWARE.
25  */
26 
27 
28 #ifndef TOMOGRAPHER_DENSEDM_TSPACEFIGOFMERIT_H
29 #define TOMOGRAPHER_DENSEDM_TSPACEFIGOFMERIT_H
30 
31 
36 
37 
45 namespace Tomographer {
46 namespace DenseDM {
47 namespace TSpace {
48 
49 
56 template<typename DMTypes_, typename ValueType_ = double>
58  : public virtual Tools::NeedOwnOperatorNew<typename DMTypes_::MatrixType>::ProviderType
59 {
60 public:
61  typedef DMTypes_ DMTypes;
62  typedef typename DMTypes::MatrixType MatrixType;
64 
66  typedef ValueType_ ValueType;
67 
68 private:
69  MatrixType _ref_T;
70 
71 public:
73  FidelityToRefCalculator(MatrixTypeConstRef T_ref)
74  : _ref_T(T_ref)
75  {
76  }
77 
79  inline ValueType getValue(MatrixTypeConstRef T) const
80  {
81  return fidelityT<ValueType>(T, _ref_T);
82  }
83 };
84 
85 
86 
87 
95 template<typename DMTypes_, typename ValueType_ = double>
97  : public virtual Tools::NeedOwnOperatorNew<typename DMTypes_::MatrixType>::ProviderType
98 {
99 public:
100  typedef DMTypes_ DMTypes;
101  typedef typename DMTypes::MatrixType MatrixType;
103 
105  typedef ValueType_ ValueType;
106 
107 private:
108  MatrixType _ref_T;
109 
110 public:
112  PurifDistToRefCalculator(MatrixTypeConstRef T_ref)
113  : _ref_T(T_ref)
114  {
115  }
116 
118  inline ValueType getValue(MatrixTypeConstRef T) const
119  {
120  ValueType F = fidelityT<ValueType>(T, _ref_T);
121  if (F >= ValueType(1)) {
122  return 0;
123  }
124  return std::sqrt(ValueType(1) - F*F);
125  }
126 };
127 
131 template<typename DMTypes_, typename ValueType_ = double>
133  : public virtual Tools::NeedOwnOperatorNew<typename DMTypes_::MatrixType>::ProviderType
134 {
135 public:
136  typedef DMTypes_ DMTypes;
137  typedef typename DMTypes::MatrixType MatrixType;
139 
141  typedef ValueType_ ValueType;
142 
143 private:
144  MatrixType _ref_rho;
145 
146 public:
148  TrDistToRefCalculator(MatrixTypeConstRef rho_ref)
149  : _ref_rho(rho_ref)
150  {
151  }
152 
154  inline ValueType getValue(MatrixTypeConstRef T) const
155  {
156  return traceDistance<ValueType>(T*T.adjoint(), _ref_rho);
157  }
158 };
159 
160 
161 
165 template<typename DMTypes_>
167  : public virtual Tools::NeedOwnOperatorNew<typename DMTypes_::VectorParamType>::ProviderType
168 {
169 public:
170  typedef DMTypes_ DMTypes;
171  typedef typename DMTypes::MatrixType MatrixType;
173  typedef typename DMTypes::VectorParamType VectorParamType;
175 
177  typedef typename DMTypes::RealScalar ValueType;
178 
179 private:
181  ParamX<DMTypes> _param_x;
182 
184  VectorParamType _A_x;
185 
186 public:
188  ObservableValueCalculator(DMTypes dmt, MatrixTypeConstRef A)
189  : _param_x(dmt), _A_x(_param_x.HermToX(A))
190  {
191  }
193  ObservableValueCalculator(DMTypes dmt, VectorParamTypeConstRef A_x)
194  : _param_x(dmt), _A_x(A_x)
195  {
196  }
197 
199  inline ValueType getValue(MatrixTypeConstRef T) const
200  {
201  return _A_x.transpose() * _param_x.HermToX(T*T.adjoint());
202  }
203 };
204 
205 
206 } // namespace TSpace
207 } // namespace DenseDM
208 } // namespace Tomographer
209 
210 
211 #endif
VectorParamType HermToX(MatrixTypeConstRef Herm) const
Get the X-parameterization corresponding to a given hermitian matrix.
Definition: param_herm_x.h:182
Base namespace for the Tomographer project.
Definition: densellh.h:44
ObservableValueCalculator(DMTypes dmt, MatrixTypeConstRef A)
Constructor directly accepting A as a hermitian matrix.
C++ types for describing dense density matrices in various parameterizations.
ValueType_ ValueType
For ValueCalculator interface : value type.
Provide appropriate operator new() definitions for a structure which has a member of the given stored...
Calculate the trace distance to a reference state for each sample.
Distance measures in quantum information for states represented as dense matrices.
PurifDistToRefCalculator(MatrixTypeConstRef T_ref)
Constructor, the reference state is T_ref (in T Parameterization)
Calculate expectation value of an observable for each sample.
DMTypes::RealScalar ValueType
For ValueCalculator interface : value type.
ObservableValueCalculator(DMTypes dmt, VectorParamTypeConstRef A_x)
Constructor directly accepting the X parameterization of A.
ValueType getValue(MatrixTypeConstRef T) const
Calculate the purified distance of the state represented by T to the reference state.
ValueType getValue(MatrixTypeConstRef T) const
Calculate the fidelity of the state represented by T to the reference state.
FidelityToRefCalculator(MatrixTypeConstRef T_ref)
Constructor, the reference state is T_ref (in T Parameterization)
Calculate the "purified distance" to a reference state for each sample.
Tools for parameterizing hermitian matrices with the X Parameterization.
Calculate the fidelity to a reference state for each sample.
Managing the need for specific overrides to operator new() for some types (especially Eigen types) ...
ValueType_ ValueType
For ValueCalculator interface : value type.
ValueType getValue(MatrixTypeConstRef T) const
Calculate the trace distance of the state represented by T to the reference state.
T sqrt(T...args)
ValueType getValue(MatrixTypeConstRef T) const
Calculate the expectation value of the observable for the state represented by T. ...
ValueType_ ValueType
For ValueCalculator interface : value type.
TrDistToRefCalculator(MatrixTypeConstRef rho_ref)
Constructor, the reference state is rho_ref.
RealScalar_ RealScalar
Real scalar type, given in template parameter. Usually double is fine.
Definition: dmtypes.h:119