Ignore:
Timestamp:
Mar 11, 1998, 11:47:02 AM (26 years ago)
Author:
Jens Schmidt <schmidt@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
d636adca8e47219c329f1d05ef6a4b1712a88b48
Parents:
071a57d32bf2ee76f41d23ebb68750940ae505ea
Message:
	* templates/ftmpl_functions.h (tabs): new function


git-svn-id: file:///usr/local/Singular/svn/trunk@1207 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/templates/ftmpl_functions.h

    r071a57 rc842903  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: ftmpl_functions.h,v 1.3 1997-06-19 13:11:16 schmidt Exp $ */
     2/* $Id: ftmpl_functions.h,v 1.4 1998-03-11 10:47:02 schmidt Exp $ */
    33
    44#ifndef INCL_FUNCTIONS_H
    55#define INCL_FUNCTIONS_H
    66
     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
    726#include <factoryconf.h>
    827
    9 template<class T>
    10 inline T tmax( const T & a, const T & b )
     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 )
    1138{
    12   return (a > b) ? a : b;
     39    return (a > b) ? a : b;
    1340}
     41//}}}
    1442
    15 template<class T>
    16 inline T tmin( const T & a, const T & b )
     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 )
    1753{
    18   return (a < b) ? a : b;
     54    return (a < b) ? a : b;
    1955}
     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//}}}
    2073
    2174#endif /* ! INCL_FUNCTIONS_H */
Note: See TracChangeset for help on using the changeset viewer.