27 #ifndef ENTANGLEMENT_H_
28 #define ENTANGLEMENT_H_
45 template<
typename Derived>
47 const std::vector <idx>& dims)
76 template<
typename Derived>
78 const std::vector <idx>& dims)
107 template<
typename Derived>
109 const std::vector <idx>& dims)
116 if (dims.size() != 2)
143 template<
typename Derived>
145 const std::vector <idx>& dims)
152 if (dims.size() != 2)
163 std::vector <double> result;
165 for (
idx i = 0; i < static_cast<idx>(scf.rows()); ++i)
166 result.push_back(std::pow(scf(i), 2));
182 template<
typename Derived>
184 const std::vector <idx>& dims)
191 if (dims.size() != 2)
216 template<
typename Derived>
231 idx D =
static_cast<idx>(std::llround(
232 std::sqrt(static_cast<double>(rA.rows()))));
233 if (D * D != static_cast<idx>(rA.rows()))
238 return D * std::abs(std::exp(2. / D *
logdet(
reshape(rA, D, D))));
248 template<
typename Derived>
250 const std::vector <idx>& dims)
257 if (dims.size() != 2)
278 template<
typename Derived>
280 const std::vector <idx>& dims)
287 if (dims.size() != 2)
299 return std::log2(2 *
negativity(rA, dims) + 1);
308 template<
typename Derived>
327 *
kron(sigmaY, sigmaY)).real();
329 std::vector <double> lambdas_sorted(lambdas.data(),
330 lambdas.data() + lambdas.size());
332 std::sort(std::begin(lambdas_sorted), std::end(lambdas_sorted),
333 std::greater<double>());
334 std::transform(std::begin(lambdas_sorted), std::end(lambdas_sorted),
335 std::begin(lambdas_sorted), [](
double elem)
337 return std::sqrt(std::abs(elem));
341 lambdas_sorted[0] - lambdas_sorted[1] - lambdas_sorted[2]
342 - lambdas_sorted[3]);
bool _check_cvector(const Eigen::MatrixBase< Derived > &A)
Definition: util.h:104
Derived::Scalar logdet(const Eigen::MatrixBase< Derived > &A)
Logarithm of the determinant.
Definition: functions.h:161
std::vector< double > schmidtprobs(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
Schmidt probabilities of the bi-partite pure state A.
Definition: entanglement.h:144
bool _check_dims_match_mat(const std::vector< idx > &dims, const Eigen::MatrixBase< Derived > &A)
Definition: util.h:142
double gconcurrence(const Eigen::MatrixBase< Derived > &A)
G-concurrence of the bi-partite pure state A.
Definition: entanglement.h:218
double lognegativity(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
Logarithmic negativity of the bi-partite mixed state A.
Definition: entanglement.h:279
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > dyn_mat
Dynamic Eigen matrix over the field specified by Scalar.
Definition: types.h:83
Quantum++ main namespace.
Definition: codes.h:30
bool _check_square_mat(const Eigen::MatrixBase< Derived > &A)
Definition: util.h:77
double schatten(const Eigen::MatrixBase< Derived > &A, double p)
Schatten matrix norm.
Definition: functions.h:738
cmat svdU(const Eigen::MatrixBase< Derived > &A)
Left singular vectors.
Definition: functions.h:447
cmat schmidtA(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
Schmidt basis on Alice side.
Definition: entanglement.h:77
dyn_col_vect< double > svals(const Eigen::MatrixBase< Derived > &A)
Singular values.
Definition: functions.h:426
dyn_mat< typename T::Scalar > kron(const T &head)
Kronecker product.
Definition: functions.h:798
double entropy(const Eigen::MatrixBase< Derived > &A)
von-Neumann entropy of the density matrix A
Definition: entropies.h:43
Generates custom exceptions, used when validating function parameters.
Definition: exception.h:39
dyn_mat< typename Derived::Scalar > transpose(const Eigen::MatrixBase< Derived > &A)
Transpose.
Definition: functions.h:44
dyn_col_vect< cplx > evals(const Eigen::MatrixBase< Derived > &A)
Eigenvalues.
Definition: functions.h:277
dyn_mat< typename Derived::Scalar > conjugate(const Eigen::MatrixBase< Derived > &A)
Complex conjugate.
Definition: functions.h:64
bool _check_nonzero_size(const T &x) noexcept
Definition: util.h:113
cmat schmidtB(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
Schmidt basis on Bob side.
Definition: entanglement.h:108
cmat svdV(const Eigen::MatrixBase< Derived > &A)
Right singular vectors.
Definition: functions.h:469
double entanglement(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
Entanglement of the bi-partite pure state A.
Definition: entanglement.h:183
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > dyn_col_vect
Dynamic Eigen column vector over the field specified by Scalar.
Definition: types.h:95
static const Gates & get_instance() noexcept(std::is_nothrow_constructible< const Gates >::value)
Definition: singleton.h:90
dyn_mat< typename Derived::Scalar > ptranspose(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &subsys, const std::vector< idx > &dims)
Partial transpose.
Definition: operations.h:1328
Eigen::MatrixXcd cmat
Complex (double precision) dynamic Eigen matrix.
Definition: types.h:66
std::size_t idx
Non-negative integer index.
Definition: types.h:36
double concurrence(const Eigen::MatrixBase< Derived > &A)
Wootters concurrence of the bi-partite qubit mixed state A.
Definition: entanglement.h:309
cmat Y
Pauli Sigma-Y gate.
Definition: gates.h:46
dyn_col_vect< double > schmidtcoeffs(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
Schmidt coefficients of the bi-partite pure state A.
Definition: entanglement.h:46
dyn_mat< typename Derived::Scalar > reshape(const Eigen::MatrixBase< Derived > &A, idx rows, idx cols)
Reshape.
Definition: functions.h:1026
double negativity(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
Negativity of the bi-partite mixed state A.
Definition: entanglement.h:249