source: XMLIO_V2/external/include/blitz/minmax.h @ 73

Last change on this file since 73 was 73, checked in by ymipsl, 14 years ago
  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1/***************************************************************************
2 * blitz/minmax.h  Declaration of min and max functions
3 *
4 * $Id: minmax.h,v 1.4 2003/12/11 03:44:22 julianc Exp $
5 *
6 * Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * Suggestions:          blitz-dev@oonumerics.org
19 * Bugs:                 blitz-bugs@oonumerics.org
20 *
21 * For more information, please see the Blitz++ Home Page:
22 *    http://oonumerics.org/blitz/
23 *
24 ***************************************************************************/
25
26#ifndef BZ_MINMAX_H
27#define BZ_MINMAX_H
28
29#include <blitz/promote.h>
30
31BZ_NAMESPACE(blitz)
32
33/*
34 * These functions are in their own namespace (blitz::minmax) to avoid
35 * conflicts with the array reduction operations min and max.
36 */
37
38BZ_NAMESPACE(minmax)
39
40template<typename T1, typename T2>
41BZ_PROMOTE(T1,T2) min(const T1& a, const T2& b)
42{
43    typedef BZ_PROMOTE(T1,T2) T_promote;
44
45    if (a <= b)
46        return T_promote(a);
47    else
48        return T_promote(b);
49}
50
51template<typename T1, typename T2>
52BZ_PROMOTE(T1,T2) max(const T1& a, const T2& b)
53{
54    typedef BZ_PROMOTE(T1,T2) T_promote;
55
56    if (a >= b)
57        return T_promote(a);
58    else
59        return T_promote(b);
60}
61
62BZ_NAMESPACE_END
63
64BZ_NAMESPACE_END
65
66#endif
Note: See TracBrowser for help on using the repository browser.