Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > aaf33964de706a538481c929c1da6a44 > files > 93

faust-doc-0.9.10-5mdv2010.1.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>FAUST compiler: absprim.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>absprim.cpp</h1><a href="absprim_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &quot;<a class="code" href="xtended_8hh.html">xtended.hh</a>&quot;</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include &quot;<a class="code" href="Text_8hh.html">Text.hh</a>&quot;</span>
<a name="l00003"></a>00003 <span class="preprocessor">#include &lt;math.h&gt;</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &quot;<a class="code" href="sigtyperules_8hh.html">sigtyperules.hh</a>&quot;</span>
<a name="l00005"></a>00005 
<a name="l00006"></a><a class="code" href="classAbsPrim.html#a0a251f5ef642aca8acd06b77d7a41760">00006</a> <span class="preprocessor">#include &quot;<a class="code" href="floats_8hh.html">floats.hh</a>&quot;</span>
<a name="l00007"></a>00007 
<a name="l00008"></a><a class="code" href="classAbsPrim.html#a529dd0636e9394b18c6266299ece2385">00008</a> <span class="keyword">class </span><a class="code" href="classAbsPrim.html">AbsPrim</a> : <span class="keyword">public</span> <a class="code" href="classxtended.html">xtended</a>
<a name="l00009"></a>00009 {
<a name="l00010"></a><a class="code" href="classAbsPrim.html#ac7e2808746697d470098726dad3faedc">00010</a> 
<a name="l00011"></a>00011  <span class="keyword">public</span>:
<a name="l00012"></a><a class="code" href="classAbsPrim.html#a68518bc4879e80c1c0a5f8c00431743a">00012</a> 
<a name="l00013"></a>00013     <a class="code" href="classAbsPrim.html#a0a251f5ef642aca8acd06b77d7a41760">AbsPrim</a>() : <a class="code" href="classxtended.html">xtended</a>(<span class="stringliteral">&quot;abs&quot;</span>) {}
<a name="l00014"></a>00014 
<a name="l00015"></a>00015     <span class="keyword">virtual</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>    <a class="code" href="classAbsPrim.html#a529dd0636e9394b18c6266299ece2385">arity</a> () { <span class="keywordflow">return</span> 1; }
<a name="l00016"></a>00016 
<a name="l00017"></a>00017     <span class="keyword">virtual</span> <span class="keywordtype">bool</span>    <a class="code" href="classAbsPrim.html#ac7e2808746697d470098726dad3faedc">needCache</a> ()    { <span class="keywordflow">return</span> <span class="keyword">true</span>; }
<a name="l00018"></a>00018 
<a name="l00019"></a>00019     <span class="keyword">virtual</span> <a class="code" href="classP.html">Type</a>    <a class="code" href="classAbsPrim.html#a68518bc4879e80c1c0a5f8c00431743a">infereSigType</a> (<span class="keyword">const</span> vector&lt;Type&gt;&amp; types)
<a name="l00020"></a><a class="code" href="classAbsPrim.html#a4d6f9c41d48aee9f1b99390598b9df6d">00020</a>     {
<a name="l00021"></a>00021         assert (types.size() == <a class="code" href="classAbsPrim.html#a529dd0636e9394b18c6266299ece2385">arity</a>());
<a name="l00022"></a><a class="code" href="classAbsPrim.html#ab6b8b3ed18f4774493c892fb39deda35">00022</a>         <a class="code" href="classP.html">Type</a> t = types[0];
<a name="l00023"></a>00023         <span class="keywordflow">return</span> <a class="code" href="sigtype_8hh.html#a4a00d24cc30a4924d2df9b56d577bd16">castInterval</a>(t, <a class="code" href="interval_8hh.html#a466c6b7b96c9d292b7b4177fae8e0801">abs</a>(t-&gt;getInterval()));
<a name="l00024"></a>00024         <span class="keywordflow">return</span> t;
<a name="l00025"></a>00025     }
<a name="l00026"></a>00026 
<a name="l00027"></a>00027     <span class="keyword">virtual</span> <span class="keywordtype">void</span>    <a class="code" href="classAbsPrim.html#a4d6f9c41d48aee9f1b99390598b9df6d">sigVisit</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> sig, <a class="code" href="structsigvisitor.html">sigvisitor</a>* visitor) {}
<a name="l00028"></a>00028 
<a name="l00029"></a><a class="code" href="classAbsPrim.html#a4ec496126ea41309c6d5c888ec53db7a">00029</a>     <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classAbsPrim.html#ab6b8b3ed18f4774493c892fb39deda35">infereSigOrder</a> (<span class="keyword">const</span> vector&lt;int&gt;&amp; args)
<a name="l00030"></a>00030     {
<a name="l00031"></a>00031         assert (args.size() == <a class="code" href="classAbsPrim.html#a529dd0636e9394b18c6266299ece2385">arity</a>());
<a name="l00032"></a>00032         <span class="keywordflow">return</span> args[0];
<a name="l00033"></a>00033     }
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 
<a name="l00036"></a>00036     <span class="keyword">virtual</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>    <a class="code" href="classAbsPrim.html#a4ec496126ea41309c6d5c888ec53db7a">computeSigOutput</a> (<span class="keyword">const</span> vector&lt;Tree&gt;&amp; args)
<a name="l00037"></a>00037     {
<a name="l00038"></a>00038         <span class="keywordtype">double</span> f; <span class="keywordtype">int</span> i;
<a name="l00039"></a>00039 
<a name="l00040"></a>00040         assert (args.size() == <a class="code" href="classAbsPrim.html#a529dd0636e9394b18c6266299ece2385">arity</a>());
<a name="l00041"></a>00041 
<a name="l00042"></a>00042         <span class="keywordflow">if</span> (<a class="code" href="node_8hh.html#aab6c20fb5dce797e97ac8ec8591258af">isDouble</a>(args[0]-&gt;node(),&amp;f)) {
<a name="l00043"></a>00043             <span class="keywordflow">return</span> <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(fabs(f));
<a name="l00044"></a>00044 
<a name="l00045"></a>00045         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="node_8hh.html#a8c9b968ac68f6cac1c361002da8afe99">isInt</a>(args[0]-&gt;node(),&amp;i)) {
<a name="l00046"></a><a class="code" href="classAbsPrim.html#a7947cd63a6d08a426261f59abf4a29d4">00046</a>             <span class="keywordflow">return</span> <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="interval_8hh.html#a466c6b7b96c9d292b7b4177fae8e0801">abs</a>(i));
<a name="l00047"></a>00047 
<a name="l00048"></a>00048         } <span class="keywordflow">else</span> {
<a name="l00049"></a>00049             <span class="keywordflow">return</span> <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(<a class="code" href="classxtended.html#ae7e621bd8015110e7af77ab7c850f573">symbol</a>(), args[0]);
<a name="l00050"></a>00050         }
<a name="l00051"></a>00051     }
<a name="l00052"></a>00052 
<a name="l00053"></a>00053     <span class="keyword">virtual</span> <span class="keywordtype">string</span>  <a class="code" href="classAbsPrim.html#a7947cd63a6d08a426261f59abf4a29d4">generateCode</a> (<a class="code" href="classKlass.html">Klass</a>* klass, <span class="keyword">const</span> vector&lt;string&gt;&amp; args, <span class="keyword">const</span> vector&lt;Type&gt;&amp; types)
<a name="l00054"></a>00054     {
<a name="l00055"></a>00055         assert (args.size() == <a class="code" href="classAbsPrim.html#a529dd0636e9394b18c6266299ece2385">arity</a>());
<a name="l00056"></a>00056         assert (types.size() == <a class="code" href="classAbsPrim.html#a529dd0636e9394b18c6266299ece2385">arity</a>());
<a name="l00057"></a>00057 
<a name="l00058"></a>00058         <a class="code" href="classP.html">Type</a> t = <a class="code" href="classAbsPrim.html#a68518bc4879e80c1c0a5f8c00431743a">infereSigType</a>(types);
<a name="l00059"></a><a class="code" href="classAbsPrim.html#ac1bcdfa966de28bda588514e84ec78b3">00059</a>         <span class="keywordflow">if</span> (t-&gt;nature() == <a class="code" href="sigtype_8hh.html#adc29c2ff13d900c2f185ee95427fb06cabd8b038fc1f31f03f96a41107d3ac13d">kReal</a>) {
<a name="l00060"></a>00060             <span class="keywordflow">return</span> <a class="code" href="Text_8cpp.html#af50e951c134c2c98c4c75d687f8fca7a">subst</a>(<span class="stringliteral">&quot;fabs$1($0)&quot;</span>, args[0], <a class="code" href="floats_8cpp.html#a4091ebb0e4eff17b3ff908531df9fb92" title="suffix for math functions">isuffix</a>());
<a name="l00061"></a>00061         } <span class="keywordflow">else</span> {
<a name="l00062"></a>00062             <span class="keywordflow">return</span> <a class="code" href="Text_8cpp.html#af50e951c134c2c98c4c75d687f8fca7a">subst</a>(<span class="stringliteral">&quot;abs($0)&quot;</span>, args[0]);
<a name="l00063"></a>00063         }
<a name="l00064"></a>00064     }
<a name="l00065"></a>00065     
<a name="l00066"></a>00066     <span class="keyword">virtual</span> <span class="keywordtype">string</span>  <a class="code" href="classAbsPrim.html#ac1bcdfa966de28bda588514e84ec78b3">generateLateq</a> (<a class="code" href="classLateq.html">Lateq</a>* lateq, <span class="keyword">const</span> vector&lt;string&gt;&amp; args, <span class="keyword">const</span> vector&lt;Type&gt;&amp; types)
<a name="l00067"></a>00067     {
<a name="l00068"></a>00068         assert (args.size() == <a class="code" href="classAbsPrim.html#a529dd0636e9394b18c6266299ece2385">arity</a>());
<a name="l00069"></a>00069         assert (types.size() == <a class="code" href="classAbsPrim.html#a529dd0636e9394b18c6266299ece2385">arity</a>());
<a name="l00070"></a>00070         
<a name="l00071"></a>00071         <a class="code" href="classP.html">Type</a> t = <a class="code" href="classAbsPrim.html#a68518bc4879e80c1c0a5f8c00431743a">infereSigType</a>(types);
<a name="l00072"></a>00072         <span class="keywordflow">return</span> <a class="code" href="Text_8cpp.html#af50e951c134c2c98c4c75d687f8fca7a">subst</a>(<span class="stringliteral">&quot;\\left\\lvert{$0}\\right\\rvert&quot;</span>, args[0]);
<a name="l00073"></a>00073     }
<a name="l00074"></a>00074 };
<a name="l00075"></a>00075 
<a name="l00076"></a>00076 
<a name="l00077"></a><a class="code" href="xtended_8hh.html#a6a18bb96b926d533d75ce4fecee5dcae">00077</a> <a class="code" href="classxtended.html">xtended</a>* <a class="code" href="absprim_8cpp.html#a6a18bb96b926d533d75ce4fecee5dcae">gAbsPrim</a> = <span class="keyword">new</span> <a class="code" href="classAbsPrim.html">AbsPrim</a>();
<a name="l00078"></a>00078 
<a name="l00079"></a>00079 
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Wed Apr 28 23:59:58 2010 for FAUST compiler by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>