Spline problem


toma
01-14-2004, 03:56 AM
Hi,

I'm having a problem with the spline function.

Below is some very simplified code. My problem is that I cannot seem to get the spline to go through the first point (0,0) whatever end derivatives I use (slightly better with 1e30 but still gives 4 instead of 0). Can anyone spot something that I am doing wrong??

Thanks very much for your help

Tom

int main()
{
float x[] = {0, 40, 80,120,140,180};
float y[] = {0, 6 , 8, 8, 7, 6};
float y2[6];

spline(x, y, 6, 0, 0, y2);

float ty;
int tx;
for (tx = 0; tx <= 180; tx += 20)
{
splint(x, y, y2, 6, tx, &ty);
printf("TX %4d: TY %3.2f\n",tx,ty);
}

return 0;
}

Output is:
TX 0: TY 12.12
TX 20: TY 7.27
TX 40: TY 6.00
TX 60: TY 6.76
TX 80: TY 8.00
TX 100: TY 8.46
TX 120: TY 8.00
TX 140: TY 7.00
TX 160: TY 6.47
TX 180: TY 6.00

toma
01-14-2004, 05:20 AM
Sorry, worked it out... I was assuming zero offset arrays...

Tom

siddharth
06-08-2005, 11:28 AM
hi,
i am sid.i purchased NR software 2 days back. I want to use some routines of NR in C (cubic spline) to my code.my code is of pspice(circuit simulator) which i obtained from cadencce. it contains the MSVC++ project file,
DEVEQ.DSP, which is included to compile and link the DLL for this code.
because of this, i cant follow
the way NR ask to make workspace and compile as it is essential to load DEVEQ.DSP.could u plz guide me how i can overcome this problem.
i would really appreciate ur help.
thank you.
waiting for ur reply.
Sid.