Nir,

Setup two one dimensional variables, y1 and y2 and a 2-D variable y  
with the same points. In this case a circle with the 5th point equal  
to the first. Run csape with the periodic condition and then inspect  
the structures produced. y should yield the same coefficients as y1  
and y2, just stacked into an array:

 >>> x = linspace(0, 2*pi, 5);
 >>> y1 = cos(x);
 >>> y2 = sin(x);
 >>> pp1 = csape(x, y1, 'periodic');
 >>> pp2 = csape(x, y2, 'periodic');
 >>> y = [y1; y2];
 >>> pp = csape(x, y, 'periodic');
 >>> pp1.P
ans =

    0.12901  -0.60793   0.00000   1.00000
    0.12901   0.00000  -0.95493   0.00000
   -0.12901   0.60793   0.00000  -1.00000
   -0.12901   0.00000   0.95493  -0.00000

 >>> pp2.P
ans =

   -0.12901  -0.00000   0.95493   0.00000
    0.12901  -0.60793   0.00000   1.00000
    0.12901  -0.00000  -0.95493   0.00000
   -0.12901   0.60793  -0.00000  -1.00000

 >>> pp.P
ans =

   -0.12901  -0.00000  -0.31831   1.00000
    0.12901  -0.60793  -0.00000   0.00000
    0.12901  -0.00000   0.31831  -1.00000
   -0.12901   0.60793   0.00000  -0.00000
    0.00000   0.00000   0.63662   0.00000
    0.00000   0.00000  -0.63662   1.00000
    0.00000   0.00000  -0.63662   0.00000
    0.00000   0.00000   0.63662  -1.00000

As you see they are quite different. This is from a saved session  
using spline 1.0.7, but I have had similar results with the latest  
splines 1.1.0. Actually, it looks like the only thing that has changed  
between 1.0.7 and 1.1.0 is the function mkpp now has different  
filednames. The latest edit noted in the comments of csape.m is Feb.  
19th 2001 in both versions.

All this is easy to see in a plot of the points overlaid with the  
splines too:

 >>> xpp = linspace(0, 2*pi, 201);
 >>> plot(y1, y2, 'ko', ppval(pp1, xpp), ppval(pp2, xpp), 'b-')
 >>> figure
 >>> yy = ppval(pp, xpp);
 >>> plot(y(1,:), y(2,:), 'ko', yy(1,:), yy(2,:), 'b-')

Now, after editing csape.m per my recommendation:

 >>> pp = csape(x, y, 'periodic');
 >>> pp.P
ans =

    0.12901  -0.60793   0.00000   1.00000
    0.12901   0.00000  -0.95493   0.00000
   -0.12901   0.60793   0.00000  -1.00000
   -0.12901   0.00000   0.95493  -0.00000
   -0.12901  -0.00000   0.95493   0.00000
    0.12901  -0.60793   0.00000   1.00000
    0.12901  -0.00000  -0.95493   0.00000
   -0.12901   0.60793  -0.00000  -1.00000

Just looking at idx in csape.m ( idx = ones (columns(a),1); ), you can  
see that using it in a matrix index on the left side of an equation  
makes no sense anyway.

Ted

On Nov 21, 2012, at 1:09 PM, Nir Krakauer wrote:

> Dear Ted,
>
> Can you give an example where it fails?
>
> Nir
>
> On Wed, Nov 21, 2012 at 3:25 AM, Ted Rippert <ted.ripp...@gmail.com>  
> wrote:
>> csape(x, y, "cond") with a boundary condition of "periodic" will work
>> for a one dimensional vector, but not for a matrix value for y. This
>> is fixed by changing line 162 in csape.m from:
>>
>>   c(2:n,idx) = z(:,2:end) - z(:,1) * fact;
>>
>> to:
>>
>>   c(2:n,:) = z(:,2:end) - z(:,1) * fact;


------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to