proteus  1.8.1
C/C++/Fortran libraries
Solve.cpp
Go to the documentation of this file.
1 void Solve(double **a, double *b, int m, int n, double *solution, int MP, int NP)
2 {
3 int i;
4 double *w, **v, wmax, wmin;
5 double *dvector(long nl, long nh);
6 double **dmatrix(long nrl, long nrh, long ncl, long nch);
7 void dsvdcmp(double **a, int m, int n, double w[], double **v);
8 void dsvbksb(double **u, double w[], double **v, int m, int n, double b[], double x[]);
9 void free_dvector(double *v, long nl, long nh);
10 void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch);
11 
12 w=dvector(1,NP);
13 v=dmatrix(1,NP,1,NP);
14 
15 // Perform decomposition
16 
17 dsvdcmp(a,m,n,w,v);
18 
19 // Set up: see p65 of Press et al.
20 
21 wmax = 0.;
22 for ( i=1 ; i<=n ; i++) if ( w[i] >= wmax ) wmax = w[i];
23 wmin = wmax * 1.e-12;
24 for ( i=1 ; i<=n ; i++) if ( w[i] <= wmin ) w[i] = 0.;
25 
26 // Back substitute
27 
28 dsvbksb(a,w,v,m,n,b,solution);
29 
30 free_dmatrix(v,1,NP,1,NP);
31 free_dvector(w,1,NP);
32 }
33 
dmatrix
double ** dmatrix(long nrl, long nrh, long ncl, long nch)
Definition: Util.cpp:16
nl
#define nl(x)
Definition: jf.h:17
dvector
double * dvector(long nl, long nh)
Definition: Util.cpp:7
w
#define w(x)
Definition: jf.h:22
dsvbksb
void dsvbksb(double **u, double w[], double **v, int m, int n, double b[], double x[])
Definition: Dsvbksb.cpp:3
Solve
void Solve(double **a, double *b, int m, int n, double *solution, int MP, int NP)
Definition: Solve.cpp:1
free_dmatrix
void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch)
Definition: Util.cpp:44
n
Int n
Definition: Headers.h:28
v
Double v
Definition: Headers.h:95
free_dvector
void free_dvector(double *v, long nl, long nh)
Definition: Util.cpp:38
u
Double u
Definition: Headers.h:89
dsvdcmp
void dsvdcmp(double **a, int m, int n, double w[], double **v)
Definition: Dsvdcmp.cpp:15