STK++ 0.9.13
STK_Funct_Util.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff, Université Lille 1, Inria
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: Analysis
27 * Purpose: Usual mathematical functions
28 * Author: Serge Iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 **/
30
35#ifndef STK_FUNCT_UTIL_H
36#define STK_FUNCT_UTIL_H
37
38#include "STK_ISerie.h"
39
40namespace STK
41{
42
43namespace Funct
44{
50class Serielog1p: public ISerie<Serielog1p>
51{
52 public:
53 inline Serielog1p( Real const& x): x_(x), n_(2), xpown_(1.) {}
54 inline Real firstImpl() const { return 1./n_;}
55 inline Real nextImpl() const { return (xpown_ *= x_)/(++n_);}
56
57 private:
58 const Real& x_;
59 mutable Real n_;
60 mutable Real xpown_;
61};
62
72template<int N>
73inline Real evalPolynomial( Real x, const Real* P)
74{ return P[N] + x * evalPolynomial<N-1>(x,P);}
75template<>
76inline Real evalPolynomial<0>( Real x, const Real* P)
77{ return P[0];}
78
89template<int N>
90inline Real evalPolynomial1( Real x, const Real* P)
91{ return P[N-1] + x * evalPolynomial1<N-1>(x,P);}
92template<>
93inline Real evalPolynomial1<0>( Real x, const Real* P)
94{ return 1.;}
95
96} // namespace Funct
97
98} // namespace STK
99
100#endif // STK_FUNCT_UTIL_H
In this file we define Interface base class for Real Series.
This Series computes.
Serielog1p(Real const &x)
Interface base class for Series.
Definition STK_ISerie.h:67
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Real evalPolynomial1(Real x, const Real *P)
Polynomial evaluator.
Real evalPolynomial(Real x, const Real *P)
Polynomial evaluator.
double Real
STK fundamental type of Real values.
Real evalPolynomial< 0 >(Real x, const Real *P)
Real evalPolynomial1< 0 >(Real x, const Real *P)
The namespace STK is the main domain space of the Statistical ToolKit project.