43 int Regression_size_factor,
55 int number_sample_out;
60 double *data2_sigma = NULL;
72 if (Data1->
nline < 1) {
86 number_line_in = Data1->
nline;
87 number_sample_in = Data1->
nsample;
96 if (Valid_mask1 == NULL) {
99 if (Valid_mask1->
nline != number_line_in) {
102 if (Valid_mask1->
nsample != number_sample_in) {
119 if (Data2->
nline != number_line_in) {
122 if (Data2->
nsample != number_sample_in) {
136 if (Data2_sigma == NULL) {
139 if (Data2_sigma->
nline != number_line_in) {
142 if (Data2_sigma->
nsample != number_sample_in) {
156 if (Valid_mask2 == NULL) {
159 if (Valid_mask2->
nline != number_line_in) {
162 if (Valid_mask2->
nsample != number_sample_in) {
175 if (Map_info == NULL) {
178 if (Map_info->
nline != number_line_in) {
181 if (Map_info->
nsample != number_sample_in) {
191 if (number_line_in % Regression_size_factor != 0) {
194 if (number_sample_in % Regression_size_factor != 0) {
202 if (Regression_coeff == NULL) {
210 if (Regression_coeff_map_info == NULL) {
218 number_line_out = number_line_in / Regression_size_factor;
219 number_sample_out = number_sample_in / Regression_size_factor;
226 ®ression_coeff_tmp);
233 data1 = (
double *)calloc(Regression_size_factor*Regression_size_factor,
238 data2 = (
double *)calloc(Regression_size_factor*Regression_size_factor,
243 data2_sigma = (
double *)calloc(Regression_size_factor*Regression_size_factor,
245 if (data2_sigma == NULL) {
253 for (iline = 0; iline < number_line_out ; iline++) {
254 for (isample = 0; isample < number_sample_out; isample++) {
255 int rline_start, rsample_start;
256 int rline_end, rsample_end;
259 double intercept, slope, correlation;
261 rline_start = iline * Regression_size_factor;
262 rsample_start = isample * Regression_size_factor;
263 rline_end = rline_start + Regression_size_factor;
264 rsample_end = rsample_start + Regression_size_factor;
273 for (rline = rline_start ; rline < rline_end ; rline++) {
274 for (rsample = rsample_start ; rsample < rsample_end ; rsample++) {
275 if (Valid_mask1->
data.
u8[rline][rsample] &&
276 Valid_mask2->
data.
u8[rline][rsample]) {
279 data2_sigma[
count] = Data2_sigma->
data.
f[rline][rsample];
289 &intercept, &slope, &correlation);
296 regression_coeff_tmp.
intercept.
data.
f[iline][isample] = intercept;
297 regression_coeff_tmp.
slope.
data.
f[iline][isample] = slope;
315 Map_info->
resolution * Regression_size_factor,
316 ®ression_coeff_map_info_tmp);
323 *Regression_coeff = regression_coeff_tmp;
324 *Regression_coeff_map_info = regression_coeff_map_info_tmp;
334 if (data2_sigma != NULL) {
HDFFCLIBAPI intf intf intf * count
#define MTKT_MAPINFO_INIT
MTKt_status MtkRegressionCoeffCalc(const MTKt_DataBuffer *Data1, const MTKt_DataBuffer *Valid_mask1, const MTKt_DataBuffer *Data2, const MTKt_DataBuffer *Data2_sigma, const MTKt_DataBuffer *Valid_mask2, const MTKt_MapInfo *Map_info, int Regression_size_factor, MTKt_RegressionCoeff *Regression_coeff, MTKt_MapInfo *Regression_coeff_map_info)
Calculate linear regression coefficients for translating values in data buffer 1 to corresponding val...
MTKt_DataBuffer valid_mask
MTKt_status MtkChangeMapResolution(const MTKt_MapInfo *Map_info_in, int Resolution, MTKt_MapInfo *Map_info_out)
Change resolution of an MTKt_MapInfo structure.
#define MTK_ERR_CODE_JUMP(code)
MTKt_status MtkLinearRegressionCalc(int Size, const double *X, const double *Y, const double *YSigma, double *A, double *B, double *Correlation)
Use linear regression to fit a set of observations (x,y) to the model: y(x) = a + b * x...
2-dimensional Data Buffer
MTKt_DataBuffer intercept
MTKt_status MtkRegressionCoeffFree(MTKt_RegressionCoeff *regressbuf)
Free memory for regression coefficients.
#define MTK_ERR_CODE_MSG_JUMP(code, msg)
#define MTKT_REGRESSION_COEFF_INIT
MTKt_status MtkRegressionCoeffAllocate(int nline, int nsample, MTKt_RegressionCoeff *regressbuf)
Allocate buffer to contain regression coefficients.
#define MTK_ERR_COND_JUMP(code)
MTKt_DataBuffer correlation