32 #ifndef ENTANGLEMENT_H_ 33 #define ENTANGLEMENT_H_ 47 template <
typename Derived>
49 const std::vector<idx>& dims) {
82 template <
typename Derived>
99 std::vector<idx> dims(n, d);
112 template <
typename Derived>
114 const std::vector<idx>& dims) {
123 if (dims.size() != 2)
144 template <
typename Derived>
160 std::vector<idx> dims(n, d);
173 template <
typename Derived>
175 const std::vector<idx>& dims) {
184 if (dims.size() != 2)
207 template <
typename Derived>
223 std::vector<idx> dims(n, d);
240 template <
typename Derived>
242 const std::vector<idx>& dims) {
251 if (dims.size() != 2)
261 std::vector<double> result;
263 for (
idx i = 0; i < static_cast<idx>(scf.rows()); ++i)
264 result.push_back(std::pow(scf(i), 2));
281 template <
typename Derived>
298 std::vector<idx> dims(n, d);
314 template <
typename Derived>
316 const std::vector<idx>& dims) {
325 if (dims.size() != 2)
349 template <
typename Derived>
365 std::vector<idx> dims(n, d);
382 template <
typename Derived>
398 if (d * d != static_cast<idx>(rA.rows()))
403 return d * std::abs(std::exp(2. / d *
logdet(
reshape(rA, d, d))));
413 template <
typename Derived>
415 const std::vector<idx>& dims) {
424 if (dims.size() != 2)
444 template <
typename Derived>
460 std::vector<idx> dims(n, d);
472 template <
typename Derived>
474 const std::vector<idx>& dims) {
483 if (dims.size() != 2)
493 return std::log2(2 *
negativity(rA, dims) + 1);
503 template <
typename Derived>
519 std::vector<idx> dims(n, d);
530 template <
typename Derived>
552 std::vector<double> lambdas_sorted(lambdas.data(),
553 lambdas.data() + lambdas.size());
555 std::sort(std::begin(lambdas_sorted), std::end(lambdas_sorted),
556 std::greater<double>());
557 std::transform(std::begin(lambdas_sorted), std::end(lambdas_sorted),
558 std::begin(lambdas_sorted), [](
double elem) {
559 return std::sqrt(std::abs(elem));
562 return std::max(0., lambdas_sorted[0] - lambdas_sorted[1] -
563 lambdas_sorted[2] - lambdas_sorted[3]);
bool check_nonzero_size(const T &x) noexcept
Definition: util.h:123
Dimensions not equal exception.
Definition: exception.h:284
Dimension(s) mismatch matrix size exception.
Definition: exception.h:300
Derived::Scalar logdet(const Eigen::MatrixBase< Derived > &A)
Logarithm of the determinant.
Definition: functions.h:174
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:241
bool check_cvector(const Eigen::MatrixBase< Derived > &A)
Definition: util.h:117
double gconcurrence(const Eigen::MatrixBase< Derived > &A)
G-concurrence of the bi-partite pure state A.
Definition: entanglement.h:383
double lognegativity(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
Logarithmic negativity of the bi-partite mixed state A.
Definition: entanglement.h:473
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > dyn_mat
Dynamic Eigen matrix over the field specified by Scalar.
Definition: types.h:81
bool check_dims_match_mat(const std::vector< idx > &dims, const Eigen::MatrixBase< Derived > &A)
Definition: util.h:150
Matrix is not a column vector exception.
Definition: exception.h:164
Quantum++ main namespace.
Definition: circuits.h:35
Invalid dimension(s) exception.
Definition: exception.h:269
Subsystems are not qubits exception.
Definition: exception.h:471
idx get_num_subsys(idx D, idx d)
Definition: util.h:370
double schatten(const Eigen::MatrixBase< Derived > &A, double p)
Schatten matrix norm.
Definition: functions.h:845
bool check_dims_match_cvect(const std::vector< idx > &dims, const Eigen::MatrixBase< Derived > &A)
Definition: util.h:165
Not bi-partite exception.
Definition: exception.h:486
cmat svdU(const Eigen::MatrixBase< Derived > &A)
Left singular vectors.
Definition: functions.h:527
cmat schmidtA(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
Schmidt basis on Alice side.
Definition: entanglement.h:113
dyn_col_vect< double > svals(const Eigen::MatrixBase< Derived > &A)
Singular values.
Definition: functions.h:504
dyn_mat< typename T::Scalar > kron(const T &head)
Kronecker product.
Definition: functions.h:917
double entropy(const Eigen::MatrixBase< Derived > &A)
von-Neumann entropy of the density matrix A
Definition: entropies.h:43
dyn_mat< typename Derived::Scalar > ptranspose(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &target, const std::vector< idx > &dims)
Partial transpose.
Definition: operations.h:1425
Dimension(s) mismatch column vector size exception.
Definition: exception.h:316
dyn_mat< typename Derived::Scalar > transpose(const Eigen::MatrixBase< Derived > &A)
Transpose.
Definition: functions.h:46
dyn_col_vect< cplx > evals(const Eigen::MatrixBase< Derived > &A)
Eigenvalues.
Definition: functions.h:344
idx get_dim_subsys(idx sz, idx N)
Definition: util.h:382
dyn_mat< typename Derived::Scalar > conjugate(const Eigen::MatrixBase< Derived > &A)
Complex conjugate.
Definition: functions.h:68
bool check_square_mat(const Eigen::MatrixBase< Derived > &A)
Definition: util.h:99
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:551
double entanglement(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
Entanglement of the bi-partite pure state A.
Definition: entanglement.h:315
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > dyn_col_vect
Dynamic Eigen column vector over the field specified by Scalar.
Definition: types.h:93
static const Gates & get_instance() noexcept(std::is_nothrow_constructible< const Gates >::value)
Definition: singleton.h:92
Eigen::MatrixXcd cmat
Complex (double precision) dynamic Eigen matrix.
Definition: types.h:64
std::size_t idx
Non-negative integer index, make sure you use an unsigned type.
Definition: types.h:39
Matrix is not square exception.
Definition: exception.h:149
double concurrence(const Eigen::MatrixBase< Derived > &A)
Wootters concurrence of the bi-partite qubit mixed state A.
Definition: entanglement.h:531
cmat Y
Pauli Sigma-Y gate.
Definition: gates.h:49
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:48
dyn_mat< typename Derived::Scalar > reshape(const Eigen::MatrixBase< Derived > &A, idx rows, idx cols)
Reshape.
Definition: functions.h:1144
double negativity(const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &dims)
Negativity of the bi-partite mixed state A.
Definition: entanglement.h:414
Object has zero size exception.
Definition: exception.h:134