32 #ifndef INTERNAL_CLASSES_IOMANIP_H_ 33 #define INTERNAL_CLASSES_IOMANIP_H_ 40 template <
typename InputIterator>
41 class IOManipRange :
public IDisplay {
42 InputIterator first_, last_;
43 std::string separator_, start_, end_;
47 explicit IOManipRange(InputIterator first, InputIterator last,
48 const std::string& separator,
49 const std::string& start =
"[",
50 const std::string& end =
"]",
double chop = qpp::chop)
51 : first_{first}, last_{last},
52 separator_{separator}, start_{start}, end_{end}, chop_{chop} {}
57 IOManipRange(
const IOManipRange&) =
default;
59 IOManipRange& operator=(
const IOManipRange&) =
default;
62 std::ostream& display(std::ostream& os)
const override {
66 for (InputIterator it = first_; it != last_; ++it) {
70 os << abs_chop(*it, chop_);
78 template <
typename Po
interType>
79 class IOManipPointer :
public IDisplay {
80 const PointerType* p_;
82 std::string separator_, start_, end_;
86 explicit IOManipPointer(
const PointerType* p, idx N,
87 const std::string& separator,
88 const std::string& start =
"[",
89 const std::string& end =
"]",
90 double chop = qpp::chop)
92 separator_{separator}, start_{start}, end_{end}, chop_{chop} {}
95 IOManipPointer(
const IOManipPointer&) =
default;
97 IOManipPointer& operator=(
const IOManipPointer&) =
default;
100 std::ostream& display(std::ostream& os)
const override {
103 for (idx i = 0; i < N_ - 1; ++i)
104 os << abs_chop(p_[i], chop_) << separator_;
106 os << abs_chop(p_[N_ - 1], chop_);
117 #if ((__GNUC__ == 4) && (__GNUC_MINOR__ == 8) && !__clang__) 118 #pragma GCC diagnostic push 119 #pragma GCC diagnostic ignored "-Weffc++" 121 class IOManipEigen :
public IDisplay,
private Display_Impl_ {
122 #if ((__GNUC__ == 4) && (__GNUC_MINOR__ == 8) && !__clang__) 123 #pragma GCC diagnostic pop 130 template <
typename Derived>
131 explicit IOManipEigen(
const Eigen::MatrixBase<Derived>& A,
132 double chop = qpp::chop)
133 : A_{A.template cast<cplx>()},
137 explicit IOManipEigen(
const cplx z,
double chop = qpp::chop)
138 : A_{cmat::Zero(1, 1)}, chop_{chop} {
144 std::ostream& display(std::ostream& os)
const override {
145 return display_impl_(A_, os, chop_);
Quantum++ main namespace.
Definition: circuits.h:35