[SOLVED] 代写 C math void lubksbfloat a, int n, int indx, float b

30 $

File Name: 代写_C_math_void_lubksbfloat_a,_int_n,_int_indx,_float_b.zip
File Size: 546.36 KB

SKU: 5900297981 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


void lubksbfloat a, int n, int indx, float b

int i,ii0,ip,j;
float sum;

for i1;in;i
ipindxi;
sumbip;
bipbi;
if ii
for jii;ji1;j sumaijbj;
else if sum iii;
bisum;

for in;i1;i
sumbi;
for ji1;jn;j sumaijbj;
bisumaii;

include math.h
define NRANSI
include nrutil.h
define TINY 1.0e20

void ludcmpfloat a, int n, int indx, float d

int i,imax,j,k;
float big,dum,sum,temp;
float vv;

vvvector1,n;
d1.0;
for i1;in;i
big0.0;
for j1;jn;j
if tempfabsaijbig bigtemp;
if big0.0 nrerrorSingular matrix in routine ludcmp;
vvi1.0big;

for j1;jn;j
for i1;ij;i
sumaij;
for k1;ki;k sumaikakj;
aijsum;

big0.0;
for ij;in;i
sumaij;
for k1;kj;k
sumaikakj;
aijsum;
ifdumvvifabssumbig
bigdum;
imaxi;

if j ! imax
for k1;kn;k
dumaimaxk;
aimaxkajk;
ajkdum;

dd;
vvimaxvvj;

indxjimax;
if ajj0.0 ajjTINY;
if j ! n
dum1.0ajj;
for ij1;in;i aijdum;

freevectorvv,1,n;

undef TINY
undef NRANSI

define NRANSI
include nrutil.h

void mprovefloat a, float alud, int n, int indx, float b, float x

void lubksbfloat a, int n, int indx, float b;
int j,i;
double sdp;
float r;

rvector1,n;
for i1;in;i
sdpbi;
for j1;jn;j sdpaijxj;
risdp;

lubksbalud,n,indx,r;
for i1;in;i xiri;
freevectorr,1,n;

undef NRANSI
if definedSTDCdefinedANSIdefinedNRANSIANSI

include stdio.h
include stddef.h
include stdlib.h
define NREND 1
define FREEARG char

void nrerrorchar errortext
Numerical Recipes standard error handler

fprintfstderr,Numerical Recipes runtime error…n;
fprintfstderr,sn,errortext;
fprintfstderr,…now exiting to system…n;
exit1;

float vectorlong nl, long nh
allocate a float vector with subscript range vnl..nh

float v;

vfloat mallocsizet nhnl1NRENDsizeoffloat;
if !v nrerrorallocation failure in vector;
return vnlNREND;

int ivectorlong nl, long nh
allocate an int vector with subscript range vnl..nh

int v;

vint mallocsizet nhnl1NRENDsizeofint;
if !v nrerrorallocation failure in ivector;
return vnlNREND;

unsigned char cvectorlong nl, long nh
allocate an unsigned char vector with subscript range vnl..nh

unsigned char v;

vunsigned char mallocsizet nhnl1NRENDsizeofunsigned char;
if !v nrerrorallocation failure in cvector;
return vnlNREND;

unsigned long lvectorlong nl, long nh
allocate an unsigned long vector with subscript range vnl..nh

unsigned long v;

vunsigned long mallocsizet nhnl1NRENDsizeoflong;
if !v nrerrorallocation failure in lvector;
return vnlNREND;

double dvectorlong nl, long nh
allocate a double vector with subscript range vnl..nh

double v;

vdouble mallocsizet nhnl1NRENDsizeofdouble;
if !v nrerrorallocation failure in dvector;
return vnlNREND;

float matrixlong nrl, long nrh, long ncl, long nch
allocate a float matrix with subscript range mnrl..nrhncl..nch

long i, nrownrhnrl1,ncolnchncl1;
float m;

allocate pointers to rows
mfloatmallocsizetnrowNRENDsizeoffloat;
if !m nrerrorallocation failure 1 in matrix;
mNREND;
mnrl;

allocate rows and set pointers to them
mnrlfloatmallocsizetnrowncolNRENDsizeoffloat;
if !mnrl nrerrorallocation failure 2 in matrix;
mnrlNREND;
mnrlncl;

forinrl1;inrh;i mimi1ncol;

return pointer to array of pointers to rows
return m;

double dmatrixlong nrl, long nrh, long ncl, long nch
allocate a double matrix with subscript range mnrl..nrhncl..nch

long i, nrownrhnrl1,ncolnchncl1;
double m;

allocate pointers to rows
mdoublemallocsizetnrowNRENDsizeofdouble;
if !m nrerrorallocation failure 1 in matrix;
mNREND;
mnrl;

allocate rows and set pointers to them
mnrldoublemallocsizetnrowncolNRENDsizeofdouble;
if !mnrl nrerrorallocation failure 2 in matrix;
mnrlNREND;
mnrlncl;

forinrl1;inrh;i mimi1ncol;

return pointer to array of pointers to rows
return m;

int imatrixlong nrl, long nrh, long ncl, long nch
allocate a int matrix with subscript range mnrl..nrhncl..nch

long i, nrownrhnrl1,ncolnchncl1;
int m;

allocate pointers to rows
mintmallocsizetnrowNRENDsizeofint;
if !m nrerrorallocation failure 1 in matrix;
mNREND;
mnrl;

allocate rows and set pointers to them
mnrlintmallocsizetnrowncolNRENDsizeofint;
if !mnrl nrerrorallocation failure 2 in matrix;
mnrlNREND;
mnrlncl;

forinrl1;inrh;i mimi1ncol;

return pointer to array of pointers to rows
return m;

float submatrixfloat a, long oldrl, long oldrh, long oldcl, long oldch,
long newrl, long newcl
point a submatrix newrl..newcl.. to aoldrl..oldrholdcl..oldch

long i,j,nrowoldrholdrl1,ncololdclnewcl;
float m;

allocate array of pointers to rows
mfloatmallocsizet nrowNRENDsizeoffloat;
if !m nrerrorallocation failure in submatrix;
mNREND;
mnewrl;

set pointers to rows
forioldrl,jnewrl;ioldrh;i,j mjaincol;

return pointer to array of pointers to rows
return m;

float convertmatrixfloat a, long nrl, long nrh, long ncl, long nch
allocate a float matrix mnrl..nrhncl..nch that points to the matrix
declared in the standard C manner as anrowncol, where nrownrhnrl1
and ncolnchncl1. The routine should be called with the address
a00 as the first argument.

long i,j,nrownrhnrl1,ncolnchncl1;
float m;

allocate pointers to rows
mfloatmallocsizet nrowNRENDsizeoffloat;
if !m nrerrorallocation failure in convertmatrix;
mNREND;
mnrl;

set pointers to rows
mnrlancl;
fori1,jnrl1;inrow;i,j mjmj1ncol;
return pointer to array of pointers to rows
return m;

float f3tensorlong nrl, long nrh, long ncl, long nch, long ndl, long ndh
allocate a float 3tensor with range tnrl..nrhncl..nchndl..ndh

long i,j,nrownrhnrl1,ncolnchncl1,ndepndhndl1;
float t;

allocate pointers to pointers to rows
tfloatmallocsizetnrowNRENDsizeoffloat;
if !t nrerrorallocation failure 1 in f3tensor;
tNREND;
tnrl;

allocate pointers to rows and set pointers to them
tnrlfloatmallocsizetnrowncolNRENDsizeoffloat;
if !tnrl nrerrorallocation failure 2 in f3tensor;
tnrlNREND;
tnrlncl;

allocate rows and set pointers to them
tnrlnclfloatmallocsizetnrowncolndepNRENDsizeoffloat;
if !tnrlncl nrerrorallocation failure 3 in f3tensor;
tnrlnclNREND;
tnrlnclndl;

forjncl1;jnch;j tnrljtnrlj1ndep;
forinrl1;inrh;i
titi1ncol;
tinclti1nclncolndep;
forjncl1;jnch;j tijtij1ndep;

return pointer to array of pointers to rows
return t;

void freevectorfloat v, long nl, long nh
free a float vector allocated with vector

freeFREEARG vnlNREND;

void freeivectorint v, long nl, long nh
free an int vector allocated with ivector

freeFREEARG vnlNREND;

void freecvectorunsigned char v, long nl, long nh
free an unsigned char vector allocated with cvector

freeFREEARG vnlNREND;

void freelvectorunsigned long v, long nl, long nh
free an unsigned long vector allocated with lvector

freeFREEARG vnlNREND;

void freedvectordouble v, long nl, long nh
free a double vector allocated with dvector

freeFREEARG vnlNREND;

void freematrixfloat m, long nrl, long nrh, long ncl, long nch
free a float matrix allocated by matrix

freeFREEARG mnrlnclNREND;
freeFREEARG mnrlNREND;

void freedmatrixdouble m, long nrl, long nrh, long ncl, long nch
free a double matrix allocated by dmatrix

freeFREEARG mnrlnclNREND;
freeFREEARG mnrlNREND;

void freeimatrixint m, long nrl, long nrh, long ncl, long nch
free an int matrix allocated by imatrix

freeFREEARG mnrlnclNREND;
freeFREEARG mnrlNREND;

void freesubmatrixfloat b, long nrl, long nrh, long ncl, long nch
free a submatrix allocated by submatrix

freeFREEARG bnrlNREND;

void freeconvertmatrixfloat b, long nrl, long nrh, long ncl, long nch
free a matrix allocated by convertmatrix

freeFREEARG bnrlNREND;

void freef3tensorfloat t, long nrl, long nrh, long ncl, long nch,
long ndl, long ndh
free a float f3tensor allocated by f3tensor

freeFREEARG tnrlnclndlNREND;
freeFREEARG tnrlnclNREND;
freeFREEARG tnrlNREND;

elseANSI
traditionalKR

include stdio.h
define NREND 1
define FREEARG char

void nrerrorerrortext
char errortext;
Numerical Recipes standard error handler

void exit;

fprintfstderr,Numerical Recipes runtime error…n;
fprintfstderr,sn,errortext;
fprintfstderr,…now exiting to system…n;
exit1;

float vectornl,nh
long nh,nl;
allocate a float vector with subscript range vnl..nh

float v;

vfloat mallocunsigned int nhnl1NRENDsizeoffloat;
if !v nrerrorallocation failure in vector;
return vnlNREND;

int ivectornl,nh
long nh,nl;
allocate an int vector with subscript range vnl..nh

int v;

vint mallocunsigned int nhnl1NRENDsizeofint;
if !v nrerrorallocation failure in ivector;
return vnlNREND;

unsigned char cvectornl,nh
long nh,nl;
allocate an unsigned char vector with subscript range vnl..nh

unsigned char v;

vunsigned char mallocunsigned int nhnl1NRENDsizeofunsigned char;
if !v nrerrorallocation failure in cvector;
return vnlNREND;

unsigned long lvectornl,nh
long nh,nl;
allocate an unsigned long vector with subscript range vnl..nh

unsigned long v;

vunsigned long mallocunsigned int nhnl1NRENDsizeoflong;
if !v nrerrorallocation failure in lvector;
return vnlNREND;

double dvectornl,nh
long nh,nl;
allocate a double vector with subscript range vnl..nh

double v;

vdouble mallocunsigned int nhnl1NRENDsizeofdouble;
if !v nrerrorallocation failure in dvector;
return vnlNREND;

float matrixnrl,nrh,ncl,nch
long nch,ncl,nrh,nrl;
allocate a float matrix with subscript range mnrl..nrhncl..nch

long i, nrownrhnrl1,ncolnchncl1;
float m;

allocate pointers to rows
mfloatmallocunsigned intnrowNRENDsizeoffloat;
if !m nrerrorallocation failure 1 in matrix;
mNREND;
mnrl;

allocate rows and set pointers to them
mnrlfloatmallocunsigned intnrowncolNRENDsizeoffloat;
if !mnrl nrerrorallocation failure 2 in matrix;
mnrlNREND;
mnrlncl;

forinrl1;inrh;i mimi1ncol;

return pointer to array of pointers to rows
return m;

double dmatrixnrl,nrh,ncl,nch
long nch,ncl,nrh,nrl;
allocate a double matrix with subscript range mnrl..nrhncl..nch

long i, nrownrhnrl1,ncolnchncl1;
double m;

allocate pointers to rows
mdoublemallocunsigned intnrowNRENDsizeofdouble;
if !m nrerrorallocation failure 1 in matrix;
mNREND;
mnrl;

allocate rows and set pointers to them
mnrldoublemallocunsigned intnrowncolNRENDsizeofdouble;
if !mnrl nrerrorallocation failure 2 in matrix;
mnrlNREND;
mnrlncl;

forinrl1;inrh;i mimi1ncol;

return pointer to array of pointers to rows
return m;

int imatrixnrl,nrh,ncl,nch
long nch,ncl,nrh,nrl;
allocate a int matrix with subscript range mnrl..nrhncl..nch

long i, nrownrhnrl1,ncolnchncl1;
int m;

allocate pointers to rows
mintmallocunsigned intnrowNRENDsizeofint;
if !m nrerrorallocation failure 1 in matrix;
mNREND;
mnrl;

allocate rows and set pointers to them
mnrlintmallocunsigned intnrowncolNRENDsizeofint;
if !mnrl nrerrorallocation failure 2 in matrix;
mnrlNREND;
mnrlncl;

forinrl1;inrh;i mimi1ncol;

return pointer to array of pointers to rows
return m;

float submatrixa,oldrl,oldrh,oldcl,oldch,newrl,newcl
float a;
long newcl,newrl,oldch,oldcl,oldrh,oldrl;
point a submatrix newrl..newcl.. to aoldrl..oldrholdcl..oldch

long i,j,nrowoldrholdrl1,ncololdclnewcl;
float m;

allocate array of pointers to rows
mfloatmallocunsigned int nrowNRENDsizeoffloat;
if !m nrerrorallocation failure in submatrix;
mNREND;
mnewrl;

set pointers to rows
forioldrl,jnewrl;ioldrh;i,j mjaincol;

return pointer to array of pointers to rows
return m;

float convertmatrixa,nrl,nrh,ncl,nch
float a;
long nch,ncl,nrh,nrl;
allocate a float matrix mnrl..nrhncl..nch that points to the matrix
declared in the standard C manner as anrowncol, where nrownrhnrl1
and ncolnchncl1. The routine should be called with the address
a00 as the first argument.

long i,j,nrownrhnrl1,ncolnchncl1;
float m;

allocate pointers to rows
mfloatmallocunsigned int nrowNRENDsizeoffloat;
if !mnrerrorallocation failure in convertmatrix;
mNREND;
mnrl;

set pointers to rows
mnrlancl;
fori1,jnrl1;inrow;i,j mjmj1ncol;
return pointer to array of pointers to rows
return m;

float f3tensornrl,nrh,ncl,nch,ndl,ndh
long nch,ncl,ndh,ndl,nrh,nrl;
allocate a float 3tensor with range tnrl..nrhncl..nchndl..ndh

long i,j,nrownrhnrl1,ncolnchncl1,ndepndhndl1;
float t;

allocate pointers to pointers to rows
tfloatmallocunsigned intnrowNRENDsizeoffloat;
if !t nrerrorallocation failure 1 in f3tensor;
tNREND;
tnrl;

allocate pointers to rows and set pointers to them
tnrlfloatmallocunsigned intnrowncolNRENDsizeoffloat;
if !tnrl nrerrorallocation failure 2 in f3tensor;
tnrlNREND;
tnrlncl;

allocate rows and set pointers to them
tnrlnclfloatmallocunsigned intnrowncolndepNRENDsizeoffloat;
if !tnrlncl nrerrorallocation failure 3 in f3tensor;
tnrlnclNREND;
tnrlnclndl;

forjncl1;jnch;j tnrljtnrlj1ndep;
forinrl1;inrh;i
titi1ncol;
tinclti1nclncolndep;
forjncl1;jnch;j tijtij1ndep;

return pointer to array of pointers to rows
return t;

void freevectorv,nl,nh
float v;
long nh,nl;
free a float vector allocated with vector

freeFREEARG vnlNREND;

void freeivectorv,nl,nh
int v;
long nh,nl;
free an int vector allocated with ivector

freeFREEARG vnlNREND;

void freecvectorv,nl,nh
long nh,nl;
unsigned char v;
free an unsigned char vector allocated with cvector

freeFREEARG vnlNREND;

void freelvectorv,nl,nh
long nh,nl;
unsigned long v;
free an unsigned long vector allocated with lvector

freeFREEARG vnlNREND;

void freedvectorv,nl,nh
double v;
long nh,nl;
free a double vector allocated with dvector

freeFREEARG vnlNREND;

void freematrixm,nrl,nrh,ncl,nch
float m;
long nch,ncl,nrh,nrl;
free a float matrix allocated by matrix

freeFREEARG mnrlnclNREND;
freeFREEARG mnrlNREND;

void freedmatrixm,nrl,nrh,ncl,nch
double m;
long nch,ncl,nrh,nrl;
free a double matrix allocated by dmatrix

freeFREEARG mnrlnclNREND;
freeFREEARG mnrlNREND;

void freeimatrixm,nrl,nrh,ncl,nch
int m;
long nch,ncl,nrh,nrl;
free an int matrix allocated by imatrix

freeFREEARG mnrlnclNREND;
freeFREEARG mnrlNREND;

void freesubmatrixb,nrl,nrh,ncl,nch
float b;
long nch,ncl,nrh,nrl;
free a submatrix allocated by submatrix

freeFREEARG bnrlNREND;

void freeconvertmatrixb,nrl,nrh,ncl,nch
float b;
long nch,ncl,nrh,nrl;
free a matrix allocated by convertmatrix

freeFREEARG bnrlNREND;

void freef3tensort,nrl,nrh,ncl,nch,ndl,ndh
float t;
long nch,ncl,ndh,ndl,nrh,nrl;
free a float f3tensor allocated by f3tensor

freeFREEARG tnrlnclndlNREND;
freeFREEARG tnrlnclNREND;
freeFREEARG tnrlNREND;

endifANSI

include math.h
define NRANSI
include nrutil.h
define BIG 1.0e30

void padedouble cof, int n, float resid

void lubksbfloat a, int n, int indx, float b;
void ludcmpfloat a, int n, int indx, float d;
void mprovefloat a, float alud, int n, int indx, float b,
float x;
int j,k,indx;
float d,rr,rrold,sum,q,qlu,x,y,z;

indxivector1,n;
qmatrix1,n,1,n;
qlumatrix1,n,1,n;
xvector1,n;
yvector1,n;
zvector1,n;
for j1;jn;j
yjxjcofnj;
for k1;kn;k
qjkcofjkn;
qlujkqjk;

ludcmpqlu,n,indx,d;
lubksbqlu,n,indx,x;
rrBIG;
do
rroldrr;
for j1;jn;j zjxj;
mproveq,qlu,n,indx,y,x;
rr0.0;
for j1;jn;j
rrSQRzjxj;
while rrrrold;
residsqrtrrold;
for k1;kn;k
for sumcofk,j1;jk;j sumzjcofkj;
yksum;

for j1;jn;j
cofjyj;
cofjnzj;

freevectorz,1,n;
freevectory,1,n;
freevectorx,1,n;
freematrixqlu,1,n,1,n;
freematrixq,1,n,1,n;
freeivectorindx,1,n;

undef BIG
undef NRANSI

double ratvaldouble x, double cof, int mm, int kk

int j;
double sumd,sumn;

for sumncofmm,jmm1;j0;j sumnsumnxcofj;
for sumd0.0,jmmkk;jmm1;j sumdsumdcofjx;
return sumn1.0sumd;

Driver for routine pade

include stdlib.h
include string.h
include stdio.h
include math.h
define NRANSI
include nr.h
include nrutil.h

double fndouble x

return x0.0 ? 1.0 : log1.0xx;

int mainint argc, char argv

int j, k, n2048, verbose0;
float resid;
double b, d, fac, x, c;

for j0; jargc; j
if strcmpargvj, verbose0
verbose1;

else
natoiargvj;

cdvector0, 2n1;
fac1;

for j1; j2n1; j
cj1facdoublej;
facfac;

padec, n, resid;

if verbose
printfNorm of residual vector 16.8en, resid;
printfpoint, func. value, pade series:n;
for j1; j21; j
xj10.25;
dratvalx, c, n, n;
printf16.8ft16.8ft16.8fn, x, fnx, d;

freedvectorc, 0, 2n1;
return 0;

undef NRANSI

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 C math void lubksbfloat a, int n, int indx, float b
30 $