LALPrimer.c

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 Jolien Creighton
00003 *
00004 *  This program is free software; you can redistribute it and/or modify
00005 *  it under the terms of the GNU General Public License as published by
00006 *  the Free Software Foundation; either version 2 of the License, or
00007 *  (at your option) any later version.
00008 *
00009 *  This program is distributed in the hope that it will be useful,
00010 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 *  GNU General Public License for more details.
00013 *
00014 *  You should have received a copy of the GNU General Public License
00015 *  along with with program; see the file COPYING. If not, write to the
00016 *  Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00017 *  MA  02111-1307  USA
00018 */
00019 
00020 /* <lalVerbatim> */
00021 #include <lal/LALStdlib.h>
00022 #include <lal/LALPrimer.h>
00023 
00024 NRCSID( LALPRIMERC, "$Id: LALPrimer.c,v 1.5 2007/06/08 14:41:53 bema Exp $" );
00025 
00026 void
00027 REAL4Invert( LALStatus *stat, REAL4 *output, REAL4 input )
00028      /* Computes the inverse of a REAL4 number. */
00029 {
00030   INITSTATUS( stat, "REAL4Invert", LALPRIMERC );
00031 
00032   /* This traps coding errors in the calling routine. */
00033   ASSERT( output != NULL, stat, LALPRIMERH_ENULL, LALPRIMERH_MSGENULL );
00034 
00035   /* This traps runtime errors. */
00036   if ( input == 0.0 )
00037     ABORT( stat, LALPRIMERH_EDIV0, LALPRIMERH_MSGEDIV0 );
00038 
00039   *output = 1.0/input;
00040   RETURN( stat );
00041 }
00042 
00043 
00044 void
00045 REAL4Divide( LALStatus *stat, REAL4 *output, REAL4 numer, REAL4 denom )
00046      /* Computes the ratio of two REAL4 numbers. */
00047 {
00048   INITSTATUS( stat, "REAL4Divide", LALPRIMERC );
00049   ATTATCHSTATUSPTR( stat );
00050 
00051   TRY( REAL4Invert( stat->statusPtr, output, denom ), stat );
00052   *output *= numer;
00053 
00054   DETATCHSTATUSPTR( stat );
00055   RETURN( stat );
00056 }
00057 /* </lalVerbatim> */

Generated on Fri Sep 5 03:07:08 2008 for LAL by  doxygen 1.5.2