|
STK++ 1.0
|
Compute the regression splines coefficients of an additive model. More...
#include <STK_AdditiveBSplineCoefficients.h>


Public Member Functions | |
| AdditiveBSplineCoefficients (Matrix const *p_data, Integer const &nbControlPoints, Integer const °ree=3, BSplineCoefficients::KnotsPosition const &position=BSplineCoefficients::uniform_) | |
| Constructor : initialize the data members. | |
| virtual | ~AdditiveBSplineCoefficients () |
| Destructor. | |
| void | setData (Matrix const *p_data, Integer const &nbControlPoints, Integer const °ree=3, BSplineCoefficients::KnotsPosition const &position=BSplineCoefficients::uniform_) |
| Compute the coefficients of the B-Spline curve for the given values. | |
| bool | run () |
| run the computations. | |
| Integer const & | degree () const |
| give the degree of the B-Spline curves. | |
| Integer const & | nbKnots () const |
| give the number of knots of the B-Spline curves. | |
| Integer const & | nbControlPoints () const |
| give the number of control points of the B-Spline curves. | |
| Matrix const & | coefficients () const |
| give the computed coefficients of the B-Spline curves. | |
Protected Attributes | |
| Matrix const * | p_data_ |
| the input data set | |
| Integer | nbKnots_ |
| number of knots of the B-Spline curves. | |
| Integer | nbControlPoints_ |
| number of control points of the B-Spline curves. | |
| Integer | degree_ |
| degree of the B-splines curves. | |
| BSplineCoefficients::KnotsPosition | position_ |
| Method used in order to position the knots. | |
| Matrix | coefficients_ |
| Matrix of the coefficients. | |
Compute the regression splines coefficients of an additive model.
The method is described in BSplineCoefficients documentation class and repeated for each variables of the model. The number of control points, the degree and the position of the knots are the same for all variables.
If the input data set is a matrix of size (n,p) then the output matrix of the coefficients Coefficients() is a matrix of size (n, p*nbControlPoints) where p is the number of variables.
Definition at line 56 of file STK_AdditiveBSplineCoefficients.h.
| STK::AdditiveBSplineCoefficients::AdditiveBSplineCoefficients | ( | Matrix const * | p_data, |
| Integer const & | nbControlPoints, | ||
| Integer const & | degree = 3, |
||
| BSplineCoefficients::KnotsPosition const & | position = BSplineCoefficients::uniform_ |
||
| ) |
Constructor : initialize the data members.
The number of knots is given by the formula nbKnots = nbControlPoints + degree +1.
| p_data | the input data values |
| nbControlPoints | number of control points |
| degree | degree of the B-Spline curves |
| position | method to use for positioning the knots |
Definition at line 46 of file STK_AdditiveBSplineCoefficients.cpp.
: IRunnerBase() , p_data_(p_data) , nbKnots_(nbControlPoints + degree +1) , nbControlPoints_(nbControlPoints) , degree_(degree) , position_(position) , coefficients_() { ; }
| STK::AdditiveBSplineCoefficients::~AdditiveBSplineCoefficients | ( | ) | [virtual] |
| void STK::AdditiveBSplineCoefficients::setData | ( | Matrix const * | p_data, |
| Integer const & | nbControlPoints, | ||
| Integer const & | degree = 3, |
||
| BSplineCoefficients::KnotsPosition const & | position = BSplineCoefficients::uniform_ |
||
| ) |
Compute the coefficients of the B-Spline curve for the given values.
| p_data | the input data values |
| nbControlPoints | number of control points |
| degree | degree of the B-Spline curves |
| position | method to use for positioning the knots |
Definition at line 109 of file STK_AdditiveBSplineCoefficients.cpp.
References degree(), degree_, nbControlPoints(), nbControlPoints_, nbKnots_, p_data_, and position_.
Referenced by STK::AdditiveBSplineRegression::preRun().
{
p_data_ =p_data;
nbKnots_ = nbControlPoints + degree +1;
nbControlPoints_ = nbControlPoints;
degree_ = degree;
position_ = position;
}

| bool STK::AdditiveBSplineCoefficients::run | ( | ) | [virtual] |
run the computations.
Implements STK::IRunnerBase.
Definition at line 65 of file STK_AdditiveBSplineCoefficients.cpp.
References _T, STK::BSplineCoefficients::coefficients(), coefficients_, degree_, STK::IContainer2D::firstCol(), STK::IContainer2D::lastCol(), STK::IRunnerBase::msg_error_, nbControlPoints_, p_data_, position_, STK::ITArray2DBase< TYPE, PTRCOL, TArray2D >::pushBackByTransfer(), STK::IContainer2D::rangeVe(), STK::IContainer2D::resize(), STK::BSplineCoefficients::run(), and stk_cout.
Referenced by STK::AdditiveBSplineRegression::preRun().
{
#ifdef STK_VERBOSE
stk_cout << _T("in AdditiveBSplineCoefficients::run()\n");
#endif
// check if there exists data
if (!p_data_)
{
msg_error_ = _T("Error In AdditiveBSplineCoefficients::run()\nWhat: no data\n");
return false;
}
try {
// resize the matrix of coefficient
coefficients_.resize(p_data_->rangeVe(), Range());
// get dimensions
const Integer first = p_data_->firstCol(), last = p_data_->lastCol();
for (Integer i=first; i<=last; i++)
{
// create a reference on the ith column of the data
Vector colData((*p_data_)[i], true);
BSplineCoefficients coefs(colData, nbControlPoints_, degree_, position_);
coefs.run();
// get coefficients
coefficients_.pushBackByTransfer(coefs.coefficients());
}
} catch (runtime_error e)
{
msg_error_ = e.what();
return false;
}
#ifdef STK_VERBOSE
stk_cout << _T("AdditiveBSplineCoefficients::run() done\n");
#endif
return true;
}

| Integer const& STK::AdditiveBSplineCoefficients::degree | ( | ) | const [inline] |
give the degree of the B-Spline curves.
Definition at line 91 of file STK_AdditiveBSplineCoefficients.h.
References degree_.
Referenced by setData().
{ return degree_;}
| Integer const& STK::AdditiveBSplineCoefficients::nbKnots | ( | ) | const [inline] |
give the number of knots of the B-Spline curves.
Definition at line 93 of file STK_AdditiveBSplineCoefficients.h.
References nbKnots_.
{ return nbKnots_;}
| Integer const& STK::AdditiveBSplineCoefficients::nbControlPoints | ( | ) | const [inline] |
give the number of control points of the B-Spline curves.
Definition at line 95 of file STK_AdditiveBSplineCoefficients.h.
References nbControlPoints_.
Referenced by setData().
{ return nbControlPoints_;}
| Matrix const& STK::AdditiveBSplineCoefficients::coefficients | ( | ) | const [inline] |
give the computed coefficients of the B-Spline curves.
This is a matrix of size (p_data_->range(), 0:lastControlPoints).
Definition at line 99 of file STK_AdditiveBSplineCoefficients.h.
References coefficients_.
Referenced by STK::AdditiveBSplineRegression::coefficients(), STK::AdditiveBSplineRegression::prediction(), and STK::AdditiveBSplineRegression::regression().
{ return coefficients_;}
Matrix const* STK::AdditiveBSplineCoefficients::p_data_ [protected] |
the input data set
Definition at line 103 of file STK_AdditiveBSplineCoefficients.h.
Integer STK::AdditiveBSplineCoefficients::nbKnots_ [protected] |
number of knots of the B-Spline curves.
Definition at line 105 of file STK_AdditiveBSplineCoefficients.h.
number of control points of the B-Spline curves.
Definition at line 107 of file STK_AdditiveBSplineCoefficients.h.
Referenced by nbControlPoints(), run(), and setData().
Integer STK::AdditiveBSplineCoefficients::degree_ [protected] |
degree of the B-splines curves.
Definition at line 109 of file STK_AdditiveBSplineCoefficients.h.
Method used in order to position the knots.
Definition at line 111 of file STK_AdditiveBSplineCoefficients.h.
Matrix of the coefficients.
Definition at line 113 of file STK_AdditiveBSplineCoefficients.h.
Referenced by coefficients(), and run().