Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F19252105
ComplexComparesAbs.hh
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
ComplexComparesAbs.hh
View Options
#ifndef NPSTAT_COMPLEXCOMPARESABS_HH_
#define NPSTAT_COMPLEXCOMPARESABS_HH_
/*!
// \file ComplexComparesAbs.hh
//
// \brief Ordering extended to complex numbers by comparing their magnitudes
//
// Author: I. Volobouev
//
// January 2012
*/
#include
<cmath>
#include
<complex>
namespace
npstat
{
/**
// This template compares two numbers. For simple numeric types
// (int, double, etc) the numbers themselves are compared while
// for std::complex<...> types absolute values are compared.
*/
template
<
class
T
>
struct
ComplexComparesAbs
{
inline
static
bool
less
(
const
T
&
l
,
const
T
&
r
)
{
return
l
<
r
;}
inline
static
bool
more
(
const
T
&
l
,
const
T
&
r
)
{
return
l
>
r
;}
};
template
<
class
T
>
struct
ComplexComparesAbs
<
std
::
complex
<
T
>
>
{
inline
static
bool
less
(
const
std
::
complex
<
T
>&
l
,
const
std
::
complex
<
T
>&
r
)
{
return
std
::
abs
(
l
)
<
std
::
abs
(
r
);}
inline
static
bool
more
(
const
std
::
complex
<
T
>&
l
,
const
std
::
complex
<
T
>&
r
)
{
return
std
::
abs
(
l
)
>
std
::
abs
(
l
);}
};
}
#endif
// NPSTAT_COMPLEXCOMPARESABS_HH_
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Tue, Sep 30, 6:13 AM (1 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6547741
Default Alt Text
ComplexComparesAbs.hh (1 KB)
Attached To
Mode
rNPSTATSVN npstatsvn
Attached
Detach File
Event Timeline
Log In to Comment