/[ascend]/trunk/base/generic/compiler/fractions.h
ViewVC logotype

Annotation of /trunk/base/generic/compiler/fractions.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1066 - (hide annotations) (download) (as text)
Sun Jan 7 10:02:41 2007 UTC (17 years, 9 months ago) by johnpye
File MIME type: text/x-chdr
File size: 2657 byte(s)
Adding doxygen 'addtogroup' for Solver, Compiler, Integrator.
1 johnpye 619 /* ASCEND modelling environment
2     Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
3     Copyright (C) 2006 Carnegie Mellon University
4 aw0a 1
5 johnpye 619 This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2, or (at your option)
8     any later version.
9 aw0a 1
10 johnpye 619 This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13     GNU General Public License for more details.
14    
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 59 Temple Place - Suite 330,
18     Boston, MA 02111-1307, USA.
19     *//**
20     @file
21     Fraction module for ASCEND.
22    
23     Requires:
24     #include <utilities/ascConfig.h>
25     *//*
26     by Tom Epperly
27     8/18/89
28     Version: $Revision: 1.5 $
29     Version control file: $RCSfile: fractions.h,v $
30     Date last modified: $Date: 1997/07/18 12:29:47 $
31     Last modified by: $Author: mthomas $
32     */
33    
34 johnpye 67 #ifndef ASC_FRACTIONS_H
35     #define ASC_FRACTIONS_H
36 aw0a 1
37 johnpye 1066 /** addtogroup compiler Compiler
38     @{
39     */
40    
41 jds 54 /** The type of a fraction numerator or denominator. */
42 aw0a 1 #define FRACPART short
43 jds 54 /** The maximum FRACPART value. */
44 aw0a 1 #define FRACMAX SHRT_MAX
45 jds 54
46     /** Fraction data structure. */
47 aw0a 1 struct fraction {
48 jds 54 FRACPART numerator;
49     FRACPART denominator;
50 aw0a 1 };
51    
52 johnpye 1063 ASC_DLLSPEC struct fraction CreateFraction(short n, short d);
53 johnpye 619 /**<
54 jds 54 * Create a fraction (n/d).
55     * Specify the numerator (n) and denominator (d).
56 aw0a 1 */
57    
58 jds 54 extern struct fraction Simplify(struct fraction f);
59     /**<
60 aw0a 1 * Simplify the fraction. This forces the denominator to be >= 0; so
61     * if the fraction is negative, the numerator will be negative.
62     */
63    
64     #define Numerator(f) ((f).numerator)
65 johnpye 619 /**<
66 jds 54 * Return the numerator of f as a FRACPART.
67 aw0a 1 */
68    
69     #define Denominator(f) ((f).denominator)
70 johnpye 619 /**<
71 jds 54 * Return the denominator of f as a FRACPART.
72 aw0a 1 */
73    
74 jds 54 extern struct fraction AddF(struct fraction f1, struct fraction f2);
75 johnpye 619 /**<
76 aw0a 1 * Return f1+f2 simplified.
77     */
78    
79 jds 54 extern struct fraction SubF(struct fraction f1, struct fraction f2);
80 johnpye 619 /**<
81 aw0a 1 * Return f1-f2 simplified.
82     */
83    
84 jds 54 extern struct fraction MultF(struct fraction f1, struct fraction f2);
85 johnpye 619 /**<
86 aw0a 1 * Return f1*f2 simplified.
87     */
88    
89 jds 54 extern struct fraction DivF(struct fraction f1, struct fraction f2);
90 johnpye 619 /**<
91 aw0a 1 * Return f1/f2 simplified.
92     */
93    
94 jds 54 extern int CmpF(struct fraction f1, struct fraction f2);
95 johnpye 619 /**<
96 aw0a 1 * Return -1,0,1 if f1 is <,=, or > than f2 respectively.
97     */
98    
99 jds 54 extern struct fraction NegateF(struct fraction f);
100 johnpye 619 /**<
101 aw0a 1 * Returned fraction equal -f.
102     */
103 jds 54
104 johnpye 1066 /* @} */
105    
106 johnpye 67 #endif /* ASC_FRACTIONS_H */
107 jds 54

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22