Tomographer  v5.2
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  * Copyright (c) 2017 Caltech, Institute for Quantum Information and Matter, Philippe Faist
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a copy
10  * of this software and associated documentation files (the "Software"), to deal
11  * in the Software without restriction, including without limitation the rights
12  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13  * copies of the Software, and to permit persons to whom the Software is
14  * furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included in
17  * all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25  * SOFTWARE.
26  */
27 
28 
29 #ifndef TOMOGRAPHER_DENSEDM_TSPACEFIGOFMERIT_H
30 #define TOMOGRAPHER_DENSEDM_TSPACEFIGOFMERIT_H
31 
32 
37 
38 
46 namespace Tomographer {
47 namespace DenseDM {
48 namespace TSpace {
49 
50 
57 template<typename DMTypes_, typename ValueType_ = double>
58 class TOMOGRAPHER_EXPORT FidelityToRefCalculator
59  : public virtual Tools::NeedOwnOperatorNew<typename DMTypes_::MatrixType>::ProviderType
60 {
61 public:
62  typedef DMTypes_ DMTypes;
63  typedef typename DMTypes::MatrixType MatrixType;
65 
67  typedef ValueType_ ValueType;
68 
69 private:
70  MatrixType _ref_T;
71 
72 public:
74  FidelityToRefCalculator(MatrixTypeConstRef T_ref)
75  : _ref_T(T_ref)
76  {
77  }
78 
80  inline ValueType getValue(MatrixTypeConstRef T) const
81  {
82  return fidelityT<ValueType>(T, _ref_T);
83  }
84 };
85 
86 
87 
88 
96 template<typename DMTypes_, typename ValueType_ = double>
97 class TOMOGRAPHER_EXPORT PurifDistToRefCalculator
98  : public virtual Tools::NeedOwnOperatorNew<typename DMTypes_::MatrixType>::ProviderType
99 {
100 public:
101  typedef DMTypes_ DMTypes;
102  typedef typename DMTypes::MatrixType MatrixType;
104 
106  typedef ValueType_ ValueType;
107 
108 private:
109  MatrixType _ref_T;
110 
111 public:
113  PurifDistToRefCalculator(MatrixTypeConstRef T_ref)
114  : _ref_T(T_ref)
115  {
116  }
117 
119  inline ValueType getValue(MatrixTypeConstRef T) const
120  {
121  ValueType F = fidelityT<ValueType>(T, _ref_T);
122  if (F >= ValueType(1)) {
123  return 0;
124  }
125  return std::sqrt(ValueType(1) - F*F);
126  }
127 };
128 
132 template<typename DMTypes_, typename ValueType_ = double>
133 class TOMOGRAPHER_EXPORT TrDistToRefCalculator
134  : public virtual Tools::NeedOwnOperatorNew<typename DMTypes_::MatrixType>::ProviderType
135 {
136 public:
137  typedef DMTypes_ DMTypes;
138  typedef typename DMTypes::MatrixType MatrixType;
140 
142  typedef ValueType_ ValueType;
143 
144 private:
145  MatrixType _ref_rho;
146 
147 public:
149  TrDistToRefCalculator(MatrixTypeConstRef rho_ref)
150  : _ref_rho(rho_ref)
151  {
152  }
153 
155  inline ValueType getValue(MatrixTypeConstRef T) const
156  {
157  return traceDistance<ValueType>(T*T.adjoint(), _ref_rho);
158  }
159 };
160 
161 
162 
166 template<typename DMTypes_>
167 class TOMOGRAPHER_EXPORT ObservableValueCalculator
168  : public virtual Tools::NeedOwnOperatorNew<typename DMTypes_::VectorParamType>::ProviderType
169 {
170 public:
171  typedef DMTypes_ DMTypes;
172  typedef typename DMTypes::MatrixType MatrixType;
174  typedef typename DMTypes::VectorParamType VectorParamType;
176 
178  typedef typename DMTypes::RealScalar ValueType;
179 
180 private:
182  ParamX<DMTypes> _param_x;
183 
185  VectorParamType _A_x;
186 
187 public:
189  ObservableValueCalculator(DMTypes dmt, MatrixTypeConstRef A)
190  : _param_x(dmt), _A_x(_param_x.HermToX(A))
191  {
192  }
194  ObservableValueCalculator(DMTypes dmt, VectorParamTypeConstRef A_x)
195  : _param_x(dmt), _A_x(A_x)
196  {
197  }
198 
200  inline ValueType getValue(MatrixTypeConstRef T) const
201  {
202  return _A_x.transpose() * _param_x.HermToX(T*T.adjoint());
203  }
204 };
205 
206 
207 } // namespace TSpace
208 } // namespace DenseDM
209 } // namespace Tomographer
210 
211 
212 #endif
ValueType getValue(MatrixTypeConstRef T) const
Calculate the trace distance of the state represented by T to the reference state.
Base namespace for the Tomographer project.
Definition: densellh.h:45
ObservableValueCalculator(DMTypes dmt, MatrixTypeConstRef A)
Constructor directly accepting A as a hermitian matrix.
ValueType getValue(MatrixTypeConstRef T) const
Calculate the purified distance of the state represented by T to the reference state.
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.
ValueType getValue(MatrixTypeConstRef T) const
Calculate the fidelity of the state represented by T to the reference state.
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 expectation value of the observable for the state represented by T. ...
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.
VectorParamType HermToX(MatrixTypeConstRef Herm) const
Get the X-parameterization corresponding to a given hermitian matrix.
Definition: param_herm_x.h:81
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.
T sqrt(T... args)
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:121