FEDRA emulsion software from the OPERA Collaboration
VtUtil.hh
Go to the documentation of this file.
1 #ifndef __VTUTIL_HH
2 #define __VTUTIL_HH
3 // *****************************************************************************
4 //
5 // source:
6 //
7 // type: source code
8 //
9 // created: 21. Aug 2000
10 //
11 // author: Thorsten Glebe
12 // HERA-B Collaboration
13 // Max-Planck-Institut fuer Kernphysik
14 // Saupfercheckweg 1
15 // 69117 Heidelberg
16 // Germany
17 // E-mail: T.Glebe@mpi-hd.mpg.de
18 //
19 // Description: Some helper routines
20 //
21 // changes:
22 // 21 Aug 2000 (TG) creation
23 // 20 Feb 2001 (TG) max, min templates added
24 // 17 Okt 2001 (TG) added/improved #defines for ARTE
25 //
26 // *****************************************************************************
27 
28 namespace VERTEX {
29  class abc; // to fake doc++
30 
32  //==============================================================================
33  // sqr: x*x
34  //==============================================================================
36  template <class T>
37  inline const T sqr(const T& x) { return x*x; }
38 
39  //==============================================================================
40  // sgn: sign
41  //==============================================================================
43  template <class T>
44  inline const short int sgn(const T& x) { return (x==0)? 0 : (x<0)? -1 : 1; }
45 
46 
47  //==============================================================================
48  // max: maximum
49  //==============================================================================
50  template <class T>
51  inline const T max(const T& rhs, const T& lhs) {
52  return (rhs > lhs) ? rhs : lhs;
53  }
54 
55 
56  //==============================================================================
57  // min: minimum
58  //==============================================================================
59  template <class T>
60  inline const T min(const T& rhs, const T& lhs) {
61  return (rhs < lhs) ? rhs : lhs;
62  }
63 
64 
65 } // end of namespace VERTEX
66 #endif
Definition: VtDistance.hh:30
const T max(const T &rhs, const T &lhs)
Definition: VtUtil.hh:51
const T sqr(const T &x)
compute the square of a number: $x*x$
Definition: VtUtil.hh:37
const T min(const T &rhs, const T &lhs)
Definition: VtUtil.hh:60
const short int sgn(const T &x)
compute the sign of a number
Definition: VtUtil.hh:44