11 void leastsq(
double **
A,
double *
b,
int n1,
int n2) {
12 double *c = (
double *)malloc(n1 *
sizeof(
double));
13 memcpy(c,
b, n1 *
sizeof(
double));
16 B = (
double **)malloc(n2 *
sizeof(
double *));
17 B[0] = (
double *)malloc(n2 * n2 *
sizeof(
double));
18 for (
int i = 0; i < n2; ++i) B[i] = B[0] + i * n2;
20 for (
int i = 0; i < n2; ++i) {
22 for (
int j = 0;
j < n2; ++
j) {
25 for (
int k = 0; k < n1; ++k) B[i][
j] +=
A[k][i] *
A[k][
j];
31 for (
int j = 0;
j < n1; ++
j)
b[i] +=
A[
j][i] * c[
j];
35 int *indx = (
int *)malloc(n2 *
sizeof(
int));
void leastsq(double **A, double *b, int n1, int n2)
void lubksb(double **a, int n, int *indx, double *b)
int ludcmp(double **a, int n, int *indx)