Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > ce1f17e7ec5e62f35dbe9f064c5f74d7 > files > 1056

libtpcimgio-devel-1.5.10-4.fc15.i686.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>sif.c 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.7.4 -->
<div id="top">
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">sif.c</div>  </div>
</div>
<div class="contents">
<a href="sif_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/******************************************************************************</span>
<a name="l00002"></a>00002 <span class="comment"></span>
<a name="l00003"></a>00003 <span class="comment">  File:        sif.c</span>
<a name="l00004"></a>00004 <span class="comment">  Description: Routines for Scan Information Files (SIF).</span>
<a name="l00005"></a>00005 <span class="comment"></span>
<a name="l00006"></a>00006 <span class="comment">  Copyright (c) 2000-2005 Turku PET Centre</span>
<a name="l00007"></a>00007 <span class="comment"></span>
<a name="l00008"></a>00008 <span class="comment">  This library is free software; you can redistribute it and/or</span>
<a name="l00009"></a>00009 <span class="comment">  modify it under the terms of the GNU Lesser General Public</span>
<a name="l00010"></a>00010 <span class="comment">  License as published by the Free Software Foundation; either</span>
<a name="l00011"></a>00011 <span class="comment">  version 2.1 of the License, or (at your option) any later version.</span>
<a name="l00012"></a>00012 <span class="comment"></span>
<a name="l00013"></a>00013 <span class="comment">  This library is distributed in the hope that it will be useful,</span>
<a name="l00014"></a>00014 <span class="comment">  but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00015"></a>00015 <span class="comment">  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</span>
<a name="l00016"></a>00016 <span class="comment">  See the GNU Lesser General Public License for more details:</span>
<a name="l00017"></a>00017 <span class="comment">  http://www.gnu.org/copyleft/lesser.html</span>
<a name="l00018"></a>00018 <span class="comment"></span>
<a name="l00019"></a>00019 <span class="comment">  You should have received a copy of the GNU Lesser General Public License</span>
<a name="l00020"></a>00020 <span class="comment">  along with this library/program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment">  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA </span>
<a name="l00022"></a>00022 <span class="comment"></span>
<a name="l00023"></a>00023 <span class="comment">  Turku PET Centre, Turku, Finland, http://www.turkupetcentre.fi</span>
<a name="l00024"></a>00024 <span class="comment"></span>
<a name="l00025"></a>00025 <span class="comment">  Modification history:</span>
<a name="l00026"></a>00026 <span class="comment">  2000-09-04 Vesa Oikonen</span>
<a name="l00027"></a>00027 <span class="comment">  2000-09-08 VO</span>
<a name="l00028"></a>00028 <span class="comment">    malloc-&gt;calloc.</span>
<a name="l00029"></a>00029 <span class="comment">  2000-09-18 VO</span>
<a name="l00030"></a>00030 <span class="comment">    weightSIF() can calculate weights for decay corrected data.</span>
<a name="l00031"></a>00031 <span class="comment">  2000-12-13 VO</span>
<a name="l00032"></a>00032 <span class="comment">    Included function writeSIF().</span>
<a name="l00033"></a>00033 <span class="comment">  2002-07-30 VO</span>
<a name="l00034"></a>00034 <span class="comment">    memset() added to initSIF().</span>
<a name="l00035"></a>00035 <span class="comment">  2004-09-17 VO</span>
<a name="l00036"></a>00036 <span class="comment">    Doxygen style comments.</span>
<a name="l00037"></a>00037 <span class="comment">  2004-10-13 VO</span>
<a name="l00038"></a>00038 <span class="comment">    tm_isdst=-1 (unknown Daylight saving time).</span>
<a name="l00039"></a>00039 <span class="comment">  2005-01-12 VO</span>
<a name="l00040"></a>00040 <span class="comment">    Changed and additional comments not affecting compiled code.</span>
<a name="l00041"></a>00041 <span class="comment">  2005-01-15 VO</span>
<a name="l00042"></a>00042 <span class="comment">    SIF related stuff moved from libpet to new libsif.</span>
<a name="l00043"></a>00043 <span class="comment">    Function names changed, although old names can still be used.</span>
<a name="l00044"></a>00044 <span class="comment">  2005-01-16 VO</span>
<a name="l00045"></a>00045 <span class="comment">    studynr and isotope_name were added to SIF structure.</span>
<a name="l00046"></a>00046 <span class="comment">  2005-04-26 CL</span>
<a name="l00047"></a>00047 <span class="comment">    Merged libsif to libtpcimio</span>
<a name="l00048"></a>00048 <span class="comment"></span>
<a name="l00049"></a>00049 <span class="comment">******************************************************************************/</span>
<a name="l00050"></a>00050 
<a name="l00051"></a>00051 <span class="comment">/*****************************************************************************/</span>
<a name="l00052"></a>00052 <span class="preprocessor">#include &quot;<a class="code" href="sif_8h.html">sif.h</a>&quot;</span>
<a name="l00053"></a>00053 <span class="comment">/*****************************************************************************/</span>
<a name="l00054"></a>00054 
<a name="l00055"></a>00055 <span class="comment">/*****************************************************************************/</span>
<a name="l00061"></a><a class="code" href="sif_8h.html#a61c0218e380da8ace65d78f82a8f9f69">00061</a> <span class="keywordtype">void</span> <a class="code" href="sif_8c.html#a61c0218e380da8ace65d78f82a8f9f69">sifInit</a>(<a class="code" href="structSIF.html">SIF</a> *data) {
<a name="l00062"></a>00062   <span class="keywordflow">if</span>(<a class="code" href="sif_8h.html#a78c06628d2bc47f66f573e280c77931e">SIF_TEST</a>) printf(<span class="stringliteral">&quot;sifInit()\n&quot;</span>);
<a name="l00063"></a>00063   memset(data, 0, <span class="keyword">sizeof</span>(<a class="code" href="structSIF.html">SIF</a>));
<a name="l00064"></a>00064   data-&gt;<a class="code" href="structSIF.html#a441bd4d1d3825ace8f21d02e9f5d650d">frameNr</a>=data-&gt;<a class="code" href="structSIF.html#ae6e05bc7807e015b7a188d88e54c722d">colNr</a>=0;
<a name="l00065"></a>00065 }
<a name="l00066"></a>00066 <span class="comment">/*****************************************************************************/</span>
<a name="l00067"></a>00067 
<a name="l00068"></a>00068 <span class="comment">/*****************************************************************************/</span>
<a name="l00074"></a><a class="code" href="sif_8h.html#ad2378bec7fec69900af6f52737c89784">00074</a> <span class="keywordtype">void</span> <a class="code" href="sif_8c.html#ad2378bec7fec69900af6f52737c89784">sifEmpty</a>(<a class="code" href="structSIF.html">SIF</a> *data) {
<a name="l00075"></a>00075   <span class="keywordflow">if</span>(<a class="code" href="sif_8h.html#a78c06628d2bc47f66f573e280c77931e">SIF_TEST</a>) printf(<span class="stringliteral">&quot;sifEmpty()\n&quot;</span>);
<a name="l00076"></a>00076   <span class="keywordflow">if</span>(data-&gt;<a class="code" href="structSIF.html#a441bd4d1d3825ace8f21d02e9f5d650d">frameNr</a>&gt;0) {
<a name="l00077"></a>00077     free((<span class="keywordtype">char</span>*)(data-&gt;<a class="code" href="structSIF.html#a085f3f1a4b2a77eabe13f52c2010a3c0">x1</a>)); free((<span class="keywordtype">char</span>*)(data-&gt;<a class="code" href="structSIF.html#a45001ad49c925e6ae266357b3ab7d8a4">x2</a>));
<a name="l00078"></a>00078     free((<span class="keywordtype">char</span>*)(data-&gt;<a class="code" href="structSIF.html#a20d6fecbd751d872300c661e19903eed">prompts</a>)); free((<span class="keywordtype">char</span>*)(data-&gt;<a class="code" href="structSIF.html#af2fa6ee9e91796baa37261bd866b641f">randoms</a>));
<a name="l00079"></a>00079     free((<span class="keywordtype">char</span>*)(data-&gt;<a class="code" href="structSIF.html#afacb83b024d68548311e34263a3319ea">trues</a>)); free((<span class="keywordtype">char</span>*)(data-&gt;<a class="code" href="structSIF.html#abd4ddd6bc4aa25c3f8ed6d85445dce23">weights</a>));
<a name="l00080"></a>00080     data-&gt;<a class="code" href="structSIF.html#a441bd4d1d3825ace8f21d02e9f5d650d">frameNr</a>=data-&gt;<a class="code" href="structSIF.html#ae6e05bc7807e015b7a188d88e54c722d">colNr</a>=0;
<a name="l00081"></a>00081   }
<a name="l00082"></a>00082   data-&gt;<a class="code" href="structSIF.html#a98b5ff616033e728f0edc9bdc7eddce2">scantime</a>=(time_t)0; data-&gt;<a class="code" href="structSIF.html#a48b4293795f15b4c214549e0dad3ce41">version</a>=0;
<a name="l00083"></a>00083   strcpy(data-&gt;<a class="code" href="structSIF.html#a2d3e6df8c97d55d0c28d83501d12f523">studynr</a>, <span class="stringliteral">&quot;&quot;</span>); strcpy(data-&gt;<a class="code" href="structSIF.html#aaf18449475434d1cf5ab11b2c36780b1">isotope_name</a>, <span class="stringliteral">&quot;&quot;</span>);
<a name="l00084"></a>00084 }
<a name="l00085"></a>00085 <span class="comment">/*****************************************************************************/</span>
<a name="l00086"></a>00086 
<a name="l00087"></a>00087 <span class="comment">/*****************************************************************************/</span>
<a name="l00095"></a><a class="code" href="sif_8h.html#ac1ea54c7476aa6b3d0b1835e22798915">00095</a> <span class="keywordtype">int</span> <a class="code" href="sif_8c.html#ac1ea54c7476aa6b3d0b1835e22798915">sifSetmem</a>(<a class="code" href="structSIF.html">SIF</a> *data, <span class="keywordtype">int</span> frameNr) {
<a name="l00096"></a>00096   <span class="keywordflow">if</span>(<a class="code" href="sif_8h.html#a78c06628d2bc47f66f573e280c77931e">SIF_TEST</a>) printf(<span class="stringliteral">&quot;sifSetmem()\n&quot;</span>);
<a name="l00097"></a>00097   <span class="comment">/* Clear previous data, if necessary */</span>
<a name="l00098"></a>00098   <span class="keywordflow">if</span>(data-&gt;<a class="code" href="structSIF.html#a441bd4d1d3825ace8f21d02e9f5d650d">frameNr</a>&gt;0) <a class="code" href="sif_8c.html#ad2378bec7fec69900af6f52737c89784">sifEmpty</a>(data);
<a name="l00099"></a>00099   <span class="keywordflow">if</span>(frameNr&lt;1) <span class="keywordflow">return</span>(0);
<a name="l00100"></a>00100   
<a name="l00101"></a>00101   <span class="comment">/* Allocate memory */</span>
<a name="l00102"></a>00102   data-&gt;<a class="code" href="structSIF.html#a085f3f1a4b2a77eabe13f52c2010a3c0">x1</a>=(<span class="keywordtype">double</span>*)calloc(frameNr, <span class="keyword">sizeof</span>(<span class="keywordtype">double</span>));
<a name="l00103"></a>00103   data-&gt;<a class="code" href="structSIF.html#a45001ad49c925e6ae266357b3ab7d8a4">x2</a>=(<span class="keywordtype">double</span>*)calloc(frameNr, <span class="keyword">sizeof</span>(<span class="keywordtype">double</span>));
<a name="l00104"></a>00104   data-&gt;<a class="code" href="structSIF.html#a20d6fecbd751d872300c661e19903eed">prompts</a>=(<span class="keywordtype">double</span>*)calloc(frameNr, <span class="keyword">sizeof</span>(<span class="keywordtype">double</span>));
<a name="l00105"></a>00105   data-&gt;<a class="code" href="structSIF.html#af2fa6ee9e91796baa37261bd866b641f">randoms</a>=(<span class="keywordtype">double</span>*)calloc(frameNr, <span class="keyword">sizeof</span>(<span class="keywordtype">double</span>));
<a name="l00106"></a>00106   data-&gt;<a class="code" href="structSIF.html#afacb83b024d68548311e34263a3319ea">trues</a>=(<span class="keywordtype">double</span>*)calloc(frameNr, <span class="keyword">sizeof</span>(<span class="keywordtype">double</span>));
<a name="l00107"></a>00107   data-&gt;<a class="code" href="structSIF.html#abd4ddd6bc4aa25c3f8ed6d85445dce23">weights</a>=(<span class="keywordtype">double</span>*)calloc(frameNr, <span class="keyword">sizeof</span>(<span class="keywordtype">double</span>));
<a name="l00108"></a>00108   <span class="keywordflow">if</span>(data-&gt;<a class="code" href="structSIF.html#a085f3f1a4b2a77eabe13f52c2010a3c0">x1</a>==NULL || data-&gt;<a class="code" href="structSIF.html#a45001ad49c925e6ae266357b3ab7d8a4">x2</a>==NULL || data-&gt;<a class="code" href="structSIF.html#a20d6fecbd751d872300c661e19903eed">prompts</a>==NULL ||
<a name="l00109"></a>00109      data-&gt;<a class="code" href="structSIF.html#af2fa6ee9e91796baa37261bd866b641f">randoms</a>==NULL || data-&gt;<a class="code" href="structSIF.html#afacb83b024d68548311e34263a3319ea">trues</a>==NULL || data-&gt;<a class="code" href="structSIF.html#abd4ddd6bc4aa25c3f8ed6d85445dce23">weights</a>==NULL) {
<a name="l00110"></a>00110     strcpy(<a class="code" href="sif_8h.html#aead6d915302aed6cb03d80791abd866f">siferrmsg</a>, <span class="stringliteral">&quot;out of memory&quot;</span>); <span class="keywordflow">return</span>(1);}
<a name="l00111"></a>00111   data-&gt;<a class="code" href="structSIF.html#a441bd4d1d3825ace8f21d02e9f5d650d">frameNr</a>=frameNr;
<a name="l00112"></a>00112 
<a name="l00113"></a>00113   <span class="keywordflow">return</span>(0);
<a name="l00114"></a>00114 }
<a name="l00115"></a>00115 <span class="comment">/*****************************************************************************/</span>
<a name="l00116"></a>00116 
<a name="l00117"></a>00117 <span class="comment">/*****************************************************************************/</span>
<a name="l00118"></a>00118 
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Mon Aug 8 2011 by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>