[353] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
| 2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
---|
| 3 | <title>mixpp: min_max.h Source File</title> |
---|
| 4 | <link href="tabs.css" rel="stylesheet" type="text/css"> |
---|
| 5 | <link href="doxygen.css" rel="stylesheet" type="text/css"> |
---|
| 6 | </head><body> |
---|
| 7 | <!-- Generated by Doxygen 1.5.8 --> |
---|
| 8 | <script type="text/javascript"> |
---|
| 9 | <!-- |
---|
| 10 | function changeDisplayState (e){ |
---|
| 11 | var num=this.id.replace(/[^[0-9]/g,''); |
---|
| 12 | var button=this.firstChild; |
---|
| 13 | var sectionDiv=document.getElementById('dynsection'+num); |
---|
| 14 | if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){ |
---|
| 15 | sectionDiv.style.display='block'; |
---|
| 16 | button.src='open.gif'; |
---|
| 17 | }else{ |
---|
| 18 | sectionDiv.style.display='none'; |
---|
| 19 | button.src='closed.gif'; |
---|
| 20 | } |
---|
| 21 | } |
---|
| 22 | function initDynSections(){ |
---|
| 23 | var divs=document.getElementsByTagName('div'); |
---|
| 24 | var sectionCounter=1; |
---|
| 25 | for(var i=0;i<divs.length-1;i++){ |
---|
| 26 | if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){ |
---|
| 27 | var header=divs[i]; |
---|
| 28 | var section=divs[i+1]; |
---|
| 29 | var button=header.firstChild; |
---|
| 30 | if (button!='IMG'){ |
---|
| 31 | divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild); |
---|
| 32 | button=document.createElement('img'); |
---|
| 33 | divs[i].insertBefore(button,divs[i].firstChild); |
---|
| 34 | } |
---|
| 35 | header.style.cursor='pointer'; |
---|
| 36 | header.onclick=changeDisplayState; |
---|
| 37 | header.id='dynheader'+sectionCounter; |
---|
| 38 | button.src='closed.gif'; |
---|
| 39 | section.id='dynsection'+sectionCounter; |
---|
| 40 | section.style.display='none'; |
---|
| 41 | section.style.marginLeft='14px'; |
---|
| 42 | sectionCounter++; |
---|
| 43 | } |
---|
| 44 | } |
---|
| 45 | } |
---|
| 46 | window.onload = initDynSections; |
---|
| 47 | --> |
---|
| 48 | </script> |
---|
| 49 | <div class="navigation" id="top"> |
---|
| 50 | <div class="tabs"> |
---|
| 51 | <ul> |
---|
| 52 | <li><a href="main.html"><span>Main Page</span></a></li> |
---|
| 53 | <li><a href="pages.html"><span>Related Pages</span></a></li> |
---|
| 54 | <li><a href="modules.html"><span>Modules</span></a></li> |
---|
| 55 | <li><a href="annotated.html"><span>Classes</span></a></li> |
---|
| 56 | <li class="current"><a href="files.html"><span>Files</span></a></li> |
---|
| 57 | </ul> |
---|
| 58 | </div> |
---|
| 59 | <div class="tabs"> |
---|
| 60 | <ul> |
---|
| 61 | <li><a href="files.html"><span>File List</span></a></li> |
---|
| 62 | <li><a href="globals.html"><span>File Members</span></a></li> |
---|
| 63 | </ul> |
---|
| 64 | </div> |
---|
| 65 | <h1>min_max.h</h1><a href="min__max_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 |
---|
| 66 | <a name="l00029"></a>00029 <span class="preprocessor">#ifndef MIN_MAX_H</span> |
---|
| 67 | <a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#define MIN_MAX_H</span> |
---|
| 68 | <a name="l00031"></a>00031 <span class="preprocessor"></span> |
---|
| 69 | <a name="l00032"></a>00032 <span class="preprocessor">#include <<a class="code" href="mat_8h.html" title="Matrix Class Definitions.">itpp/base/mat.h</a>></span> |
---|
| 70 | <a name="l00033"></a>00033 |
---|
| 71 | <a name="l00034"></a>00034 |
---|
| 72 | <a name="l00035"></a>00035 <span class="keyword">namespace </span>itpp |
---|
| 73 | <a name="l00036"></a>00036 { |
---|
| 74 | <a name="l00037"></a>00037 |
---|
| 75 | <a name="l00043"></a>00043 |
---|
| 76 | <a name="l00044"></a>00044 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
| 77 | <a name="l00045"></a><a class="code" href="group__miscfunc.html#g343007ee24cfd630e8addeddd1d08e7d">00045</a> T <a class="code" href="group__protocol.html#g3e4e78a5230c444344a135c661163ef2" title="ADD DOCUMENTATION HERE.">max</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> &v) |
---|
| 78 | <a name="l00046"></a>00046 { |
---|
| 79 | <a name="l00047"></a>00047 T maxdata = v(0); |
---|
| 80 | <a name="l00048"></a>00048 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i < v.<a class="code" href="classitpp_1_1Vec.html#44478ea086eda22a180102e77e352325" title="The size of the vector.">length</a>(); i++) |
---|
| 81 | <a name="l00049"></a>00049 <span class="keywordflow">if</span> (v(i) > maxdata) |
---|
| 82 | <a name="l00050"></a>00050 maxdata = v(i); |
---|
| 83 | <a name="l00051"></a>00051 <span class="keywordflow">return</span> maxdata; |
---|
| 84 | <a name="l00052"></a>00052 } |
---|
| 85 | <a name="l00053"></a>00053 |
---|
| 86 | <a name="l00055"></a>00055 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
| 87 | <a name="l00056"></a><a class="code" href="group__miscfunc.html#gc4d4c2bbccf09020c0dbae63b4bab9e4">00056</a> T <a class="code" href="group__protocol.html#g3e4e78a5230c444344a135c661163ef2" title="ADD DOCUMENTATION HERE.">max</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> &v, <span class="keywordtype">int</span>& index) |
---|
| 88 | <a name="l00057"></a>00057 { |
---|
| 89 | <a name="l00058"></a>00058 T maxdata = v(0); |
---|
| 90 | <a name="l00059"></a>00059 index = 0; |
---|
| 91 | <a name="l00060"></a>00060 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i < v.<a class="code" href="classitpp_1_1Vec.html#44478ea086eda22a180102e77e352325" title="The size of the vector.">length</a>(); i++) |
---|
| 92 | <a name="l00061"></a>00061 <span class="keywordflow">if</span> (v(i) > maxdata) { |
---|
| 93 | <a name="l00062"></a>00062 maxdata = v(i); |
---|
| 94 | <a name="l00063"></a>00063 index = i; |
---|
| 95 | <a name="l00064"></a>00064 } |
---|
| 96 | <a name="l00065"></a>00065 <span class="keywordflow">return</span> maxdata; |
---|
| 97 | <a name="l00066"></a>00066 } |
---|
| 98 | <a name="l00067"></a>00067 |
---|
| 99 | <a name="l00075"></a>00075 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
| 100 | <a name="l00076"></a><a class="code" href="group__miscfunc.html#g6a2e3146dc6660a22a638f0beb5d4890">00076</a> <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> <a class="code" href="group__protocol.html#g3e4e78a5230c444344a135c661163ef2" title="ADD DOCUMENTATION HERE.">max</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Mat.html">Mat<T></a> &m, <span class="keywordtype">int</span> dim = 1) |
---|
| 101 | <a name="l00077"></a>00077 { |
---|
| 102 | <a name="l00078"></a>00078 <a class="code" href="group__errorhandlingfunc.html#gd5c34b291e5018534fd2344486e2b5a1" title="Abort if t is not true.">it_assert</a>((dim == 1) || (dim == 2), <span class="stringliteral">"max(): dimension need to be 1 or 2"</span>); |
---|
| 103 | <a name="l00079"></a>00079 <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> out; |
---|
| 104 | <a name="l00080"></a>00080 <span class="keywordflow">if</span> (dim == 1) { |
---|
| 105 | <a name="l00081"></a>00081 out.<a class="code" href="classitpp_1_1Vec.html#a4b02b7819e540bb3853c15e6480ada6" title="Set length of vector. if copy = true then keeping the old values.">set_size</a>(m.<a class="code" href="classitpp_1_1Mat.html#49680ef454d1d75b737e3ce157f1ac7b" title="The number of columns.">cols</a>(), <span class="keyword">false</span>); |
---|
| 106 | <a name="l00082"></a>00082 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < m.<a class="code" href="classitpp_1_1Mat.html#49680ef454d1d75b737e3ce157f1ac7b" title="The number of columns.">cols</a>(); i++) |
---|
| 107 | <a name="l00083"></a>00083 out(i) = <a class="code" href="group__protocol.html#g3e4e78a5230c444344a135c661163ef2" title="ADD DOCUMENTATION HERE.">max</a>(m.<a class="code" href="classitpp_1_1Mat.html#095a4e54f39932b62633f7f4f252ab46" title="Get column c.">get_col</a>(i)); |
---|
| 108 | <a name="l00084"></a>00084 } |
---|
| 109 | <a name="l00085"></a>00085 <span class="keywordflow">else</span> { |
---|
| 110 | <a name="l00086"></a>00086 out.<a class="code" href="classitpp_1_1Vec.html#a4b02b7819e540bb3853c15e6480ada6" title="Set length of vector. if copy = true then keeping the old values.">set_size</a>(m.<a class="code" href="classitpp_1_1Mat.html#f3028609c01e08fb07c5bf0bcd4c4e03" title="The number of rows.">rows</a>(), <span class="keyword">false</span>); |
---|
| 111 | <a name="l00087"></a>00087 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < m.<a class="code" href="classitpp_1_1Mat.html#f3028609c01e08fb07c5bf0bcd4c4e03" title="The number of rows.">rows</a>(); i++) |
---|
| 112 | <a name="l00088"></a>00088 out(i) = <a class="code" href="group__protocol.html#g3e4e78a5230c444344a135c661163ef2" title="ADD DOCUMENTATION HERE.">max</a>(m.<a class="code" href="classitpp_1_1Mat.html#9e840908b256dd1353845356b9ffacb2" title="Get row r.">get_row</a>(i)); |
---|
| 113 | <a name="l00089"></a>00089 } |
---|
| 114 | <a name="l00090"></a>00090 <span class="keywordflow">return</span> out; |
---|
| 115 | <a name="l00091"></a>00091 } |
---|
| 116 | <a name="l00092"></a>00092 |
---|
| 117 | <a name="l00103"></a>00103 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
| 118 | <a name="l00104"></a><a class="code" href="group__miscfunc.html#g6c6b391182d4c7b828169e50c362e6c7">00104</a> <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> <a class="code" href="group__protocol.html#g3e4e78a5230c444344a135c661163ef2" title="ADD DOCUMENTATION HERE.">max</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Mat.html">Mat<T></a> &m, ivec &index, <span class="keywordtype">int</span> dim = 1) |
---|
| 119 | <a name="l00105"></a>00105 { |
---|
| 120 | <a name="l00106"></a>00106 <a class="code" href="group__errorhandlingfunc.html#gd5c34b291e5018534fd2344486e2b5a1" title="Abort if t is not true.">it_assert</a>((dim == 1) || (dim == 2), <span class="stringliteral">"max(): dimension need to be 1 or 2"</span>); |
---|
| 121 | <a name="l00107"></a>00107 <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> out; |
---|
| 122 | <a name="l00108"></a>00108 <span class="keywordflow">if</span> (dim == 1) { |
---|
| 123 | <a name="l00109"></a>00109 out.<a class="code" href="classitpp_1_1Vec.html#a4b02b7819e540bb3853c15e6480ada6" title="Set length of vector. if copy = true then keeping the old values.">set_size</a>(m.<a class="code" href="classitpp_1_1Mat.html#49680ef454d1d75b737e3ce157f1ac7b" title="The number of columns.">cols</a>(), <span class="keyword">false</span>); |
---|
| 124 | <a name="l00110"></a>00110 index.set_size(m.<a class="code" href="classitpp_1_1Mat.html#49680ef454d1d75b737e3ce157f1ac7b" title="The number of columns.">cols</a>(), <span class="keyword">false</span>); |
---|
| 125 | <a name="l00111"></a>00111 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < m.<a class="code" href="classitpp_1_1Mat.html#49680ef454d1d75b737e3ce157f1ac7b" title="The number of columns.">cols</a>(); i++) |
---|
| 126 | <a name="l00112"></a>00112 out(i) = <a class="code" href="group__protocol.html#g3e4e78a5230c444344a135c661163ef2" title="ADD DOCUMENTATION HERE.">max</a>(m.<a class="code" href="classitpp_1_1Mat.html#095a4e54f39932b62633f7f4f252ab46" title="Get column c.">get_col</a>(i), index(i)); |
---|
| 127 | <a name="l00113"></a>00113 } |
---|
| 128 | <a name="l00114"></a>00114 <span class="keywordflow">else</span> { |
---|
| 129 | <a name="l00115"></a>00115 out.<a class="code" href="classitpp_1_1Vec.html#a4b02b7819e540bb3853c15e6480ada6" title="Set length of vector. if copy = true then keeping the old values.">set_size</a>(m.<a class="code" href="classitpp_1_1Mat.html#f3028609c01e08fb07c5bf0bcd4c4e03" title="The number of rows.">rows</a>(), <span class="keyword">false</span>); |
---|
| 130 | <a name="l00116"></a>00116 index.set_size(m.<a class="code" href="classitpp_1_1Mat.html#f3028609c01e08fb07c5bf0bcd4c4e03" title="The number of rows.">rows</a>(), <span class="keyword">false</span>); |
---|
| 131 | <a name="l00117"></a>00117 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < m.<a class="code" href="classitpp_1_1Mat.html#f3028609c01e08fb07c5bf0bcd4c4e03" title="The number of rows.">rows</a>(); i++) |
---|
| 132 | <a name="l00118"></a>00118 out(i) = <a class="code" href="group__protocol.html#g3e4e78a5230c444344a135c661163ef2" title="ADD DOCUMENTATION HERE.">max</a>(m.<a class="code" href="classitpp_1_1Mat.html#9e840908b256dd1353845356b9ffacb2" title="Get row r.">get_row</a>(i), index(i)); |
---|
| 133 | <a name="l00119"></a>00119 } |
---|
| 134 | <a name="l00120"></a>00120 <span class="keywordflow">return</span> out; |
---|
| 135 | <a name="l00121"></a>00121 } |
---|
| 136 | <a name="l00122"></a>00122 |
---|
| 137 | <a name="l00124"></a>00124 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
| 138 | <a name="l00125"></a><a class="code" href="group__miscfunc.html#g814aaa20dabe8eeb87c95116491a0341">00125</a> T <a class="code" href="group__protocol.html#g27dde5be5aac902c0de838b4b872cd2f" title="ADD DOCUMENTATION HERE.">min</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> &in) |
---|
| 139 | <a name="l00126"></a>00126 { |
---|
| 140 | <a name="l00127"></a>00127 T mindata = in[0]; |
---|
| 141 | <a name="l00128"></a>00128 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i < in.<a class="code" href="classitpp_1_1Vec.html#44478ea086eda22a180102e77e352325" title="The size of the vector.">length</a>(); i++) |
---|
| 142 | <a name="l00129"></a>00129 <span class="keywordflow">if</span> (in[i] < mindata) |
---|
| 143 | <a name="l00130"></a>00130 mindata = in[i]; |
---|
| 144 | <a name="l00131"></a>00131 <span class="keywordflow">return</span> mindata; |
---|
| 145 | <a name="l00132"></a>00132 } |
---|
| 146 | <a name="l00133"></a>00133 |
---|
| 147 | <a name="l00135"></a>00135 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
| 148 | <a name="l00136"></a><a class="code" href="group__miscfunc.html#g113f9fcb7a0fe030d2a396fabb451986">00136</a> T <a class="code" href="group__protocol.html#g27dde5be5aac902c0de838b4b872cd2f" title="ADD DOCUMENTATION HERE.">min</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> &in, <span class="keywordtype">int</span>& index) |
---|
| 149 | <a name="l00137"></a>00137 { |
---|
| 150 | <a name="l00138"></a>00138 T mindata = in[0]; |
---|
| 151 | <a name="l00139"></a>00139 index = 0; |
---|
| 152 | <a name="l00140"></a>00140 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i < in.<a class="code" href="classitpp_1_1Vec.html#44478ea086eda22a180102e77e352325" title="The size of the vector.">length</a>(); i++) |
---|
| 153 | <a name="l00141"></a>00141 <span class="keywordflow">if</span> (in[i] < mindata) { |
---|
| 154 | <a name="l00142"></a>00142 mindata = in[i]; |
---|
| 155 | <a name="l00143"></a>00143 index = i; |
---|
| 156 | <a name="l00144"></a>00144 } |
---|
| 157 | <a name="l00145"></a>00145 <span class="keywordflow">return</span> mindata; |
---|
| 158 | <a name="l00146"></a>00146 } |
---|
| 159 | <a name="l00147"></a>00147 |
---|
| 160 | <a name="l00148"></a>00148 |
---|
| 161 | <a name="l00156"></a>00156 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
| 162 | <a name="l00157"></a><a class="code" href="group__miscfunc.html#gb616f826275be6d5a140770c73bcc391">00157</a> <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> <a class="code" href="group__protocol.html#g27dde5be5aac902c0de838b4b872cd2f" title="ADD DOCUMENTATION HERE.">min</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Mat.html">Mat<T></a> &m, <span class="keywordtype">int</span> dim = 1) |
---|
| 163 | <a name="l00158"></a>00158 { |
---|
| 164 | <a name="l00159"></a>00159 <a class="code" href="group__errorhandlingfunc.html#gd5c34b291e5018534fd2344486e2b5a1" title="Abort if t is not true.">it_assert</a>((dim == 1) || (dim == 2), <span class="stringliteral">"min(): dimension need to be 1 or 2"</span>); |
---|
| 165 | <a name="l00160"></a>00160 <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> out; |
---|
| 166 | <a name="l00161"></a>00161 <span class="keywordflow">if</span> (dim == 1) { |
---|
| 167 | <a name="l00162"></a>00162 out.<a class="code" href="classitpp_1_1Vec.html#a4b02b7819e540bb3853c15e6480ada6" title="Set length of vector. if copy = true then keeping the old values.">set_size</a>(m.<a class="code" href="classitpp_1_1Mat.html#49680ef454d1d75b737e3ce157f1ac7b" title="The number of columns.">cols</a>(), <span class="keyword">false</span>); |
---|
| 168 | <a name="l00163"></a>00163 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < m.<a class="code" href="classitpp_1_1Mat.html#49680ef454d1d75b737e3ce157f1ac7b" title="The number of columns.">cols</a>(); i++) |
---|
| 169 | <a name="l00164"></a>00164 out(i) = <a class="code" href="group__protocol.html#g27dde5be5aac902c0de838b4b872cd2f" title="ADD DOCUMENTATION HERE.">min</a>(m.<a class="code" href="classitpp_1_1Mat.html#095a4e54f39932b62633f7f4f252ab46" title="Get column c.">get_col</a>(i)); |
---|
| 170 | <a name="l00165"></a>00165 } |
---|
| 171 | <a name="l00166"></a>00166 <span class="keywordflow">else</span> { |
---|
| 172 | <a name="l00167"></a>00167 out.<a class="code" href="classitpp_1_1Vec.html#a4b02b7819e540bb3853c15e6480ada6" title="Set length of vector. if copy = true then keeping the old values.">set_size</a>(m.<a class="code" href="classitpp_1_1Mat.html#f3028609c01e08fb07c5bf0bcd4c4e03" title="The number of rows.">rows</a>(), <span class="keyword">false</span>); |
---|
| 173 | <a name="l00168"></a>00168 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < m.<a class="code" href="classitpp_1_1Mat.html#f3028609c01e08fb07c5bf0bcd4c4e03" title="The number of rows.">rows</a>(); i++) |
---|
| 174 | <a name="l00169"></a>00169 out(i) = <a class="code" href="group__protocol.html#g27dde5be5aac902c0de838b4b872cd2f" title="ADD DOCUMENTATION HERE.">min</a>(m.<a class="code" href="classitpp_1_1Mat.html#9e840908b256dd1353845356b9ffacb2" title="Get row r.">get_row</a>(i)); |
---|
| 175 | <a name="l00170"></a>00170 } |
---|
| 176 | <a name="l00171"></a>00171 <span class="keywordflow">return</span> out; |
---|
| 177 | <a name="l00172"></a>00172 } |
---|
| 178 | <a name="l00173"></a>00173 |
---|
| 179 | <a name="l00174"></a>00174 |
---|
| 180 | <a name="l00185"></a>00185 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
| 181 | <a name="l00186"></a><a class="code" href="group__miscfunc.html#gaa13aea7c1f0fd0d205a9555c2f4efc1">00186</a> <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> <a class="code" href="group__protocol.html#g27dde5be5aac902c0de838b4b872cd2f" title="ADD DOCUMENTATION HERE.">min</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Mat.html">Mat<T></a> &m, ivec &index, <span class="keywordtype">int</span> dim = 1) |
---|
| 182 | <a name="l00187"></a>00187 { |
---|
| 183 | <a name="l00188"></a>00188 <a class="code" href="group__errorhandlingfunc.html#gd5c34b291e5018534fd2344486e2b5a1" title="Abort if t is not true.">it_assert</a>((dim == 1) || (dim == 2), <span class="stringliteral">"min(): dimension need to be 1 or 2"</span>); |
---|
| 184 | <a name="l00189"></a>00189 <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> out; |
---|
| 185 | <a name="l00190"></a>00190 <span class="keywordflow">if</span> (dim == 1) { |
---|
| 186 | <a name="l00191"></a>00191 out.<a class="code" href="classitpp_1_1Vec.html#a4b02b7819e540bb3853c15e6480ada6" title="Set length of vector. if copy = true then keeping the old values.">set_size</a>(m.<a class="code" href="classitpp_1_1Mat.html#49680ef454d1d75b737e3ce157f1ac7b" title="The number of columns.">cols</a>(), <span class="keyword">false</span>); |
---|
| 187 | <a name="l00192"></a>00192 index.set_size(m.<a class="code" href="classitpp_1_1Mat.html#49680ef454d1d75b737e3ce157f1ac7b" title="The number of columns.">cols</a>(), <span class="keyword">false</span>); |
---|
| 188 | <a name="l00193"></a>00193 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < m.<a class="code" href="classitpp_1_1Mat.html#49680ef454d1d75b737e3ce157f1ac7b" title="The number of columns.">cols</a>(); i++) |
---|
| 189 | <a name="l00194"></a>00194 out(i) = <a class="code" href="group__protocol.html#g27dde5be5aac902c0de838b4b872cd2f" title="ADD DOCUMENTATION HERE.">min</a>(m.<a class="code" href="classitpp_1_1Mat.html#095a4e54f39932b62633f7f4f252ab46" title="Get column c.">get_col</a>(i), index(i)); |
---|
| 190 | <a name="l00195"></a>00195 } |
---|
| 191 | <a name="l00196"></a>00196 <span class="keywordflow">else</span> { |
---|
| 192 | <a name="l00197"></a>00197 out.<a class="code" href="classitpp_1_1Vec.html#a4b02b7819e540bb3853c15e6480ada6" title="Set length of vector. if copy = true then keeping the old values.">set_size</a>(m.<a class="code" href="classitpp_1_1Mat.html#f3028609c01e08fb07c5bf0bcd4c4e03" title="The number of rows.">rows</a>(), <span class="keyword">false</span>); |
---|
| 193 | <a name="l00198"></a>00198 index.set_size(m.<a class="code" href="classitpp_1_1Mat.html#f3028609c01e08fb07c5bf0bcd4c4e03" title="The number of rows.">rows</a>(), <span class="keyword">false</span>); |
---|
| 194 | <a name="l00199"></a>00199 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < m.<a class="code" href="classitpp_1_1Mat.html#f3028609c01e08fb07c5bf0bcd4c4e03" title="The number of rows.">rows</a>(); i++) |
---|
| 195 | <a name="l00200"></a>00200 out(i) = <a class="code" href="group__protocol.html#g27dde5be5aac902c0de838b4b872cd2f" title="ADD DOCUMENTATION HERE.">min</a>(m.<a class="code" href="classitpp_1_1Mat.html#9e840908b256dd1353845356b9ffacb2" title="Get row r.">get_row</a>(i), index(i)); |
---|
| 196 | <a name="l00201"></a>00201 } |
---|
| 197 | <a name="l00202"></a>00202 <span class="keywordflow">return</span> out; |
---|
| 198 | <a name="l00203"></a>00203 } |
---|
| 199 | <a name="l00204"></a>00204 |
---|
| 200 | <a name="l00205"></a>00205 |
---|
| 201 | <a name="l00207"></a>00207 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
| 202 | <a name="l00208"></a><a class="code" href="group__miscfunc.html#g216641fd7fa3b5c760f3d824b7adbe40">00208</a> <span class="keywordtype">int</span> <a class="code" href="group__miscfunc.html#gf946a722644d53040d3c4e363646a39b" title="Return the postion of the maximum element in the matrix.">max_index</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> &in) |
---|
| 203 | <a name="l00209"></a>00209 { |
---|
| 204 | <a name="l00210"></a>00210 <span class="keywordtype">int</span> maxindex = 0; |
---|
| 205 | <a name="l00211"></a>00211 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i < in.<a class="code" href="classitpp_1_1Vec.html#44478ea086eda22a180102e77e352325" title="The size of the vector.">length</a>(); i++) |
---|
| 206 | <a name="l00212"></a>00212 <span class="keywordflow">if</span> (in[i] > in[maxindex]) |
---|
| 207 | <a name="l00213"></a>00213 maxindex = i; |
---|
| 208 | <a name="l00214"></a>00214 <span class="keywordflow">return</span> maxindex; |
---|
| 209 | <a name="l00215"></a>00215 } |
---|
| 210 | <a name="l00216"></a>00216 |
---|
| 211 | <a name="l00218"></a>00218 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
| 212 | <a name="l00219"></a><a class="code" href="group__miscfunc.html#gf946a722644d53040d3c4e363646a39b">00219</a> <span class="keywordtype">void</span> <a class="code" href="group__miscfunc.html#gf946a722644d53040d3c4e363646a39b" title="Return the postion of the maximum element in the matrix.">max_index</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Mat.html">Mat<T></a> &m, <span class="keywordtype">int</span> &row, <span class="keywordtype">int</span> &col) |
---|
| 213 | <a name="l00220"></a>00220 { |
---|
| 214 | <a name="l00221"></a>00221 T maxdata = m(0, 0); |
---|
| 215 | <a name="l00222"></a>00222 row = col = 0; |
---|
| 216 | <a name="l00223"></a>00223 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < m.<a class="code" href="classitpp_1_1Mat.html#f3028609c01e08fb07c5bf0bcd4c4e03" title="The number of rows.">rows</a>(); i++) |
---|
| 217 | <a name="l00224"></a>00224 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j < m.<a class="code" href="classitpp_1_1Mat.html#49680ef454d1d75b737e3ce157f1ac7b" title="The number of columns.">cols</a>(); j++) |
---|
| 218 | <a name="l00225"></a>00225 <span class="keywordflow">if</span> (m(i, j) > maxdata) { |
---|
| 219 | <a name="l00226"></a>00226 row = i; |
---|
| 220 | <a name="l00227"></a>00227 col = j; |
---|
| 221 | <a name="l00228"></a>00228 maxdata = m(i, j); |
---|
| 222 | <a name="l00229"></a>00229 } |
---|
| 223 | <a name="l00230"></a>00230 } |
---|
| 224 | <a name="l00231"></a>00231 |
---|
| 225 | <a name="l00233"></a>00233 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
| 226 | <a name="l00234"></a><a class="code" href="group__miscfunc.html#g8bb63df4ea7bd2ae57e6ff877e8e2892">00234</a> <span class="keywordtype">int</span> <a class="code" href="group__miscfunc.html#g30831e540d60212e23437cc259253f2f" title="Return the postion of the minimum element in the matrix.">min_index</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> &in) |
---|
| 227 | <a name="l00235"></a>00235 { |
---|
| 228 | <a name="l00236"></a>00236 <span class="keywordtype">int</span> minindex = 0; |
---|
| 229 | <a name="l00237"></a>00237 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i < in.<a class="code" href="classitpp_1_1Vec.html#44478ea086eda22a180102e77e352325" title="The size of the vector.">length</a>(); i++) |
---|
| 230 | <a name="l00238"></a>00238 <span class="keywordflow">if</span> (in[i] < in[minindex]) |
---|
| 231 | <a name="l00239"></a>00239 minindex = i; |
---|
| 232 | <a name="l00240"></a>00240 <span class="keywordflow">return</span> minindex; |
---|
| 233 | <a name="l00241"></a>00241 } |
---|
| 234 | <a name="l00242"></a>00242 |
---|
| 235 | <a name="l00244"></a>00244 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
| 236 | <a name="l00245"></a><a class="code" href="group__miscfunc.html#g30831e540d60212e23437cc259253f2f">00245</a> <span class="keywordtype">void</span> <a class="code" href="group__miscfunc.html#g30831e540d60212e23437cc259253f2f" title="Return the postion of the minimum element in the matrix.">min_index</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Mat.html">Mat<T></a> &m, <span class="keywordtype">int</span> &row, <span class="keywordtype">int</span> &col) |
---|
| 237 | <a name="l00246"></a>00246 { |
---|
| 238 | <a name="l00247"></a>00247 T mindata = m(0, 0); |
---|
| 239 | <a name="l00248"></a>00248 row = col = 0; |
---|
| 240 | <a name="l00249"></a>00249 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < m.<a class="code" href="classitpp_1_1Mat.html#f3028609c01e08fb07c5bf0bcd4c4e03" title="The number of rows.">rows</a>(); i++) |
---|
| 241 | <a name="l00250"></a>00250 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j < m.<a class="code" href="classitpp_1_1Mat.html#49680ef454d1d75b737e3ce157f1ac7b" title="The number of columns.">cols</a>(); j++) |
---|
| 242 | <a name="l00251"></a>00251 <span class="keywordflow">if</span> (m(i, j) < mindata) { |
---|
| 243 | <a name="l00252"></a>00252 row = i; |
---|
| 244 | <a name="l00253"></a>00253 col = j; |
---|
| 245 | <a name="l00254"></a>00254 mindata = m(i, j); |
---|
| 246 | <a name="l00255"></a>00255 } |
---|
| 247 | <a name="l00256"></a>00256 } |
---|
| 248 | <a name="l00257"></a>00257 |
---|
| 249 | <a name="l00262"></a>00262 } <span class="comment">//namespace itpp</span> |
---|
| 250 | <a name="l00263"></a>00263 |
---|
| 251 | <a name="l00264"></a>00264 |
---|
| 252 | <a name="l00265"></a>00265 <span class="preprocessor">#endif </span><span class="comment">/* MIN_MAX_H */</span> |
---|
| 253 | </pre></div></div> |
---|
| 254 | <hr size="1"><address style="text-align: right;"><small>Generated on Tue Jun 2 10:02:12 2009 for mixpp by |
---|
| 255 | <a href="http://www.doxygen.org/index.html"> |
---|
| 256 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address> |
---|
| 257 | </body> |
---|
| 258 | </html> |
---|