root/doc/html/misc_8h-source.html @ 353

Revision 353, 10.0 kB (checked in by smidl, 16 years ago)

doc

RevLine 
[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: misc.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<!--
10function 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}
22function 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}
46window.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&nbsp;Page</span></a></li>
53      <li><a href="pages.html"><span>Related&nbsp;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&nbsp;List</span></a></li>
62      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
63    </ul>
64  </div>
65<h1>misc.h</h1><a href="misc_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 MISC_H</span>
67<a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#define MISC_H</span>
68<a name="l00031"></a>00031 <span class="preprocessor"></span>
69<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;complex&gt;</span>
70<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;string&gt;</span>
71<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;limits&gt;</span>
72<a name="l00035"></a>00035
73<a name="l00036"></a>00036
74<a name="l00037"></a>00037 <span class="keyword">namespace </span>std
75<a name="l00038"></a>00038 {
76<a name="l00039"></a>00039
77<a name="l00041"></a>00041 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
78<a name="l00042"></a>00042 std::ostream&amp; operator&lt;&lt;(std::ostream &amp;os, const std::complex&lt;T&gt; &amp;x)
79<a name="l00043"></a>00043 {
80<a name="l00044"></a>00044   os &lt;&lt; x.real();
81<a name="l00045"></a>00045   ios::fmtflags saved_format = os.setf(ios::showpos);
82<a name="l00046"></a>00046   os &lt;&lt; x.imag();
83<a name="l00047"></a>00047   os.setf(saved_format, ios::showpos);
84<a name="l00048"></a>00048   <span class="keywordflow">return</span> os &lt;&lt; <span class="charliteral">'i'</span>;
85<a name="l00049"></a>00049 }
86<a name="l00050"></a>00050
87<a name="l00052"></a>00052 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
88<a name="l00053"></a>00053 std::istream&amp; <a class="code" href="group__fixed.html#gbd223815e04b623a044d98fd366f3a0f" title="Input bit representation and, optionally, the shift.">operator&gt;&gt;</a>(std::istream &amp;is, std::complex&lt;T&gt; &amp;x)
89<a name="l00054"></a>00054 {
90<a name="l00055"></a>00055   T re, im;
91<a name="l00056"></a>00056   <span class="keywordtype">char</span> c;
92<a name="l00057"></a>00057   is &gt;&gt; c;
93<a name="l00058"></a>00058   <span class="keywordflow">if</span> (c == <span class="charliteral">'('</span>) {
94<a name="l00059"></a>00059     is &gt;&gt; re &gt;&gt; c;
95<a name="l00060"></a>00060     <span class="keywordflow">if</span> (c == <span class="charliteral">','</span>) {
96<a name="l00061"></a>00061       is &gt;&gt; im &gt;&gt; c;
97<a name="l00062"></a>00062       <span class="keywordflow">if</span> (c == <span class="charliteral">')'</span>) {
98<a name="l00063"></a>00063         x = complex&lt;T&gt;(re, im);
99<a name="l00064"></a>00064       }
100<a name="l00065"></a>00065       <span class="keywordflow">else</span> {
101<a name="l00066"></a>00066         is.setstate(ios_base::failbit);
102<a name="l00067"></a>00067       }
103<a name="l00068"></a>00068     }
104<a name="l00069"></a>00069     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (c == <span class="charliteral">')'</span>) {
105<a name="l00070"></a>00070       x = complex&lt;T&gt;(re, T(0));
106<a name="l00071"></a>00071     }
107<a name="l00072"></a>00072     <span class="keywordflow">else</span> {
108<a name="l00073"></a>00073       is.setstate(ios_base::failbit);
109<a name="l00074"></a>00074     }
110<a name="l00075"></a>00075   }
111<a name="l00076"></a>00076   <span class="keywordflow">else</span> {
112<a name="l00077"></a>00077     is.putback(c);
113<a name="l00078"></a>00078     is &gt;&gt; re;
114<a name="l00079"></a>00079     <span class="keywordflow">if</span> (!is.eof() &amp;&amp; ((c = <span class="keyword">static_cast&lt;</span><span class="keywordtype">char</span><span class="keyword">&gt;</span>(is.peek())) == <span class="charliteral">'+'</span> || c == <span class="charliteral">'-'</span>)) {
115<a name="l00080"></a>00080       is &gt;&gt; im &gt;&gt; c;
116<a name="l00081"></a>00081       <span class="keywordflow">if</span> (c == <span class="charliteral">'i'</span>) {
117<a name="l00082"></a>00082         x = complex&lt;T&gt;(re, im);
118<a name="l00083"></a>00083       }
119<a name="l00084"></a>00084       <span class="keywordflow">else</span> {
120<a name="l00085"></a>00085         is.setstate(ios_base::failbit);
121<a name="l00086"></a>00086       }
122<a name="l00087"></a>00087     }
123<a name="l00088"></a>00088     <span class="keywordflow">else</span> {
124<a name="l00089"></a>00089       x = complex&lt;T&gt;(re, T(0));
125<a name="l00090"></a>00090     }
126<a name="l00091"></a>00091   }
127<a name="l00092"></a>00092   <span class="keywordflow">return</span> is;
128<a name="l00093"></a>00093 }
129<a name="l00094"></a>00094
130<a name="l00095"></a>00095 } <span class="comment">// namespace std</span>
131<a name="l00096"></a>00096
132<a name="l00097"></a>00097
133<a name="l00099"></a>00099 <span class="keyword">namespace </span>itpp
134<a name="l00100"></a>00100 {
135<a name="l00101"></a>00101
136<a name="l00103"></a>00103 <span class="keyword">const</span> <span class="keywordtype">double</span> pi = 3.14159265358979323846;
137<a name="l00104"></a>00104
138<a name="l00106"></a>00106 <span class="keyword">const</span> <span class="keywordtype">double</span> m_2pi = 2 * pi;
139<a name="l00107"></a>00107
140<a name="l00109"></a>00109 <span class="keyword">const</span> <span class="keywordtype">double</span> eps = std::numeric_limits&lt;double&gt;::epsilon();
141<a name="l00110"></a>00110
142<a name="l00113"></a>00113
143<a name="l00115"></a><a class="code" href="group__miscfunc.html#gfa54458e53dce41d8404fe45376339a3">00115</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="group__miscfunc.html#gfa54458e53dce41d8404fe45376339a3" title="Return true if x is an integer.">is_int</a>(<span class="keywordtype">double</span> x)
144<a name="l00116"></a>00116 {
145<a name="l00117"></a>00117   <span class="keywordtype">double</span> dummy;
146<a name="l00118"></a>00118   <span class="keywordflow">return</span> (modf(x, &amp;dummy) == 0.0);
147<a name="l00119"></a>00119 }
148<a name="l00120"></a>00120
149<a name="l00122"></a><a class="code" href="group__miscfunc.html#g7fa3ce6e66b7a5cfd8a19afbaade3e07">00122</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="group__miscfunc.html#g7fa3ce6e66b7a5cfd8a19afbaade3e07" title="Return true if x is an even integer.">is_even</a>(<span class="keywordtype">int</span> x) { <span class="keywordflow">return</span> ((x&amp;1) == 0); }
150<a name="l00123"></a>00123
151<a name="l00125"></a>00125 std::string <a class="code" href="group__miscfunc.html#gbb3627fd2889d7c0a0b0a732cdbee0df" title="Returns IT++ library version number, e.g. &amp;quot;3.7.1&amp;quot;.">itpp_version</a>();
152<a name="l00126"></a>00126
153<a name="l00128"></a>00128 <span class="keywordtype">bool</span> <a class="code" href="group__miscfunc.html#g8ba5eddf2ec659bc23fd59af00c90417" title="Returns true if machine endianness is BIG_ENDIAN.">is_bigendian</a>();
154<a name="l00129"></a>00129
155<a name="l00131"></a><a class="code" href="group__miscfunc.html#gd1f3444a5fd30325eb9dbe9f35544e6d">00131</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="group__miscfunc.html#gd1f3444a5fd30325eb9dbe9f35544e6d" title="This function is deprecated. Please use is_bigendian() instead.">check_big_endianness</a>() { <span class="keywordflow">return</span> <a class="code" href="group__miscfunc.html#g8ba5eddf2ec659bc23fd59af00c90417" title="Returns true if machine endianness is BIG_ENDIAN.">is_bigendian</a>(); }
156<a name="l00132"></a>00132
157<a name="l00134"></a>00134
158<a name="l00135"></a>00135 } <span class="comment">//namespace itpp</span>
159<a name="l00136"></a>00136
160<a name="l00137"></a>00137
161<a name="l00138"></a>00138 <span class="preprocessor">#endif // #ifndef MISC_H</span>
162</pre></div></div>
163<hr size="1"><address style="text-align: right;"><small>Generated on Tue Jun 2 10:02:12 2009 for mixpp by&nbsp;
164<a href="http://www.doxygen.org/index.html">
165<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
166</body>
167</html>
Note: See TracBrowser for help on using the browser.