27 #ifndef ENTANGLEMENT_H_ 28 #define ENTANGLEMENT_H_ 43 template<
typename Derived>
45 const std::vector<idx>& dims)
79 template<
typename Derived>
97 std::vector<idx> dims(N, d);
110 template<
typename Derived>
112 const std::vector<idx>& dims)
122 if (dims.size() != 2)
143 template<
typename Derived>
160 std::vector<idx> dims(N, d);
173 template<
typename Derived>
175 const std::vector<idx>& dims)
185 if (dims.size() != 2)
208 template<
typename Derived>
225 std::vector<idx> dims(N, d);
242 template<
typename Derived>
244 const std::vector<idx>& dims)
254 if (dims.size() != 2)
264 std::vector<double> result;
266 for (
idx i = 0; i < static_cast<idx>(scf.rows()); ++i)
267 result.push_back(std::pow(scf(i), 2));
284 template<
typename Derived>
301 std::vector<idx> dims(N, d);
317 template<
typename Derived>
319 const std::vector<idx>& dims)
329 if (dims.size() != 2)
353 template<
typename Derived>
370 std::vector<idx> dims(N, d);
387 template<
typename Derived>
404 if (d * d != static_cast<idx>(rA.rows()))
409 return d * std::abs(std::exp(2. / d *
logdet(
reshape(rA, d, d))));
419 template<
typename Derived>
421 const std::vector<idx>& dims)
431 if (dims.size() != 2)
451 template<
typename Derived>
468 std::vector<idx> dims(N, d);
480 template<
typename Derived>
482 const std::vector<idx>& dims)
492 if (dims.size() != 2)
502 return std::log2(2 *
negativity(rA, dims) + 1);
512 template<
typename Derived>
529 std::vector<idx> dims(N, d);
540 template<
typename Derived>
561 *
kron(sigmaY, sigmaY)).real();
563 std::vector<double> lambdas_sorted(lambdas.data(),
564 lambdas.data() + lambdas.size());
566 std::sort(std::begin(lambdas_sorted), std::end(lambdas_sorted),
567 std::greater<double>());
568 std::transform(std::begin(lambdas_sorted), std::end(lambdas_sorted),
569 std::begin(lambdas_sorted), [](
double elem)
571 return std::sqrt(std::abs(elem));
575 lambdas_sorted[0] - lambdas_sorted[1] - lambdas_sorted[2]
576 - lambdas_sorted[3]);
bool check_nonzero_size(const T &x) noexcept
Definition: util.h:129
Dimensions not equal exception.
Definition: exception.h:304
Dimension(s) mismatch matrix size exception.
Definition: exception.h:322
Derived::Scalar logdet(const Eigen::MatrixBase< Derived > &A)
Logarithm of the determinant.
Definition: functions.h:170
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:243
bool check_cvector(const Eigen::MatrixBase< Derived > &A)
Definition: util.h:122
double gconcurrence(const Eigen::MatrixBase< Derived > &A)
G-concurrence of the bi-partite pure state A.
Definition: entanglement.h:388
double lognegativity(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
Logarithmic negativity of the bi-partite mixed state A.
Definition: entanglement.h:481
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > dyn_mat
Dynamic Eigen matrix over the field specified by Scalar.
Definition: types.h:77
bool check_dims_match_mat(const std::vector< idx > &dims, const Eigen::MatrixBase< Derived > &A)
Definition: util.h:158
Matrix is not a column vector exception.
Definition: exception.h:168
Quantum++ main namespace.
Definition: codes.h:30
idx get_num_subsys(idx sz, idx d)
Definition: util.h:391
Invalid dimension(s) exception.
Definition: exception.h:287
Subsystems are not qubits exception.
Definition: exception.h:515
double schatten(const Eigen::MatrixBase< Derived > &A, double p)
Schatten matrix norm.
Definition: functions.h:825
bool check_dims_match_cvect(const std::vector< idx > &dims, const Eigen::MatrixBase< Derived > &A)
Definition: util.h:174
Not bi-partite exception.
Definition: exception.h:532
cmat svdU(const Eigen::MatrixBase< Derived > &A)
Left singular vectors.
Definition: functions.h:494
cmat schmidtA(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
Schmidt basis on Alice side.
Definition: entanglement.h:111
dyn_col_vect< double > svals(const Eigen::MatrixBase< Derived > &A)
Singular values.
Definition: functions.h:470
dyn_mat< typename T::Scalar > kron(const T &head)
Kronecker product.
Definition: functions.h:899
double entropy(const Eigen::MatrixBase< Derived > &A)
von-Neumann entropy of the density matrix A
Definition: entropies.h:39
Dimension(s) mismatch column vector size exception.
Definition: exception.h:340
dyn_mat< typename Derived::Scalar > transpose(const Eigen::MatrixBase< Derived > &A)
Transpose.
Definition: functions.h:41
dyn_col_vect< cplx > evals(const Eigen::MatrixBase< Derived > &A)
Eigenvalues.
Definition: functions.h:302
idx get_dim_subsys(idx sz, idx N)
Definition: util.h:404
dyn_mat< typename Derived::Scalar > conjugate(const Eigen::MatrixBase< Derived > &A)
Complex conjugate.
Definition: functions.h:61
bool check_square_mat(const Eigen::MatrixBase< Derived > &A)
Definition: util.h:101
cmat schmidtB(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
Schmidt basis on Bob side.
Definition: entanglement.h:174
cmat svdV(const Eigen::MatrixBase< Derived > &A)
Right singular vectors.
Definition: functions.h:519
double entanglement(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
Entanglement of the bi-partite pure state A.
Definition: entanglement.h:318
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > dyn_col_vect
Dynamic Eigen column vector over the field specified by Scalar.
Definition: types.h:89
static const Gates & get_instance() noexcept(std::is_nothrow_constructible< const Gates >::value)
Definition: singleton.h:89
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:1495
Eigen::MatrixXcd cmat
Complex (double precision) dynamic Eigen matrix.
Definition: types.h:60
std::size_t idx
Non-negative integer index.
Definition: types.h:35
Matrix is not square exception.
Definition: exception.h:151
double concurrence(const Eigen::MatrixBase< Derived > &A)
Wootters concurrence of the bi-partite qubit mixed state A.
Definition: entanglement.h:541
cmat Y
Pauli Sigma-Y gate.
Definition: gates.h:45
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:44
dyn_mat< typename Derived::Scalar > reshape(const Eigen::MatrixBase< Derived > &A, idx rows, idx cols)
Reshape.
Definition: functions.h:1139
double negativity(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
Negativity of the bi-partite mixed state A.
Definition: entanglement.h:420
Object has zero size exception.
Definition: exception.h:134