Kernel Quantum Probability Library
The KQP library aims at providing tools for working with quantums probabilities
trace.hpp
1 
2 
3 /*
4  This file is part of the Kernel Quantum Probability library (KQP).
5 
6  KQP is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  KQP is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with KQP. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __KQP_TRACE_H__
21 #define __KQP_TRACE_H__
22 
23 #include <kqp/feature_matrix.hpp>
24 
25 namespace kqp {
26 //
27 // /**
28 // * @brief Computes \f$ \vert X Y D^2 Y^\dagger X^\dagger \f$.
29 // *
30 // * Computes \f$ tr( X Y D^2 Y^\dagger X^\dagger X Y D^2 Y^\dagger X^\dagger) = tr( [D Y^\dagger X^\dagger X Y D] [D Y^\dagger X^\dagger X Y D] ) = \vert D Y^\dagger X^\dagger X Y D \vert^2 \f$
31 // */
32 // template<class Scalar>
33 // typename Real squaredNorm(const FeatureMatrix<Scalar> &mX,
34 // const typename ftraits<Derived>::ScalarAltMatrix &mY,
35 // const typename ftraits<Derived>::RealVector &mD) {
36 // typename ftraits<Derived>::ScalarMatrix m;
37 // return (mD.asDiagonal() * mY.adjoint() * mX.inner() * mY * mD.asDiagonal()).squaredNorm();
38 // }
39 //
40 // /**
41 // * @brief Computes the trace of an operator.
42 // *
43 // * Computes \f$ tr( X Y D^2 Y^\dagger X^\dagger) \f$
44 // *
45 // */
46 // template<typename Derived, typename OtherDerived>
47 // typename ftraits<Derived>::Scalar traceAAT(const FeatureMatrix<Derived> &mX,
48 // const typename ftraits<Derived>::ScalarAltMatrix &mY,
49 // const Eigen::MatrixBase<OtherDerived> &mD) {
50 // typename ftraits<Derived>::ScalarMatrix m;
51 // return (mY.adjoint() * mX.inner() * mY * mD.cwiseAbs2().asDiagonal()).trace();
52 // }
53 //
54 //
55 // /**
56 // * Computes \f$ tr( X_1 Y_1 D_1 Y_1^\dagger X1^\dagger X_2 Y_2 D_2 Y_2^\dagger X_2^\dagger) \f$
57 // *
58 // */
59 // template<class Scalar>
60 // typename Scalar trace_function(const Space<Scalar>
61 // const FeatureMatrix<Scalar> &mX1,
62 // const typename ScalarAltMatrix &mY1,
63 // const typename RealVector &mD1,
64 //
65 // const FeatureMatrix<Derived> &mX2,
66 // const typename ftraits<Derived>::ScalarAltMatrix &mY2,
67 // const typename ftraits<Derived>::RealVector &mD2) {
68 //
69 // typename ftraits<Derived>::ScalarMatrix m = mY1.adjoint() * inner<Derived>(mX1.derived(), mX2.derived()) * mY2;
70 //
71 // return (m.adjoint() * mD1.asDiagonal() * m * mD2.asDiagonal()).trace();
72 // }
73 //
74 // /**
75 // * Computes the difference between two operators using trace functions
76 // */
77 // template<class Derived>
78 // typename ftraits<Derived>::Scalar difference(const FeatureMatrix<Derived> &mX1,
79 // const typename ftraits<Derived>::ScalarAltMatrix &mY1,
80 // const typename ftraits<Derived>::RealVector &mD1,
81 //
82 // const FeatureMatrix<Derived> &mX2,
83 // const typename ftraits<Derived>::ScalarAltMatrix &mY2,
84 // const typename ftraits<Derived>::RealVector &mD2) {
85 //
86 // double tr1 = trace_function(mX1, mY1, mD1, mX1, mY1, mD1);
87 // double tr2 = trace_function(mX2, mY2, mD2, mX2, mY2, mD2);
88 // double tr12 = trace_function(mX1, mY1, mD1, mX2, mY2, mD2);
89 //
90 // return tr1 + tr2 - 2. * tr12;
91 // }
92 }
93 
94 #endif