source: git/factory/templates/ftmpl_functions.h @ c842903

spielwiese
Last change on this file since c842903 was c842903, checked in by Jens Schmidt <schmidt@…>, 26 years ago
* templates/ftmpl_functions.h (tabs): new function git-svn-id: file:///usr/local/Singular/svn/trunk@1207 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2/* $Id: ftmpl_functions.h,v 1.4 1998-03-11 10:47:02 schmidt Exp $ */
3
4#ifndef INCL_FUNCTIONS_H
5#define INCL_FUNCTIONS_H
6
7//{{{ docu
8//
9// ftmpl_functions.h - some useful template functions.
10//
11// Sooner or later you need them: functions to calculate the
12// minimum or maximum of two values or the absolute value.  Here
13// they are.  All of them are inlined, hence there is no source
14// file corresponding to `ftmpl_functions.h'.
15//
16// The functions are for internal use only (i.e. to build the
17// library), hence they should not be included from `factory.h'.
18// However, we have to install `ftmpl_functions.h' with the other
19// templates since the functions have to be instantiated.
20//
21// Used by: cf_gcd.cc, cf_map.cc, fac_ezgcd.cc, sm_sparsemod.cc,
22//   ftmpl_inst.cc
23//
24//}}}
25
26#include <factoryconf.h>
27
28//{{{ template <class T> inline T tmax ( const T & a, const T & b )
29//{{{ docu
30//
31// tmax() - return the maximum of `a' and `b'.
32//
33// `T' should have an `operator >()'.
34//
35//}}}
36template <class T>
37inline T tmax ( const T & a, const T & b )
38{
39    return (a > b) ? a : b;
40}
41//}}}
42
43//{{{ template <class T> inline T tmin ( const T & a, const T & b )
44//{{{ docu
45//
46// tmin() - return the minimum of `a' and `b'.
47//
48// `T' should have an `operator <()'.
49//
50//}}}
51template <class T>
52inline T tmin ( const T & a, const T & b )
53{
54    return (a < b) ? a : b;
55}
56//}}}
57
58//{{{ template <class T> inline T tabs ( const T & a )
59//{{{ docu
60//
61// tabs() - return the absolute value of `a'.
62//
63// `T' should have an `operator >()', an `operator -()', and a
64// `T::T( int )' constructor.
65//
66//}}}
67template <class T>
68inline T tabs ( const T & a )
69{
70    return (a > T( 0 )) ? a : -a;
71}
72//}}}
73
74#endif /* ! INCL_FUNCTIONS_H */
Note: See TracBrowser for help on using the repository browser.