Class documentation of Concepts

Loading...
Searching...
No Matches
outputMatlab.hh
Go to the documentation of this file.
1
6#ifndef ToolboxOutputMatlab_h
7#define ToolboxOutputMatlab_h
8
9#include <iomanip>
11#include "array.hh"
12#include "stiffArray.hh"
13#include "sequence.hh"
14
15#define OutputMatlabArray_D 0
16#define OutputMatlabStiffArray_D 0
17#define OutputMatlabSequence_D 0
18
19namespace concepts {
20
21 // ************************************************ OutputMatlab<Array<F> > **
22
29 template<typename F>
30 class OutputMatlab<Array<F> > : public virtual OutputOperator {
31 public:
32 OutputMatlab(const Array<F>& val, const bool transposed = false)
33 : val_(val), transposed_(transposed) {}
34 protected:
36 virtual std::ostream& info(std::ostream& os) const;
37 private:
38 const Array<F>& val_;
39 const bool transposed_;
40 };
41
43 template<typename F>
44 std::ostream& OutputMatlab<Array<F> >::info(std::ostream& os) const {
45 std::stringstream s;
46 s.setf(os.flags());
47 s.precision(os.precision());
48 s << "[";
49 const F* d = (const F*)val_;
50 DEBUGL(OutputMatlabArray_D,
51 "transposed = " << std::boolalpha << transposed_);
52 DEBUGL(OutputMatlabArray_D, val_);
53 for (uint i = val_.size(); i--;)
54 s << OutputMatlab<F>(*d++)
55 << ((i == 0) ? "" : (transposed_ ? " " : "; "));
56 s << ']';
57 DEBUGL(OutputMatlabArray_D, "s = " << s.str());
58 return os << s.str();
59 }
60
61 // *************************************** OutputMatlab<StiffArray<dim,F> > **
62
70 template<uint dim, typename F>
71 class OutputMatlab<StiffArray<dim,F> > : public virtual OutputOperator {
72 public:
73 OutputMatlab(const StiffArray<dim,F>& val, const bool transposed = false)
74 : val_(val), transposed_(transposed) {}
75 protected:
77 virtual std::ostream& info(std::ostream& os) const;
78 private:
79 const StiffArray<dim,F>& val_;
80 const bool transposed_;
81 };
82
84 template<uint dim, typename F>
85 std::ostream& OutputMatlab<StiffArray<dim,F> >::info(std::ostream& os) const
86 {
87 std::stringstream s;
88 s.setf(os.flags());
89 s.precision(os.precision());
90 s << "[";
91 const F* d = (const F*)val_;
92 DEBUGL(OutputMatlabStiffArray_D,
93 "transposed = " << std::boolalpha << transposed_);
94 DEBUGL(OutputMatlabStiffArray_D, val_);
95 for (uint i = dim; i--;)
96 s << OutputMatlab<F>(*d++)
97 << ((i == 0) ? "" : (transposed_ ? " " : "; "));
98 s << ']';
99 DEBUGL(OutputMatlabStiffArray_D, "s = " << s.str());
100 return os << s.str();
101 }
102
103 // ******************************************** OutputMatlab<Sequence<F> > **
104
111 template<typename F>
112 class OutputMatlab<Sequence<F> > : public virtual OutputOperator {
113 public:
114 OutputMatlab(const Sequence<F>& seq, const bool transposed = false)
115 : seq_(seq), transposed_(transposed) {}
116 protected:
118 virtual std::ostream& info(std::ostream& os) const;
119 private:
120 const Sequence<F>& seq_;
121 const bool transposed_;
122 };
123
125 template<typename F>
126 std::ostream& OutputMatlab<Sequence<F> >::info(std::ostream& os) const {
127 std::stringstream s;
128 s.setf(os.flags());
129 s.precision(os.precision());
130 s << concepts::typeOf(*this) << "[";
131 DEBUGL(OutputMatlabSequence_D,
132 "transposed = " << std::boolalpha << transposed_);
133 DEBUGL(OutputMatlabSequence_D, seq_);
134 for (uint i = 0; i < seq_.size(); ++i)
135 s << OutputMatlab<F>(seq_[i])
136 << ((i == seq_.size()-1) ? "" : (transposed_ ? " " : "; "));
137 s << ']';
138 DEBUGL(OutputMatlabSequence_D, "s = " << s.str());
139 return os << s.str();
140 }
141
142} // namespace concepts
143
144#endif // ToolboxOutputMatlab_h
std::ostream & info(std::ostream &os) const
Returns information in an output stream.
#define DEBUGL(doit, msg)
Definition debug.hh:40
std::string typeOf(const T &t)
Definition output.hh:43
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320