Tomographer  v1.0a
Tomographer C++ Framework Documentation
dist.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) 2015 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 QIT_DIST_H
28 #define QIT_DIST_H
29 
37 #include <Eigen/Core>
38 #include <Eigen/Eigenvalues>
39 #include <Eigen/SVD>
40 #include <unsupported/Eigen/MatrixFunctions>
41 
42 namespace Tomographer {
43 
44 
51 template<typename ValueType, typename Derived, typename Derived2>
52 inline ValueType fidelity(const Eigen::MatrixBase<Derived>& rho, const Eigen::MatrixBase<Derived2>& sigma)
53 {
54  // The Schatten one-norm is the sum of the singular values.
57  return ValueType( (rho_eig.operatorSqrt()*sigma_eig.operatorSqrt()).jacobiSvd().singularValues().sum() );
58 }
59 
78 template<typename ValueType, typename Der1, typename Der2>
79 inline ValueType fidelity_T(const Eigen::MatrixBase<Der1>& T1, const Eigen::MatrixBase<Der2>& T2)
80 {
81  // Calculate ||sigma^{1/2} rho^{1/2}||_1 == || T1^\dagger * T2 ||_1
82  // and Schatten one-norm is the sum of the singular values.
83  ValueType val = (T1.adjoint()*T2).template cast<std::complex<ValueType> >().jacobiSvd().singularValues().sum();
84  return val;
85 }
86 
87 
88 
89 
90 
91 
92 } // namespace Tomographer
93 
94 
95 
96 
97 
98 
99 
100 #endif
Base namespace for the Tomographer project.
Definition: dmmhrw.h:51
STL class.
MatrixType operatorSqrt() const
ValueType fidelity_T(const Eigen::MatrixBase< Der1 > &T1, const Eigen::MatrixBase< Der2 > &T2)
Fidelity between two quantum states given by their T Parameterization.
Definition: dist.h:79
ValueType fidelity(const Eigen::MatrixBase< Derived > &rho, const Eigen::MatrixBase< Derived2 > &sigma)
Fidelity between two density matrices.
Definition: dist.h:52
const AdjointReturnType adjoint() const