add numerical recipes library
This commit is contained in:
17
lib/nr/k_and_r/recipes/resid.c
Normal file
17
lib/nr/k_and_r/recipes/resid.c
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
void resid(res,u,rhs,n)
|
||||
double **res,**rhs,**u;
|
||||
int n;
|
||||
{
|
||||
int i,j;
|
||||
double h,h2i;
|
||||
|
||||
h=1.0/(n-1);
|
||||
h2i=1.0/(h*h);
|
||||
for (j=2;j<n;j++)
|
||||
for (i=2;i<n;i++)
|
||||
res[i][j] = -h2i*(u[i+1][j]+u[i-1][j]+u[i][j+1]+u[i][j-1]-
|
||||
4.0*u[i][j])+rhs[i][j];
|
||||
for (i=1;i<=n;i++)
|
||||
res[i][1]=res[i][n]=res[1][i]=res[n][i]=0.0;
|
||||
}
|
||||
Reference in New Issue
Block a user