Go to the documentation of this file.00001
00002
00003
00004 #ifndef OutputMatlabSpace_hh
00005 #define OutputMatlabSpace_hh
00006
00007 #include <iostream>
00008 #include "basics/outputMatlab.hh"
00009
00010 using namespace std;
00011
00012 namespace concepts {
00013
00014
00015
00020 inline std::ostream& outputMatlab(std::ostream& os, const TMatrix<Real>& T) {
00021 typedef pair<int, Real> PID;
00022 typedef vector<PID> VPID;
00023 typedef map<int, VPID> M_I_VPID;
00024
00025 M_I_VPID local_to_global;
00026
00027 os << "[";
00028
00029 uint cnt = 0;
00030 for(uint i=0; i < T.n(); ++i) {
00031 const TMatrix<Real>::Control* ctrl = T.control(i);
00032 uint size = ctrl->sz;
00033 int global_idx = ctrl->idx;
00034
00035 for(uint j=0; j < size; ++j) {
00036 const TMatrix<Real>::Data* d = T.data(cnt);
00037 int local_idx = d->idx;
00038 Real weight = d->data;
00039
00040 local_to_global[local_idx].push_back(PID(global_idx, weight));
00041
00042 ++cnt;
00043 }
00044 }
00045
00046 for(M_I_VPID::const_iterator it = local_to_global.begin();
00047 it != local_to_global.end(); ++it)
00048 {
00049
00050
00051 const VPID& targets = it->second;
00052 for(uint i=0; i < targets.size(); ++i)
00053 {
00054 os << it->first << " " << targets[i].first << " "
00055 << targets[i].second << "; ";
00056 if (i % 3 == 2)
00057 os << std::endl;
00058 }
00059 }
00060
00061 os << "]";
00062
00063 return os;
00064 }
00065
00070 inline std::ostream& outputMatlab(std::ostream& os, const TMatrixBase<Real>& T) {
00071 const TMatrix<Real>* Tm = dynamic_cast<const TMatrix<Real>*>(&T);
00072 if (Tm)
00073 outputMatlab(os, *Tm);
00074 else
00075 os << T;
00076 return os;
00077 }
00078
00079
00080 }
00081
00082 #endif // OutputMatlabSpace_hh