add numerical recipes library

This commit is contained in:
2025-09-12 18:55:25 +09:00
parent d4dff245bd
commit 2c75620ec9
1344 changed files with 63869 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
#include <cmath>
#include "nr.h"
using namespace std;
void NR::fdjac(Vec_IO_DP &x, Vec_I_DP &fvec, Mat_O_DP &df,
void vecfunc(Vec_I_DP &, Vec_O_DP &))
{
const DP EPS=1.0e-8;
int i,j;
DP h,temp;
int n=x.size();
Vec_DP f(n);
for (j=0;j<n;j++) {
temp=x[j];
h=EPS*fabs(temp);
if (h == 0.0) h=EPS;
x[j]=temp+h;
h=x[j]-temp;
vecfunc(x,f);
x[j]=temp;
for (i=0;i<n;i++)
df[i][j]=(f[i]-fvec[i])/h;
}
}