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