STK++ 1.0
STK_BSplineCoefficients.h
Go to the documentation of this file.
00001 /*--------------------------------------------------------------------*/
00002 /*     Copyright (C) 2004-2010  Serge Iovleff
00003 
00004  This program is free software; you can redistribute it and/or modify
00005  it under the terms of the GNU Lesser General Public License as
00006  published by the Free Software Foundation; either version 2 of the
00007  License, or (at your option) any later version.
00008 
00009  This program is distributed in the hope that it will be useful,
00010  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  GNU Lesser General Public License for more details.
00013 
00014  You should have received a copy of the GNU Lesser General Public
00015  License along with this program; if not, write to the
00016  Free Software Foundation, Inc.,
00017  59 Temple Place,
00018  Suite 330,
00019  Boston, MA 02111-1307
00020  USA
00021 
00022  Contact : Serge.Iovleff@stkpp.org
00023  */
00024 
00025 /*
00026  * Project:  stkpp::Regress
00027  * created on: 25 juin 2010
00028  * Purpose:  Compute the coefficient of a B-Spline curves.
00029  * Author:   iovleff, serge.iovleff@stkpp.org
00030  **/
00031 
00036 #ifndef STK_BSPLINECOEFFICIENTS_H
00037 #define STK_BSPLINECOEFFICIENTS_H
00038 
00039 #include "../../Arrays/include/STK_Matrix.h"
00040 
00041 namespace STK
00042 {
00043 
00044 
00053 class BSplineCoefficients
00054 {
00055   public:
00057     enum KnotsPosition
00058     {
00059       uniform_  
00060     , periodic_ 
00061     , density_  
00062     , unknown_  
00063     };
00064 
00070     static KnotsPosition StringToKnotsPosition( String const& type);
00071 
00076     static String KnotsPositionToString( KnotsPosition const& type);
00077 
00086     BSplineCoefficients( Vector const* p_data
00087                        , Integer const& nbControlPoints
00088                        , Integer const& degree = 3
00089                        , KnotsPosition const& position = uniform_
00090                        );
00091 
00100     BSplineCoefficients( Vector const& data
00101                        , Integer const& nbControlPoints
00102                        , Integer const& degree = 3
00103                        , KnotsPosition const& position = uniform_
00104                        );
00105 
00107     virtual ~BSplineCoefficients();
00108 
00110     void run();
00111 
00118     void setData( Vector const* p_data
00119                 , Integer const& nbControlPoints
00120                 , Integer const& degree = 3
00121                 , KnotsPosition const& position = uniform_
00122                 );
00123 
00125     inline Integer const& degree() const { return degree_;}
00127     inline Integer const& nbKnots() const { return nbKnots_;}
00129     inline Integer const& nbControlPoints() const { return nbControlPoints_;}
00131     inline Vector const& knots() const { return knots_;}
00135     inline Matrix const& coefficients() const { return coefficients_;}
00136 
00137   protected:
00139     Vector const* p_data_;
00141     Integer nbKnots_;
00143     Integer lastKnot_;
00145     Integer nbControlPoints_;
00149     Integer lastControlPoint_;
00151     Integer degree_;
00153     KnotsPosition position_;
00155     Vector knots_;
00157     Matrix coefficients_;
00158 
00159   private:
00161     Real minValue_;
00163     Real maxValue_;
00165     void computeKnots();
00167     void computeUniformKnots();
00169     void computePeriodicKnots();
00171     void computeDensityKnots();
00173     void computeCoefficients();
00177     void computeCoefficientsRow(Integer const& irow);
00178 };
00179 
00180 }
00181 
00182 #endif /* STK_BSPLINECOEFFICIENTS_H */