STK++ 0.9.13
STK_Arithmetic.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
23*/
24
25/*
26 * Project: STKernel::Arithmetic
27 * Purpose: DSefine template arithmetic for handling special values (NA).
28 * Author: Serge Iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 **/
30
36#ifndef STK_ARITHMETIC_H
37#define STK_ARITHMETIC_H
38
39#include <limits>
40
41namespace STK
42{
147
186template<class Type>
187struct Arithmetic: public std::numeric_limits<Type>
188{
190 static const bool hasNA = false;
194 static inline Type NA() throw() { return static_cast<Type>(0);}
198 static inline bool isNA(Type const& x) throw() { return false;}
203 static inline bool isInfinite(Type const& x) throw() { return false; }
208 static inline bool isFinite(Type const& x) throw() { return (!isNA(x) && !isInfinite(x));}
209};
210
213template<class Type>
214bool isNA(Type const& x) { return Arithmetic<Type>::isNA(x);}
215
218template<class Type>
219bool isFinite(Type const& x) { return Arithmetic<Type>::isFinite(x);}
220
223template<class Type>
224bool isInfinite(Type const& x) { return Arithmetic<Type>::isInfinite(x);}
225
226} // namespace STK
227
228#endif /* STK_ARITHMETIC_H */
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
bool isFinite(Type const &x)
utility method allowing to know if a value is a finite value
bool isNA(Type const &x)
utility method allowing to know if a value is a NA (Not Available) value
bool isInfinite(Type const &x)
utility method allowing to know if a value is an infinite value
The namespace STK is the main domain space of the Statistical ToolKit project.
Arithmetic properties of STK fundamental types.
static bool isFinite(Type const &x)
static bool isInfinite(Type const &x)
static const bool hasNA
True if the type has a representation for a "Not Available."
static Type NA()
Adding a Non Available (NA) special number.
static bool isNA(Type const &x)