Tomographer  v2.0
Tomographer C++ Framework Documentation
distmeasures.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 #ifndef TOMOGRAPHER_DENSEDM_DISTMEASURES_H
28 #define TOMOGRAPHER_DENSEDM_DISTMEASURES_H
29 
30 
37 #include <Eigen/Core>
38 #include <Eigen/Eigenvalues>
39 #include <Eigen/SVD>
40 #include <unsupported/Eigen/MatrixFunctions>
41 
42 
43 namespace Tomographer {
44 namespace DenseDM {
45 
54 template<typename ValueType, typename Derived1, typename Derived2>
55 inline ValueType traceDistance(const Eigen::MatrixBase<Derived1> & rho1, const Eigen::MatrixBase<Derived2> & rho2)
56 {
57  return boost::math::constants::half<ValueType>() *
58  (rho1 - rho2).template selfadjointView<Eigen::Lower>()
59  .eigenvalues().cwiseAbs().sum();
60 }
61 
62 
69 template<typename ValueType, typename Derived, typename Derived2>
70 inline ValueType fidelity(const Eigen::MatrixBase<Derived>& rho, const Eigen::MatrixBase<Derived2>& sigma)
71 {
72  // The Schatten one-norm is the sum of the singular values.
75  return ValueType( (rho_eig.operatorSqrt()*sigma_eig.operatorSqrt()).jacobiSvd().singularValues().sum() );
76 }
77 
96 template<typename ValueType, typename Der1, typename Der2>
97 inline ValueType fidelityT(const Eigen::MatrixBase<Der1>& T1, const Eigen::MatrixBase<Der2>& T2)
98 {
99  // Calculate ||sigma^{1/2} rho^{1/2}||_1 == || T1^\dagger * T2 ||_1
100  // and Schatten one-norm is the sum of the singular values.
101  ValueType val = (T1.adjoint()*T2).template cast<std::complex<ValueType> >().jacobiSvd().singularValues().sum();
102  return val;
103 }
104 
105 
106 
107 
108 
109 } // namespace DenseDM
110 } // namespace Tomographer
111 
112 
113 
114 
115 
116 
117 
118 #endif
Base namespace for the Tomographer project.
Definition: densellh.h:44
STL class.
ValueType fidelityT(const Eigen::MatrixBase< Der1 > &T1, const Eigen::MatrixBase< Der2 > &T2)
Fidelity between two quantum states given by their T Parameterization.
Definition: distmeasures.h:97
ValueType traceDistance(const Eigen::MatrixBase< Derived1 > &rho1, const Eigen::MatrixBase< Derived2 > &rho2)
Calculate the trace distance between two density matrices.
Definition: distmeasures.h:55
MatrixType operatorSqrt() const
ValueType fidelity(const Eigen::MatrixBase< Derived > &rho, const Eigen::MatrixBase< Derived2 > &sigma)
Fidelity between two density matrices.
Definition: distmeasures.h:70
const AdjointReturnType adjoint() const