Class documentation of Concepts

Loading...
Searching...
No Matches
outputMatlab.hh
Go to the documentation of this file.
1
6#ifndef OutputMatlabSpace_hh
7#define OutputMatlabSpace_hh
8
9#include <iostream>
11
12using namespace std;
13
14namespace concepts {
15
16 // ********************************************************** outputMatlab **
17
22 inline std::ostream& outputMatlab(std::ostream& os, const TMatrix<Real>& T)
23 {
24 typedef pair<int, Real> PID;
25 typedef vector<PID> VPID;
27
29
30 os << "[";
31
32 uint cnt = 0;
33 for(uint i=0; i < T.n(); ++i) {
35 uint size = ctrl->sz;
36 int global_idx = ctrl->idx;
37
38 for(uint j=0; j < size; ++j) {
39 const TMatrix<Real>::Data* d = T.data(cnt);
40 int local_idx = d->idx;
41 Real weight = d->data;
42
43 local_to_global[local_idx].push_back(PID(global_idx, weight));
44
45 ++cnt;
46 }
47 }
48
49 for(M_I_VPID::const_iterator it = local_to_global.begin();
50 it != local_to_global.end(); ++it)
51 {
52
53
54 const VPID& targets = it->second;
55 for(uint i=0; i < targets.size(); ++i)
56 {
57 os << it->first << " " << targets[i].first << " "
58 << targets[i].second << "; ";
59 if (i % 3 == 2)
60 os << std::endl;
61 }
62 }
63
64 os << "]";
65
66 return os;
67 }
68
73 inline std::ostream& outputMatlab(std::ostream& os, const TMatrixBase<Real>& T)
74 {
75 const TMatrix<Real>* Tm = dynamic_cast<const TMatrix<Real>*>(&T);
76 if (Tm)
78 else
79 os << T;
80 return os;
81 }
82
87 template<class F>
88 inline std::ostream& outputMatlab(std::ostream& os,
89 const ElementMatrix<F>& em)
90 {
91 const int N = em.n();
92 const int M = em.m();
93 os << "[" << std::endl;
94 for (int i = 0; i < M; ++i) {
95 for (int j = 0; j < N; ++j) {
96 outputMatlab(os << std::setw(2), em(i,j));
97 os << ((j == N-1) ? "" : " ");
98 } // for j
99 os << ((i == M-1) ? "" : "\n");
100 } // for i
101 return os << "]";
102 }
103
104} // namespace concepts
105
106#endif // OutputMatlabSpace_hh
uint n() const
Returns the number of columns.
Definition tmatrix.hh:393
const TMatrix::Control * control(uint i) const
Definition tmatrix.hh:601
const TMatrix::Data * data(uint i) const
Returns the ith entry of the data array.
Definition tmatrix.hh:604
double Real
Definition typedefs.hh:39
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320
std::ostream & outputMatlab(std::ostream &os, const T &val)
The column header: column index and length of the column data.
Definition tmatrix.hh:497
uint sz
Column length.
Definition tmatrix.hh:501
The matrix entries: row index and data.
Definition tmatrix.hh:507
uint idx
Row index.
Definition tmatrix.hh:509
F data
Data at this entry.
Definition tmatrix.hh:511