[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] b-spline evaluation
From: |
Rhys Ulerich |
Subject: |
Re: [Help-gsl] b-spline evaluation |
Date: |
Tue, 17 Jan 2012 08:35:20 -0600 |
Hi Iryna,
Please keep help-gsl CCed on your replies.
>>> I've tried to construct b-splines and evaluate them on the uniform knots. I
>>> become always the same error on the margins of the interval, over which the
>>> b-splines where constructed.
>>>
>>> // construct five uniform knots {0, 1, 2, 3, 4}
>>> gsl_bspline_knots_uniform(0, 4, w);
>> Are you mixing "knots" and "breakpoints"? That method constructs
>> knots corresponding to uniform breakpoints on [0, 4].
> I have read this manual and used it by writing a program. I've also printed
> out the vector w -> knots, and it contains in my case the sequence {0, 1, 2,
> 3, 4}.
>
> ...
>
> So, I would like to know, why I don't get proper values at the margins of the
> given interval.
I maintain that you are mixing up "knots" and "breakpoints". Observe
that your uniform breakpoints from gsl_bspline_knots_uniform are
repeated at the first and last interval to form the knot vector.
These repeated knots influence the basis functions near the margins of
the interval:
#include <cstdio>
#include <iostream>
#include <gsl/gsl_bspline.h>
#include <gsl/gsl_vector.h>
int main()
{
// allocate workspace for 5 cubic b-spline functions
gsl_bspline_workspace * w = gsl_bspline_alloc(4, 5);
// construct five uniform BREAKPOINTS {0, 1, 2, 3, 4}
//
http://www.gnu.org/software/gsl/manual/html_node/Constructing-the-knots-vector.html
gsl_bspline_knots_uniform(0, 4, w);
// print the KNOTS which contains the BREAKPOINTS in the interior
//
// From
//
http://www.gnu.org/software/gsl/manual/html_node/Overview-of-B_002dsplines.html
// notice the sentence "To do this, the abscissa axis is broken up into some
// number of intervals, where the endpoints of each interval are called
// breakpoints. These breakpoints are then converted to knots by imposing
// various continuity and smoothness conditions at each interface.
std::cout << "Knots: " << std::endl;
gsl_vector_fprintf(stdout, w->knots, "%f ");
std::cout << std::endl;
}
This snippet outputs
Knots:
0.000000
0.000000
0.000000
0.000000
1.000000
2.000000
3.000000
4.000000
4.000000
4.000000
4.000000
where you can indeed see repeated knots.
Hope that helps,
Rhys