Example #1
0
void JCCoordinator::InitFromVarInfo()
{
	DeallocateVectors();
	
	num_time_vals = 1; // for multivariate, time variable is not supported
	is_any_time_variant = false;
	is_any_sync_with_global_time = false;
	ref_var_index = -1;
    
    for (int i=0; i<var_info.size(); i++) {
        if (var_info[i].is_time_variant && var_info[i].sync_with_global_time) {
            num_time_vals = (var_info[i].time_max - var_info[i].time_min) + 1;
            if (num_time_vals < var_info[i].min.size()) {
                num_time_vals = var_info[i].min.size();
            }
            is_any_sync_with_global_time = true;
            ref_var_index = i;
            break;
        }
    }
    for (int i=0; i<var_info.size(); i++) {
        if (var_info[i].is_time_variant) {
            is_any_time_variant = true;
            break;
        }
    }
    
	AllocateVectors();
	
    int num_var = data.size();
    for (int i=0; i<num_var; i++) {
        int tms_at_var = data[i].size();
        for (int j=0; j<tms_at_var; j++) {
            for (int k=0; k<num_obs; k++) {
                data_vecs[i][j][k] = data[i][j][k];
            }
        }
    }
    
    //StandardizeData();
    GalElement* w = weights->gal;
    // get undef_tms across multi-variables
    for (int v=0; v<data_vecs.size(); v++) {
        for (int t=0; t<data_vecs[v].size(); t++) {
            for (int i=0; i<num_obs; i++) {
                undef_tms[t][i] = undef_tms[t][i] || undef_data[v][t][i];
            }
            // the isolates should be excluded as undefined
            for (int i=0; i<num_obs; i++) {
                if (w[i].Size() == 0) {
                    undef_tms[t][i] = true;
                }
            }
        }
    }
	
    CalcMultiLocalJoinCount();
    
	CalcPseudoP();
}
Example #2
0
void DisparityTool::init( int rho, int theta, int mode, double overlap, int xo, int yo, int xr, int yr, int actR) {
	
    _img = SetParam( rho, theta, mode, overlap, xo, yo, xr, yr );
    _actRings = actR;
    AllocateVectors();	
    LoadShiftMap();
    computeCountVector( _count );   
    cout << "RINGS" << actR << endl;
}
Example #3
0
BOOL CHistogram::Init32f(int numChannels, Ipp32f* ppLevels[4], Ipp32f* ppHist[4], int pnLevels[4])
{
   m_numChannels = numChannels;
   if (!SetMinMaxLevel(ppLevels, pnLevels)) return FALSE;
   AllocateVectors(ppLevels, pnLevels);
   ExpandVectors(ppLevels, ppHist, pnLevels);
   UpdateHist();
   ScaleLevels();
   ScaleHist();
   m_bInit = TRUE;
   return TRUE;
}
Example #4
0
void CHistogram::AllocateVectors(Ipp32f* ppLevels[4], int pnLevels[4])
{
   SetNumLevels(ppLevels, pnLevels);
   AllocateVectors();
}
Example #5
0
/** We assume only that var_info is initialized correctly.
 ref_var_index, is_any_time_variant, is_any_sync_with_global_time and
 num_time_vals are first updated based on var_info */ 
void LisaCoordinator::InitFromVarInfo()
{
	DeallocateVectors();
	
	num_time_vals = 1;
    is_any_time_variant = false;
    is_any_sync_with_global_time = false;
    ref_var_index = -1;
    
    if (lisa_type != differential) {
        for (int i=0; i<var_info.size(); i++) {
            if (var_info[i].is_time_variant && var_info[i].sync_with_global_time) {
                num_time_vals = (var_info[i].time_max - var_info[i].time_min) + 1;
                is_any_sync_with_global_time = true;
                ref_var_index = i;
                break;
            }
        }
        for (int i=0; i<var_info.size(); i++) {
            if (var_info[i].is_time_variant) {
                is_any_time_variant = true;
                break;
            }
        }
    }
	
	AllocateVectors();
	
    if (lisa_type == differential) {
        int t=0;
        for (int i=0; i<num_obs; i++) {
            int t0 = var_info[0].time;
            int t1 = var_info[1].time;
            data1_vecs[0][i] = data[0][t0][i] - data[0][t1][i];
        }
        
    } else if (lisa_type == univariate || lisa_type == bivariate) {
		for (int t=var_info[0].time_min; t<=var_info[0].time_max; t++) {
			int d1_t = t - var_info[0].time_min;
            for (int i=0; i<num_obs; i++) {
                data1_vecs[d1_t][i] = data[0][t][i];
            }
		}
		if (lisa_type == bivariate) {
			for (int t=var_info[1].time_min; t<=var_info[1].time_max; t++) {
				int d2_t = t - var_info[1].time_min;
				for (int i=0; i<num_obs; i++) {
					data2_vecs[d2_t][i] = data[1][t][i];
				}
			}
		}
	} else { // lisa_type == eb_rate_standardized
		std::vector<bool> undef_res(num_obs, false);
		double* smoothed_results = new double[num_obs];
		double* E = new double[num_obs]; // E corresponds to var_info[0]
		double* P = new double[num_obs]; // P corresponds to var_info[1]
		// we will only fill data1 for eb_rate_standardized and
		// further lisa calcs will treat as univariate
		for (int t=0; t<num_time_vals; t++) {
			int v0_t = var_info[0].time_min;
			if (var_info[0].is_time_variant &&
				var_info[0].sync_with_global_time) {
				v0_t += t;
			}
			for (int i=0; i<num_obs; i++) E[i] = data[0][v0_t][i];
			int v1_t = var_info[1].time_min;
			if (var_info[1].is_time_variant &&
				var_info[1].sync_with_global_time) {
				v1_t += t;
			}
			for (int i=0; i<num_obs; i++) P[i] = data[1][v1_t][i];
			bool success = GdaAlgs::RateStandardizeEB(num_obs, P, E,
														smoothed_results,
														undef_res);
			if (!success) {
				map_valid[t] = false;
				map_error_message[t] << "Emprical Bayes Rate ";
				map_error_message[t] << "Standardization failed.";
			} else {
				for (int i=0; i<num_obs; i++) {
					data1_vecs[t][i] = smoothed_results[i];
				}
			}
		}
		if (smoothed_results) delete [] smoothed_results;
		if (E) delete [] E;
		if (P) delete [] P;
	}
	
	StandardizeData();
	CalcLisa();
	if (calc_significances) CalcPseudoP();
}