OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
covariance_inversion.c
Go to the documentation of this file.
1 /*
2  * covariance_inversion.c
3  *
4  *
5  * Created by Tim Moore on 12/16/09.
6  * Copyright 2009 __MyCompanyName__. All rights reserved.
7  *
8  */
9 
10 #include "nr.h"
11 #include "nrutil.h"
12 #include <math.h>
13 #define DEBUG_COVAR 0
14 #include <stdio.h>
15 #include <stddef.h>
16 #include <stdlib.h>
17 
18 void covariance_inversion(float *rrs_cov, int nclasses, int df, float ***y3inv) {
19 
20  int i, j, k, ii, jj, *indx;
21  float d, **a, *col;
22 
23  void ludcmp();
24 
25  indx = ivector(1, df);
26  col = vector(1, df);
27  a = matrix(1, df, 1, df);
28 
29  if (DEBUG_COVAR) {
30  printf("\nptr addr =%p x0=%f", rrs_cov, *(rrs_cov));
31  printf("\nnclasses = %d", nclasses);
32  printf("\ndf = %d", df);
33  }
34 
35  /******* get inversion of covariance matrix ***********/
36 
37  for (i = 0; i < nclasses; i++) {
38  for (j = 0; j < df; j++) {
39  for (k = 0; k < df; k++) a[j + 1][k + 1] = *rrs_cov++;
40  }
41 
42  ludcmp(a, df, indx, &d);
43  for (jj = 1; jj <= df; jj++) {
44  for (ii = 1; ii <= df; ii++) col[ii] = 0.0;
45  col[jj] = 1.0;
46  lubksb(a, df, indx, col);
47  for (ii = 1; ii <= df; ii++) y3inv[i + 1][ii][jj] = col[ii];
48  }
49 
50  }
51 
52  free_ivector(indx, 1, df);
53  free_vector(col, 1, df);
54  free_matrix(a, 1, df, 1, df);
55 
56 }
int j
Definition: decode_rs.h:73
float * vector(long nl, long nh)
Definition: nrutil.c:15
int * ivector(long nl, long nh)
Definition: nrutil.c:24
void ludcmp(float **a, int n, int *indx, float *d)
Definition: ludcmp.c:7
void free_matrix(float **m, long nrl, long nrh, long ncl, long nch)
Definition: nrutil.c:229
float ** matrix(long nrl, long nrh, long ncl, long nch)
Definition: nrutil.c:60
void covariance_inversion(float *rrs_cov, int nclasses, int df, float ***y3inv)
#define DEBUG_COVAR
void free_vector(float *v, long nl, long nh)
Definition: nrutil.c:204
void lubksb(float **a, int n, int *indx, float b[])
Definition: lubksb.c:2
void free_ivector(int *v, long nl, long nh)
Definition: nrutil.c:209
int i
Definition: decode_rs.h:71
PGE01 indicating that PGE02 PGE01 V6 for and PGE01 V2 for MOD03 were used to produce the granule By convention adopted in all MODIS Terra PGE02 code versions are The fourth digit of the PGE02 version denotes the LUT version used to produce the granule The source of the metadata environment variable ProcessingCenter was changed from a QA LUT value to the Process Configuration A sign used in error in the second order term was changed to a
Definition: HISTORY.txt:424
int k
Definition: decode_rs.h:73