66 | | <a name="l00003"></a>00003 <span class="keyword">namespace </span>bdm{ |
67 | | <a name="l00004"></a>00004 <span class="keywordtype">int</span> mxReplaceFieldNM(mxArray *X,<span class="keyword">const</span> <span class="keywordtype">char</span> * fname,mxArray *X1) |
68 | | <a name="l00005"></a>00005 { |
69 | | <a name="l00006"></a>00006 mxArray *Old; |
70 | | <a name="l00007"></a>00007 <span class="keywordtype">int</span> i; |
71 | | <a name="l00008"></a>00008 |
72 | | <a name="l00009"></a>00009 <span class="keywordflow">if</span>((i=mxGetFieldNumber(X,fname))==-1) |
73 | | <a name="l00010"></a>00010 { |
74 | | <a name="l00011"></a>00011 <span class="keywordflow">if</span>((i=mxAddField(X,fname))==-1) <span class="keywordflow">return</span> i; |
| 69 | <a name="l00003"></a>00003 <span class="keyword">namespace </span>bdm { |
| 70 | <a name="l00004"></a>00004 <span class="keywordtype">int</span> mxReplaceFieldNM ( mxArray *X, <span class="keyword">const</span> <span class="keywordtype">char</span> * fname, mxArray *X1 ) { |
| 71 | <a name="l00005"></a>00005 mxArray *Old; |
| 72 | <a name="l00006"></a>00006 <span class="keywordtype">int</span> i; |
| 73 | <a name="l00007"></a>00007 |
| 74 | <a name="l00008"></a>00008 <span class="keywordflow">if</span> ( ( i = mxGetFieldNumber ( X, fname ) ) == -1 ) { |
| 75 | <a name="l00009"></a>00009 <span class="keywordflow">if</span> ( ( i = mxAddField ( X, fname ) ) == -1 ) <span class="keywordflow">return</span> i; |
| 76 | <a name="l00010"></a>00010 |
| 77 | <a name="l00011"></a>00011 } |
95 | | <a name="l00032"></a>00032 rows = in(0).length(); <span class="comment">//length of the first vec</span> |
96 | | <a name="l00033"></a>00033 <span class="keywordflow">if</span> (rows == 0) mexErrMsgTxt(<span class="stringliteral">"mat2mxArray: Data has zero rows"</span>); |
97 | | <a name="l00034"></a>00034 |
98 | | <a name="l00035"></a>00035 <span class="keywordflow">for</span> (c = 0; c < cols; c++) { |
99 | | <a name="l00036"></a>00036 <span class="keywordflow">for</span> (r = 0; r < rows; r++) { |
100 | | <a name="l00037"></a>00037 *temp++ = in(c)(r); |
101 | | <a name="l00038"></a>00038 } |
102 | | <a name="l00039"></a>00039 } |
103 | | <a name="l00040"></a>00040 |
104 | | <a name="l00041"></a>00041 } |
105 | | <a name="l00042"></a>00042 <span class="keyword">class </span>mexlog : <span class="keyword">public</span> memlog { |
106 | | <a name="l00043"></a>00043 <span class="keyword">public</span>: |
107 | | <a name="l00045"></a>00045 mexlog(): <a class="code" href="classbdm_1_1memlog.html#611dda03b3050de2eaa448a59cee9c27" title="Default constructor.">memlog</a>(0,<span class="stringliteral">""</span>){}; |
108 | | <a name="l00047"></a>00047 mxArray* toCell(){ |
109 | | <a name="l00048"></a>00048 mxArray* tmp = mxCreateStructMatrix(1,1,0,NULL); |
110 | | <a name="l00049"></a>00049 |
111 | | <a name="l00050"></a>00050 <span class="comment">//copied from itsave</span> |
112 | | <a name="l00051"></a>00051 <span class="keywordtype">int</span> i; |
113 | | <a name="l00052"></a>00052 <span class="keywordtype">string</span> vec_name=<span class="stringliteral">""</span>; |
114 | | <a name="l00053"></a>00053 <span class="keywordtype">int</span> istart, iend; |
115 | | <a name="l00054"></a>00054 |
116 | | <a name="l00055"></a>00055 mat M; <span class="comment">//temporary matrix</span> |
117 | | <a name="l00056"></a>00056 <span class="keywordflow">for</span> ( i=0; i<<a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a>.length();i++ ) { |
118 | | <a name="l00057"></a>00057 istart=0; |
119 | | <a name="l00058"></a>00058 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j=0; j<<a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a>(i).length(); j++){ <span class="comment">// same for as in add!!!</span> |
120 | | <a name="l00059"></a>00059 vec_name = <a class="code" href="classbdm_1_1logger.html#68ca1f05cf3d414ba0f39211977b8d02" title="Names of logged quantities, e.g. names of algorithm variants.">names</a>(i) + <a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a>(i).name(j); |
121 | | <a name="l00060"></a>00060 iend=istart+<a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a>(i).size(j)-1; |
122 | | <a name="l00061"></a>00061 M=<a class="code" href="classbdm_1_1memlog.html#1fed143162f2de6ef1c1b6557964f24e" title="Storage.">vectors</a>(i).get_cols(istart,iend); |
123 | | <a name="l00062"></a>00062 istart=iend+1; |
124 | | <a name="l00063"></a>00063 <span class="comment">// copy the selection to mx</span> |
125 | | <a name="l00064"></a>00064 mxArray* fld=mxCreateDoubleMatrix(M.rows(), M.cols(), mxREAL); |
126 | | <a name="l00065"></a>00065 mat2mxArray(M,fld); |
127 | | <a name="l00066"></a>00066 mxReplaceFieldNM(tmp, vec_name.c_str(), fld); |
128 | | <a name="l00067"></a>00067 } |
129 | | <a name="l00068"></a>00068 } |
130 | | <a name="l00069"></a>00069 <span class="keywordflow">return</span> tmp; |
131 | | <a name="l00070"></a>00070 } |
132 | | <a name="l00071"></a>00071 <span class="keywordtype">void</span> from_setting (<span class="keyword">const</span> Setting &root){ |
133 | | <a name="l00072"></a>00072 <a class="code" href="classbdm_1_1memlog.html#a690ebd91430b5973855c9b4c9cf1b1d" title="Maximum length of vectors stored in memory.">maxlen</a>=root[<span class="stringliteral">"maxlen"</span>]; |
134 | | <a name="l00073"></a>00073 } |
135 | | <a name="l00074"></a>00074 }; |
136 | | <a name="l00075"></a>00075 <a class="code" href="user__info_8h.html#4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a>(mexlog); |
| 98 | <a name="l00032"></a>00032 <span class="keywordflow">for</span> ( c = 0; c < cols; c++ ) { |
| 99 | <a name="l00033"></a>00033 <span class="keywordflow">for</span> ( r = 0; r < rows; r++ ) { |
| 100 | <a name="l00034"></a>00034 *temp++ = in ( c ) ( r ); |
| 101 | <a name="l00035"></a>00035 } |
| 102 | <a name="l00036"></a>00036 } |
| 103 | <a name="l00037"></a>00037 |
| 104 | <a name="l00038"></a>00038 } |
| 105 | <a name="l00039"></a>00039 |
| 106 | <a name="l00041"></a><a class="code" href="classbdm_1_1mexlog.html">00041</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mexlog.html" title="Logger storing results into an mxArray.">mexlog</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1memlog.html">memlog</a> { |
| 107 | <a name="l00042"></a>00042 <span class="keyword">public</span>: |
| 108 | <a name="l00044"></a><a class="code" href="classbdm_1_1mexlog.html#ac458d92bb26518c908521a8c9460a2c1">00044</a> <a class="code" href="classbdm_1_1mexlog.html#ac458d92bb26518c908521a8c9460a2c1" title="constructor">mexlog</a>() : <a class="code" href="classbdm_1_1memlog.html">memlog</a> ( 0, <span class="stringliteral">""</span> ) {}; |
| 109 | <a name="l00046"></a>00046 mxArray* toCell() { |
| 110 | <a name="l00047"></a>00047 mxArray* tmp = mxCreateStructMatrix ( 1, 1, 0, NULL ); |
| 111 | <a name="l00048"></a>00048 |
| 112 | <a name="l00049"></a>00049 <span class="comment">//copied from itsave</span> |
| 113 | <a name="l00050"></a>00050 <span class="keywordtype">int</span> i; |
| 114 | <a name="l00051"></a>00051 <span class="keywordtype">string</span> vec_name = <span class="stringliteral">""</span>; |
| 115 | <a name="l00052"></a>00052 <span class="keywordtype">int</span> istart, iend; |
| 116 | <a name="l00053"></a>00053 |
| 117 | <a name="l00054"></a>00054 mat M; <span class="comment">//temporary matrix</span> |
| 118 | <a name="l00055"></a>00055 <span class="keywordflow">for</span> ( i = 0; i < <a class="code" href="classbdm_1_1logger.html#ac54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a>.length(); i++ ) { |
| 119 | <a name="l00056"></a>00056 istart = 0; |
| 120 | <a name="l00057"></a>00057 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> j = 0; j < <a class="code" href="classbdm_1_1logger.html#ac54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a> ( i ).length(); j++ ) { <span class="comment">// same for as in add!!!</span> |
| 121 | <a name="l00058"></a>00058 vec_name = <a class="code" href="classbdm_1_1logger.html#a68ca1f05cf3d414ba0f39211977b8d02" title="Names of logged quantities, e.g. names of algorithm variants.">names</a> ( i ) + <a class="code" href="classbdm_1_1logger.html#ac54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a> ( i ).name ( j ); |
| 122 | <a name="l00059"></a>00059 iend = istart + <a class="code" href="classbdm_1_1logger.html#ac54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a> ( i ).size ( j ) - 1; |
| 123 | <a name="l00060"></a>00060 M = <a class="code" href="classbdm_1_1memlog.html#a1fed143162f2de6ef1c1b6557964f24e" title="Storage.">vectors</a> ( i ).get_cols ( istart, iend ); |
| 124 | <a name="l00061"></a>00061 istart = iend + 1; |
| 125 | <a name="l00062"></a>00062 <span class="comment">// copy the selection to mx</span> |
| 126 | <a name="l00063"></a>00063 mxArray* fld = mxCreateDoubleMatrix ( M.rows(), M.cols(), mxREAL ); |
| 127 | <a name="l00064"></a>00064 mat2mxArray ( M, fld ); |
| 128 | <a name="l00065"></a>00065 mxReplaceFieldNM ( tmp, vec_name.c_str(), fld ); |
| 129 | <a name="l00066"></a>00066 } |
| 130 | <a name="l00067"></a>00067 } |
| 131 | <a name="l00068"></a>00068 <span class="keywordflow">return</span> tmp; |
| 132 | <a name="l00069"></a>00069 } |
| 133 | <a name="l00070"></a><a class="code" href="classbdm_1_1mexlog.html#a39c44b30f201091ab3d287fe5741113e">00070</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mexlog.html#a39c44b30f201091ab3d287fe5741113e" title="UI for memlog.">from_setting</a> ( <span class="keyword">const</span> Setting &<a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> ) { |
| 134 | <a name="l00071"></a>00071 <a class="code" href="classbdm_1_1memlog.html#aa690ebd91430b5973855c9b4c9cf1b1d" title="Maximum length of vectors stored in memory.">maxlen</a> = root[<span class="stringliteral">"maxlen"</span>]; |
| 135 | <a name="l00072"></a>00072 } |
| 136 | <a name="l00073"></a>00073 }; |
| 137 | <a name="l00074"></a>00074 <a class="code" href="user__info_8h.html#a4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a> ( mexlog ); |
| 138 | <a name="l00075"></a>00075 SHAREDPTR ( mexlog ); |