American-transaction costs 1.0.0.0
American option pricer under proportional transaction costs
numbers.h
Go to the documentation of this file.
00001 /*
00002     American option pricer under proportional transaction costs
00003     Copyright (C) 2011 Alet Roux alet.roux@york.ac.uk
00004 
00005     This program is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 
00018 */
00019 
00020 #ifndef NUMBERS_H
00021 #define NUMBERS_H
00022 
00028 #include <math.h>
00029 
00030 #define EPSILON         1e-10
00031 
00032 #define NUMWIDTH 10
00033 
00035 typedef long double coefficient;
00036 //typedef unsigned int size_t;
00037 
00039 inline int greaterthan (const coefficient x1, const coefficient x2)
00040 {
00041         if (x1 >= EPSILON + x2)
00042                 return 1;
00043 
00044         return 0;
00045 }
00046 
00048 inline int lessthan (const coefficient x1, const coefficient x2)
00049 {
00050         return greaterthan (x2, x1);
00051 }
00052 
00054 inline int greaterequal (const coefficient x1, const coefficient x2)
00055 {
00056         if (x1 >= -EPSILON + x2)
00057                 return 1;
00058 
00059         return 0;
00060 }
00061 
00063 inline int lessequal (const coefficient x1, const coefficient x2)
00064 {
00065         return greaterequal (x2,x1);
00066 }
00067 
00069 inline int equal (const coefficient x1, const coefficient x2)
00070 {
00071         return (greaterequal (x1,x2)) && lessequal (x1,x2);
00072 }
00073 
00075 inline void fixzero (coefficient& number)
00076 {
00077         if (!isnan (number) && equal (number, 0.0))
00078                 number = 0.0;
00079 }
00080 
00081 #endif
 All Classes Namespaces Files Functions Variables Typedefs Defines