28 #ifndef RANDOM_UNITARY_H 29 #define RANDOM_UNITARY_H 61 template<
typename DerU,
typename Rng,
typename Log>
64 {
using namespace Eigen; EIGEN_STATIC_ASSERT_LVALUE(DerU); }
67 const Eigen::Index n = U.rows();
69 logger.longdebug(
"randomUnitary()", [&](
std::ostream & stream) {
70 stream <<
"n = " << n ;
73 typedef typename DerU::Scalar Scalar;
81 A = Tomographer::Tools::denseRandom<MatrixType>(rng, normdist, n, n);
89 for (Eigen::Index j = 0; j < n; ++j) {
91 VectorType v = VectorType::Zero(n);
95 for (Eigen::Index k = 0; k < j; ++k) {
96 Scalar p = U.
col(k).adjoint() * v;
100 U.
col(j) = v / v.norm();
109 logger.longdebug(
"randomUnitary()", [&](
std::ostream& str) {
110 str <<
"randomUnitary: got U = \n" << U <<
"\n" 111 <<
"Check: U*U.adjoint() ==\n" << U*U.
adjoint() <<
"\n" 112 <<
"Check: U.adjoint()*U ==\n" << U.
adjoint()*U;
117 template<
typename Der1,
typename Rng>
120 randomUnitary<Der1, Rng>(U, rng, Logger::vacuum_logger);
Base namespace for the Tomographer project.
Basic utilities for dealing with Eigen matrices and other types.
Some C++ utilities, with a tad of C++11 tricks.
const AdjointReturnType adjoint() const
#define tomographer_assert(...)
Assertion test macro.
Utilities for logging messages.