-
Notifications
You must be signed in to change notification settings - Fork 0
/
covsrt.c
36 lines (27 loc) · 992 Bytes
/
covsrt.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/***************************************************************************
COVSRT: This is the covsrt algorithm taken from Numercial Recipes. Here's
what NR has to say about it:
"Expand in storage the covariance matrix covar, so as to take into account
parameters that are being held fixed. (For the latter, return zero
covariances.)"
I have changed the raw routine to include the following features:
0) Double precision is used.
1) Function returns an integer.
****************************************************************************/
#include <stdio.h>
#include "fit.h"
int covsrt(double **covar, int ma, int *ia, int mfit) {
double tempr=0.0;
int i=0,j=0,k=0;
for (i=mfit; i<ma; i++) {
for (j=0; j<=i; j++) covar[i][j]=covar[j][i]=0.0;
}
for (k=mfit-1,j=ma-1; j>=0; j--) {
if (ia[j]) {
for (i=0; i<ma; i++) { SWAP((covar[i][k]),(covar[i][j])); }
for (i=0; i<ma; i++) { SWAP((covar[k][i]),(covar[j][i])); }
k--;
}
}
return 1;
}