|
Boost : |
From: Daryle Walker (darylew_at_[hidden])
Date: 2001-05-24 16:16:29
With the discussion over quaternions, I'm wondering if we should have a
header describing numeric type properties. Maybe like:
template < typename T >
class boost::numeric_traits
{
static const bool is_specialized = false;
static const bool has_real = false;
static const bool is_scalar = false;
static const bool has_magnitude = false;
typedef T component_type;
typedef component_type magnitude_type;
//...
};
Specializations of the template should define "is_specialized" to be TRUE,
of course. Only types that are real and scalar would have
std::numeric_limits specializations. Vector-like types that include the
real numbers, like complex and quaternion numbers, would have "has_real"
TRUE but "is_scalar" FALSE. Category types, like modulo arithmetic, would
have "has_real" FALSE but "is_scalar" TRUE. Matrices and true-vectors would
have both "has_real" and "is_scalar" FALSE. The types of the components is
described as "component_type." (What would happen with heterogeneous number
types? Can they exist?) If the number can be collapsed to a scalar
describing its relative size (indicated with "has_magnitude"), the type of
that size (from an "abs" function) is "magnitude_type."
-- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT mac DOT com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk