File: fuzzy.h

package info (click to toggle)
saods9 8.2%2Brepack-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 28,436 kB
  • sloc: tcl: 247,588; cpp: 69,307; ansic: 3,983; xml: 1,375; sh: 1,312; makefile: 183; perl: 68
file content (33 lines) | stat: -rw-r--r-- 948 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (C) 1999-2020
// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
// For conditions of distribution and use, see copyright notice in "copyright"

#ifndef __fuzzy_h__
#define __fuzzy_h__

#include <float.h>

inline void tzero(double* ff, const double epsilon= DBL_EPSILON)
{if (*ff>=-epsilon && *ff<=epsilon) *ff = 0;}

inline bool teq(const double f1, const double f2,
		const double epsilon= DBL_EPSILON)
{return f1-f2 >= -epsilon && f1-f2 <= epsilon;}

inline bool tlt(const double f1, const double f2,
		const double epsilon= DBL_EPSILON)
{return f1-f2 < -epsilon;}

inline bool tle(const double f1, const double f2,
		const double epsilon= DBL_EPSILON)
{return f1-f2 <= -epsilon;  }

inline bool tgt(const double f1, const double f2, 
		const double epsilon= DBL_EPSILON)
{return f1-f2 > epsilon;}

inline bool tge(const double f1, const double f2, 
		const double epsilon= DBL_EPSILON)
{return f1-f2 >= epsilon;}

#endif