blitz
Version 0.9
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
blitz
minmax.h
Go to the documentation of this file.
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
31
BZ_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
38
BZ_NAMESPACE
(minmax)
39
40
template<typename T1, typename T2>
41
BZ_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
51
template<typename T1, typename T2>
52
BZ_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
62
BZ_NAMESPACE_END
63
64
BZ_NAMESPACE_END
65
66
#endif
Generated on Fri Jun 15 2012 12:01:11 for blitz by
1.8.1.1