mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 23:31:12 +00:00
beginning to fold in HOD code with jeremy tinker's approval
This commit is contained in:
parent
d8108d3a8e
commit
44cd0eb71f
95 changed files with 21950 additions and 0 deletions
38
c_tools/hod/spline.c
Normal file
38
c_tools/hod/spline.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
#define NRANSI
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "nrutil.h"
|
||||
|
||||
void spline(double x[], double y[], int n, double yp1, double ypn, double y2[])
|
||||
{
|
||||
int i,k;
|
||||
double p,qn,sig,un,*u;
|
||||
|
||||
u=dvector(1,n-1);
|
||||
if (yp1 > 0.99e30)
|
||||
y2[1]=u[1]=0.0;
|
||||
else {
|
||||
y2[1] = -0.5;
|
||||
u[1]=(3.0/(x[2]-x[1]))*((y[2]-y[1])/(x[2]-x[1])-yp1);
|
||||
}
|
||||
for (i=2;i<=n-1;i++) {
|
||||
sig=(x[i]-x[i-1])/(x[i+1]-x[i-1]);
|
||||
p=sig*y2[i-1]+2.0;
|
||||
y2[i]=(sig-1.0)/p;
|
||||
u[i]=(y[i+1]-y[i])/(x[i+1]-x[i]) - (y[i]-y[i-1])/(x[i]-x[i-1]);
|
||||
u[i]=(6.0*u[i]/(x[i+1]-x[i-1])-sig*u[i-1])/p;
|
||||
}
|
||||
if (ypn > 0.99e30)
|
||||
qn=un=0.0;
|
||||
else {
|
||||
qn=0.5;
|
||||
un=(3.0/(x[n]-x[n-1]))*(ypn-(y[n]-y[n-1])/(x[n]-x[n-1]));
|
||||
}
|
||||
y2[n]=(un-qn*u[n-1])/(qn*y2[n-1]+1.0);
|
||||
for (k=n-1;k>=1;k--)
|
||||
{
|
||||
y2[k]=y2[k]*y2[k+1]+u[k];
|
||||
}
|
||||
free_dvector(u,1,n-1);
|
||||
}
|
||||
#undef NRANSI
|
Loading…
Add table
Add a link
Reference in a new issue